summaryrefslogtreecommitdiff
path: root/mesonbuild/ast
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2025-03-12 17:27:36 -0400
committerDylan Baker <dylan@pnwbakers.com>2025-03-14 12:58:28 -0700
commite65c879925219685cbcbb9a8367006b8c687167e (patch)
tree2deac14448d7bf8b1efa70df3954ee62fa6f52eb /mesonbuild/ast
parentfa3816a2eeecf4c2ee86bff0c1d92f9a4354c98b (diff)
downloadmeson-e65c879925219685cbcbb9a8367006b8c687167e.tar.gz
Extract common func_subdir functions to InterpreterBase
Diffstat (limited to 'mesonbuild/ast')
-rw-r--r--mesonbuild/ast/interpreter.py28
1 files changed, 4 insertions, 24 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py
index 30fc52183..878fb34ed 100644
--- a/mesonbuild/ast/interpreter.py
+++ b/mesonbuild/ast/interpreter.py
@@ -89,7 +89,6 @@ class AstInterpreter(InterpreterBase):
def __init__(self, source_root: str, subdir: str, subproject: SubProject, visitors: T.Optional[T.List[AstVisitor]] = None):
super().__init__(source_root, subdir, subproject)
self.visitors = visitors if visitors is not None else []
- self.processed_buildfiles: T.Set[str] = set()
self.assignments: T.Dict[str, BaseNode] = {}
self.assign_vals: T.Dict[str, T.Any] = {}
self.reverse_assignment: T.Dict[str, BaseNode] = {}
@@ -174,33 +173,14 @@ class AstInterpreter(InterpreterBase):
sys.stderr.write(f'Unable to evaluate subdir({args}) in AstInterpreter --> Skipping\n')
return
- prev_subdir = self.subdir
- subdir = os.path.join(prev_subdir, args[0])
- absdir = os.path.join(self.source_root, subdir)
- buildfilename = os.path.join(subdir, environment.build_filename)
- absname = os.path.join(self.source_root, buildfilename)
- symlinkless_dir = os.path.realpath(absdir)
- build_file = os.path.join(symlinkless_dir, 'meson.build')
- if build_file in self.processed_buildfiles:
+ subdir, is_new = self._resolve_subdir(self.source_root, args[0])
+ if not is_new:
sys.stderr.write('Trying to enter {} which has already been visited --> Skipping\n'.format(args[0]))
return
- self.processed_buildfiles.add(build_file)
- if not os.path.isfile(absname):
+ if not self._evaluate_subdir(self.source_root, subdir, self.visitors):
+ buildfilename = os.path.join(subdir, environment.build_filename)
sys.stderr.write(f'Unable to find build file {buildfilename} --> Skipping\n')
- return
- code = self.read_buildfile(absname, buildfilename)
- try:
- codeblock = mparser.Parser(code, absname).parse()
- except mesonlib.MesonException as me:
- me.file = absname
- raise me
-
- self.subdir = subdir
- for i in self.visitors:
- codeblock.accept(i)
- self.evaluate_codeblock(codeblock)
- self.subdir = prev_subdir
def method_call(self, node: BaseNode) -> bool:
return True