diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2020-05-24 00:30:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 00:30:03 +0300 |
commit | 187865c5a824054651b7e816cc83700a34c541f8 (patch) | |
tree | 53dcdf91da22b28b53a97a635548b99525d971fc /mesonbuild/mintro.py | |
parent | 527536dd4ae102d2d14e7ee512b6886d57fc0149 (diff) | |
parent | 550a450324c493d6a60a793c617f855cc55381fe (diff) | |
download | meson-187865c5a824054651b7e816cc83700a34c541f8.zip meson-187865c5a824054651b7e816cc83700a34c541f8.tar.gz meson-187865c5a824054651b7e816cc83700a34c541f8.tar.bz2 |
Merge pull request #6765 from mensinda/astDump2
mintro: 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: |