From 6866f1e81fe58d5d5cf6d34da9e20716fc0be0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 7 Feb 2024 14:17:07 +0100 Subject: [PATCH] [WIP] SQUASHME --- mesonbuild/interpreter/interpreter.py | 47 +++++++++++++++------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 7b860543f49a..b2b91b2136b8 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1775,8 +1775,8 @@ def func_find_program(self, node: mparser.BaseNode, args: T.Tuple[T.List[mesonli search_dirs = extract_search_dirs(kwargs) default_options = kwargs['default_options'] - return self.find_program_impl(args[0], kwargs['native'], default_options=default_options, required=required, - silent=False, wanted=kwargs['version'], + return self.find_program_impl(args[0], self._machine_from_kwargs(kwargs), default_options=default_options, + required=required, silent=False, wanted=kwargs['version'], search_dirs=search_dirs) # When adding kwargs, please check if they make sense in dependencies.get_dep_identifier() @@ -1977,7 +1977,7 @@ def func_vcs_tag(self, node: mparser.BaseNode, args: T.List['TYPE_var'], kwargs: tg = build.CustomTarget( kwargs['output'][0], self.subdir, - self.subp_id, + self.subproject, self.environment, cmd, self.source_strings_to_files(kwargs['input']), @@ -2098,7 +2098,7 @@ def func_custom_target(self, node: mparser.FunctionNode, args: T.Tuple[str], tg = build.CustomTarget( name, self.subdir, - self.subp_id, + self.subproject, self.environment, command, inputs, @@ -2137,7 +2137,7 @@ def func_run_target(self, node: mparser.FunctionNode, args: T.Tuple[str], if isinstance(all_args[0], str): all_args[0] = self.find_program_impl([all_args[0]]) name = args[0] - tg = build.RunTarget(name, all_args, kwargs['depends'], self.subdir, self.subp_id, self.environment, + tg = build.RunTarget(name, all_args, kwargs['depends'], self.subdir, self.subproject, self.environment, kwargs['env']) self.add_target(name, tg) return tg @@ -2148,7 +2148,7 @@ def func_run_target(self, node: mparser.FunctionNode, args: T.Tuple[str], def func_alias_target(self, node: mparser.BaseNode, args: T.Tuple[str, T.List[build.Target]], kwargs: 'TYPE_kwargs') -> build.AliasTarget: name, deps = args - tg = build.AliasTarget(name, deps, self.subdir, self.subp_id, self.environment) + tg = build.AliasTarget(name, deps, self.subdir, self.subproject, self.environment) self.add_target(name, tg) return tg @@ -2891,28 +2891,28 @@ def func_add_test_setup(self, node: mparser.BaseNode, args: T.Tuple[str], kwargs @typed_pos_args('add_global_arguments', varargs=str) @typed_kwargs('add_global_arguments', NATIVE_KW, LANGUAGE_KW) def func_add_global_arguments(self, node: mparser.FunctionNode, args: T.Tuple[T.List[str]], kwargs: 'kwtypes.FuncAddProjectArgs') -> None: - self._add_global_arguments(node, self.build.global_args[kwargs['native']], args[0], kwargs) + self._add_global_arguments(node, self.build.global_args[self._machine_from_kwargs(kwargs)], args[0], kwargs) @typed_pos_args('add_global_link_arguments', varargs=str) @typed_kwargs('add_global_arguments', NATIVE_KW, LANGUAGE_KW) def func_add_global_link_arguments(self, node: mparser.FunctionNode, args: T.Tuple[T.List[str]], kwargs: 'kwtypes.FuncAddProjectArgs') -> None: - self._add_global_arguments(node, self.build.global_link_args[kwargs['native']], args[0], kwargs) + self._add_global_arguments(node, self.build.global_link_args[self._machine_from_kwargs(kwargs)], args[0], kwargs) @typed_pos_args('add_project_arguments', varargs=str) @typed_kwargs('add_project_arguments', NATIVE_KW, LANGUAGE_KW) def func_add_project_arguments(self, node: mparser.FunctionNode, args: T.Tuple[T.List[str]], kwargs: 'kwtypes.FuncAddProjectArgs') -> None: - self._add_project_arguments(node, self.build.projects_args[kwargs['native']], args[0], kwargs) + self._add_project_arguments(node, self.build.projects_args[self._machine_from_kwargs(kwargs)], args[0], kwargs) @typed_pos_args('add_project_link_arguments', varargs=str) @typed_kwargs('add_global_arguments', NATIVE_KW, LANGUAGE_KW) def func_add_project_link_arguments(self, node: mparser.FunctionNode, args: T.Tuple[T.List[str]], kwargs: 'kwtypes.FuncAddProjectArgs') -> None: - self._add_project_arguments(node, self.build.projects_link_args[kwargs['native']], args[0], kwargs) + self._add_project_arguments(node, self.build.projects_link_args[self._machine_from_kwargs(kwargs)], args[0], kwargs) @FeatureNew('add_project_dependencies', '0.63.0') @typed_pos_args('add_project_dependencies', varargs=dependencies.Dependency) @typed_kwargs('add_project_dependencies', NATIVE_KW, LANGUAGE_KW) def func_add_project_dependencies(self, node: mparser.FunctionNode, args: T.Tuple[T.List[dependencies.Dependency]], kwargs: 'kwtypes.FuncAddProjectArgs') -> None: - for_machine = kwargs['native'] + for_machine = self._machine_from_kwargs(kwargs) for lang in kwargs['language']: if lang not in self.compilers[for_machine]: raise InvalidCode(f'add_project_dependencies() called before add_language() for language "{lang}"') @@ -2972,9 +2972,9 @@ def _add_global_arguments(self, node: mparser.FunctionNode, argsdict: T.Dict[str def _add_project_arguments(self, node: mparser.FunctionNode, argsdict: T.Dict[str, T.Dict[str, T.List[str]]], args: T.List[str], kwargs: 'kwtypes.FuncAddProjectArgs') -> None: - if self.subp_id not in argsdict: - argsdict[self.subp_id] = {} - self._add_arguments(node, argsdict[self.subp_id], + if self.subproject not in argsdict: + argsdict[self.subproject] = {} + self._add_arguments(node, argsdict[self.subproject], self.project_args_frozen, args, kwargs) def _add_arguments(self, node: mparser.FunctionNode, argsdict: T.Dict[str, T.List[str]], @@ -3192,8 +3192,9 @@ def add_target(self, name: str, tobj: build.Target) -> None: FeatureNew.single_use(f'multiple executables with the same name, "{tobj.name}", but different suffixes in the same directory', '1.3.0', self.subproject, location=self.current_node) - if self.environment.is_native_clone and hasattr(tobj, 'for_machine'): - tobj.for_machine = MachineChoice.BUILD + # XXX: Do we still need this? + #if self.environment.is_native_clone and hasattr(tobj, 'for_machine'): + # tobj.for_machine = MachineChoice.BUILD if isinstance(tobj, build.BuildTarget): self.add_languages(tobj.missing_languages, True, tobj.for_machine) @@ -3321,14 +3322,13 @@ def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargs targetclass: T.Type[T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]] ) -> T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]: name, sources = args - for_machine = kwargs['native'] + for_machine = self._machine_from_kwargs(kwargs) + if self.environment.is_native_clone: + kwargs['install'] = False if kwargs.get('rust_crate_type') == 'proc-macro': # Silently force to native because that's the only sensible value # and rust_crate_type is deprecated any way. for_machine = MachineChoice.BUILD - elif self.environment.is_native_clone: - for_machine = MachineChoice.BUILD - kwargs['install'] = False # Avoid mutating, since there could be other references to sources sources = sources + kwargs['sources'] if any(isinstance(s, build.BuildTarget) for s in sources): @@ -3436,13 +3436,18 @@ def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargs if kwargs['implib'] is None: kwargs['implib'] = False - target = targetclass(name, self.subdir, self.subp_id, for_machine, srcs, struct, objs, + target = targetclass(name, self.subdir, self.subproject, for_machine, srcs, struct, objs, self.environment, self.compilers[for_machine], kwargs) self.add_target(name, target) self.project_args_frozen = True return target + def _machine_from_kwargs(self, kwargs) -> MachineChoice: + if self.environment.is_native_clone: + return MachineChoice.BUILD + return kwargs['native'] + def kwarg_strings_to_includedirs(self, kwargs: kwtypes._BuildTarget) -> None: if kwargs['d_import_dirs']: items = kwargs['d_import_dirs']