aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-06-02 09:38:49 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-09-22 15:50:26 -0400
commit586bd1136d38e6695369617dfcc1dba50c35b279 (patch)
tree4c6334ededcbe3005ae5bfd4f3e059738295aec2 /mesonbuild
parente9369be086dc8381cda91725fb2073c4daf29b91 (diff)
downloadmeson-586bd1136d38e6695369617dfcc1dba50c35b279.zip
meson-586bd1136d38e6695369617dfcc1dba50c35b279.tar.gz
meson-586bd1136d38e6695369617dfcc1dba50c35b279.tar.bz2
interpreter: Move code that dumps generated AST
That code is common to any method that generates an AST, like cargo subprojects coming soon.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreter/interpreter.py38
1 files changed, 14 insertions, 24 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 505099f..6afc2aa 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -953,12 +953,24 @@ class Interpreter(InterpreterBase, HoldableObject):
kwargs: kwtypes.DoSubproject,
ast: T.Optional[mparser.CodeBlockNode] = None,
build_def_files: T.Optional[T.List[str]] = None,
- is_translated: bool = False,
relaxations: T.Optional[T.Set[InterpreterRuleRelaxation]] = None) -> SubprojectHolder:
with mlog.nested(subp_name):
+ if ast:
+ # Debug print the generated meson file
+ from ..ast import AstIndentationGenerator, AstPrinter
+ printer = AstPrinter(update_ast_line_nos=True)
+ ast.accept(AstIndentationGenerator())
+ ast.accept(printer)
+ printer.post_process()
+ meson_filename = os.path.join(self.build.environment.get_build_dir(), subdir, 'meson.build')
+ with open(meson_filename, "w", encoding='utf-8') as f:
+ f.write(printer.result)
+ mlog.log('Generated Meson AST:', meson_filename)
+ mlog.cmd_ci_include(meson_filename)
+
new_build = self.build.copy()
subi = Interpreter(new_build, self.backend, subp_name, subdir, self.subproject_dir,
- default_options, ast=ast, is_translated=is_translated,
+ default_options, ast=ast, is_translated=(ast is not None),
relaxations=relaxations,
user_defined_options=self.user_defined_options)
# Those lists are shared by all interpreters. That means that
@@ -1013,37 +1025,15 @@ class Interpreter(InterpreterBase, HoldableObject):
# Generate a meson ast and execute it with the normal do_subproject_meson
ast = cm_int.pretend_to_be_meson(options.target_options)
-
- mlog.log()
- with mlog.nested('cmake-ast'):
- mlog.log('Processing generated meson AST')
-
- # Debug print the generated meson file
- from ..ast import AstIndentationGenerator, AstPrinter
- printer = AstPrinter(update_ast_line_nos=True)
- ast.accept(AstIndentationGenerator())
- ast.accept(printer)
- printer.post_process()
- meson_filename = os.path.join(self.build.environment.get_build_dir(), subdir, 'meson.build')
- with open(meson_filename, "w", encoding='utf-8') as f:
- f.write(printer.result)
-
- mlog.log('Build file:', meson_filename)
- mlog.cmd_ci_include(meson_filename)
- mlog.log()
-
result = self._do_subproject_meson(
subp_name, subdir, default_options,
kwargs, ast,
[str(f) for f in cm_int.bs_files],
- is_translated=True,
relaxations={
InterpreterRuleRelaxation.ALLOW_BUILD_DIR_FILE_REFERENCES,
}
)
result.cm_interpreter = cm_int
-
- mlog.log()
return result
def get_option_internal(self, optname: str) -> coredata.UserOption: