diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 04fa67a9536f..07e28c295351 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -269,7 +269,6 @@ def __init__( subproject_dir: str = 'subprojects', default_project_options: T.Optional[T.Dict[OptionKey, str]] = None, ast: T.Optional[mparser.CodeBlockNode] = None, - is_translated: bool = False, relaxations: T.Optional[T.Set[InterpreterRuleRelaxation]] = None, user_defined_options: T.Optional[coredata.SharedCMDOptions] = None, ) -> None: @@ -283,6 +282,7 @@ def __init__( self.modules: T.Dict[str, NewExtensionModule] = {} self.subproject_dir = subproject_dir self.relaxations = relaxations or set() + self.build_def_files: mesonlib.OrderedSet[str] = mesonlib.OrderedSet() if ast is None: self.load_root_meson_file() else: @@ -305,16 +305,6 @@ def __init__( self.build_holder_map() self.user_defined_options = user_defined_options self.compilers: PerMachine[T.Dict[str, 'compilers.Compiler']] = PerMachine({}, {}) - - # build_def_files needs to be defined before parse_project is called - # - # For non-meson subprojects, we'll be using the ast. Even if it does - # exist we don't want to add a dependency on it, it's autogenerated - # from the actual build files, and is just for reference. - self.build_def_files: mesonlib.OrderedSet[str] = mesonlib.OrderedSet() - if not is_translated: - build_filename = os.path.join(self.subdir, environment.build_filename) - self.build_def_files.add(build_filename) self.parse_project() self._redetect_machines() @@ -339,6 +329,11 @@ def _redetect_machines(self) -> None: self.builtin['target_machine'] = \ OBJ.MachineHolder(self.build.environment.machines.target, self) + def load_root_meson_file(self) -> None: + build_filename = os.path.join(self.subdir, environment.build_filename) + self.build_def_files.add(build_filename) + super().load_root_meson_file() + def build_func_dict(self) -> None: self.funcs.update({'add_global_arguments': self.func_add_global_arguments, 'add_global_link_arguments': self.func_add_global_link_arguments, @@ -968,8 +963,7 @@ def _do_subproject_meson(self, subp_name: str, subdir: str, new_build = self.build.copy() subi = Interpreter(new_build, self.backend, subp_name, subdir, self.subproject_dir, - default_options, ast=ast, is_translated=(ast is not None), - relaxations=relaxations, + default_options, ast=ast, relaxations=relaxations, user_defined_options=self.user_defined_options) # Those lists are shared by all interpreters. That means that # even if the subproject fails, any modification that the subproject