Skip to content

Commit

Permalink
interpreter: remove is_translated
Browse files Browse the repository at this point in the history
It's not actually useful, we can just add the root meson.build file to
the depfiles when we translate the meson.build into ast. If there's a
provided ast then we don't go down that path anyway.
dcbaker committed Nov 15, 2024
1 parent cad6081 commit 5d0e073
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5d0e073

Please sign in to comment.