diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-12-12 17:03:53 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-05-23 18:13:16 +0200 |
commit | 96eeef62ea791b19fbf9bd57c8494743b2de80bf (patch) | |
tree | 8129cdfea90547cc753767a3ed1a0a2fc917a5b5 /mesonbuild/mintro.py | |
parent | f2e2e910d9c646849e55f97215217b87de491805 (diff) | |
download | meson-96eeef62ea791b19fbf9bd57c8494743b2de80bf.zip meson-96eeef62ea791b19fbf9bd57c8494743b2de80bf.tar.gz meson-96eeef62ea791b19fbf9bd57c8494743b2de80bf.tar.bz2 |
ast: Add AST JSON printer
Diffstat (limited to 'mesonbuild/mintro.py')
-rw-r--r-- | mesonbuild/mintro.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 54e302b..8eb659b 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -22,7 +22,7 @@ project files and don't need this info.""" import json from . import build, coredata as cdata from . import mesonlib -from .ast import IntrospectionInterpreter, build_target_functions, AstConditionLevel, AstIDGenerator, AstIndentationGenerator +from .ast import IntrospectionInterpreter, build_target_functions, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstJSONPrinter from . import mlog from .backend import backends from .mparser import BaseNode, FunctionNode, ArrayNode, ArgumentNode, StringNode @@ -62,6 +62,7 @@ def get_meson_introspection_types(coredata: T.Optional[cdata.CoreData] = None, benchmarkdata = testdata = installdata = None return { + 'ast': IntroCommand('Dump the AST of the meson file', no_bd=dump_ast), 'benchmarks': IntroCommand('List all benchmarks', func=lambda: list_benchmarks(benchmarkdata)), 'buildoptions': IntroCommand('List all build options', func=lambda: list_buildoptions(coredata), no_bd=list_buildoptions_from_source), 'buildsystem_files': IntroCommand('List files that make up the build system', func=lambda: list_buildsystem_files(builddata, interpreter)), @@ -89,6 +90,11 @@ def add_arguments(parser): help='Always use the new JSON format for multiple entries (even for 0 and 1 introspection commands)') parser.add_argument('builddir', nargs='?', default='.', help='The build directory') +def dump_ast(intr: IntrospectionInterpreter) -> T.Dict[str, T.Any]: + printer = AstJSONPrinter() + intr.ast.accept(printer) + return printer.result + def list_installed(installdata): res = {} if installdata is not None: |