Skip to content

Commit

Permalink
[WIP] SQUASHME
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Feb 7, 2024
1 parent 9ba0d5b commit 6866f1e
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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']),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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}"')
Expand Down Expand Up @@ -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]],
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 6866f1e

Please sign in to comment.