-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Assorted fixes for building MPV on Win32 #16164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -314,9 +314,6 @@ def should_use_rspfile(self, element: NinjaBuildElement) -> bool: | |
| element.elems) >= rsp_threshold | ||
|
|
||
| class NinjaBuildElement: | ||
|
|
||
| rule: NinjaRule | ||
|
|
||
| def __init__(self, all_outputs: T.Set[str], outfilenames: ListifiedStr, rulename: str, infilenames: ListifiedStr, implicit_outs: T.Optional[T.List[str]] = None): | ||
| self.implicit_outfilenames = implicit_outs or [] | ||
| if isinstance(outfilenames, str): | ||
|
|
@@ -334,6 +331,7 @@ def __init__(self, all_outputs: T.Set[str], outfilenames: ListifiedStr, rulename | |
| self.elems: T.List[T.Tuple[str, T.List[str]]] = [] | ||
| self.all_outputs = all_outputs | ||
| self.output_errors = '' | ||
| self.rule: NinjaRule | None = None | ||
|
|
||
| def add_dep(self, dep: ListifiedStr) -> None: | ||
| if isinstance(dep, list): | ||
|
|
@@ -359,6 +357,9 @@ def add_item(self, name: str, elems: T.Union[ListifiedStr, CompilerArgs]) -> Non | |
| if name == 'DEPFILE': | ||
| self.elems.append((name + '_UNQUOTED', elems)) | ||
|
|
||
| def remove_item(self, name: str) -> None: | ||
| self.elems[:] = [e for e in self.elems if e[0] != name] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make As an extra benefit |
||
|
|
||
| @mesonlib.lazy_property | ||
| def _should_use_rspfile(self) -> bool: | ||
| # 'phony' is a rule built-in to ninja | ||
|
|
@@ -3390,7 +3391,12 @@ def quote_make_target(targetName: str) -> str: | |
| result += c | ||
| return result | ||
| element.add_item('CUDA_ESCAPED_TARGET', quote_make_target(rel_obj)) | ||
| element.add_item('ARGS', commands) | ||
|
|
||
| # NinjaRule.should_use_rspfile counts element.elems too, which will | ||
| # exceed the RSP threshold only after added | ||
| if self.ninja.should_use_rspfile(element) and compiler.rsp_file_syntax() == RSPFileSyntax.NASM: | ||
| element.remove_item('ARGS') | ||
|
Comment on lines
+3396
to
+3399
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems correct -- calculating this outside would be a waste of time, anyway. |
||
| exe = compiler.get_exelist() | ||
| # Add to commands the args created by generate_compile_rule_for(). | ||
| # commands remain separate from exelist because they must stay | ||
|
|
@@ -3409,8 +3415,6 @@ def quote_make_target(targetName: str) -> str: | |
| cmd_type = f' (wrapped by meson {reason})' if reason else '' | ||
| element.add_item('COMMAND', meson_exe_cmd) | ||
| element.add_item('description', f'Compiling {compiler.get_display_language()} object {rel_obj}{cmd_type}') | ||
| else: | ||
| element.add_item('ARGS', commands) | ||
|
|
||
| self.add_dependency_scanner_entries_to_element(target, compiler, element, src) | ||
| self.add_build(element) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -437,7 +437,7 @@ def handle_working_dir(key: str, target: CMakeGeneratorTarget) -> None: | |
|
|
||
| for i in args: | ||
| if i in magic_keys: | ||
| if i == 'OUTPUT': | ||
| if i in ('OUTPUT', 'BYPRODUCTS'): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pylint asks to use |
||
| fn = handle_output | ||
| elif i == 'DEPENDS': | ||
| fn = handle_depends | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later code assumes that it cannot be None, so this is type-unsafe.
The current intended use of this code is that any time a NinjaBuildElement is created,
NinjaBackend.add_build(self, build)is called, and setsbuild.rule = self.ruledict[build.rulename].The type system doesn't have a good way to describe "the function isn't completely initialized by
__init__()" but saying that the property is nullable isn't the correct way to handle this. At least not without more work. Nullable != "uninitialized".Since commit 739e86f (your previous commit) all call sites for
self.rule.*properties occur after a code flow that checksself._should_use_rspfilebut I'm not convinced that's actually a good way to uphold this invariant. We could easily add other code accessing self.rule by accident etc.Perhaps we should be setting it in
__init__rather than adding it after the fact.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have one in mesonlib:
A bit of a mouthful to declare it, but it works and it allows removing the
if self.rulestatement in_should_use_rspfile.Setting it in
__init__requires passing theNinjaBuild, which is a largeish change and thelate_propertyalternative is easier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, thanks. I forgot we added that!