diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-02-18 15:51:40 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-03-03 23:19:03 +0100 |
commit | 8a1411a1e8a8a2c37de0d25ec129aba65703616e (patch) | |
tree | 177f00b186231bac4548d97ebf76e66e609603f6 /mesonbuild/mintro.py | |
parent | 98e60f59acf9bf2c74bc38cb8d0285a5d76293a7 (diff) | |
download | meson-8a1411a1e8a8a2c37de0d25ec129aba65703616e.zip meson-8a1411a1e8a8a2c37de0d25ec129aba65703616e.tar.gz meson-8a1411a1e8a8a2c37de0d25ec129aba65703616e.tar.bz2 |
Target introspection from source
Diffstat (limited to 'mesonbuild/mintro.py')
-rw-r--r-- | mesonbuild/mintro.py | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index f7e5358..ed74781 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -22,9 +22,10 @@ project files and don't need this info.""" import json from . import build, coredata as cdata from . import mesonlib -from .ast import IntrospectionInterpreter +from .ast import IntrospectionInterpreter, build_target_functions from . import mlog from .backend import backends +from .mparser import FunctionNode, ArrayNode, ArgumentNode, StringNode import sys, os import pathlib @@ -75,6 +76,7 @@ def get_meson_introspection_types(coredata: cdata.CoreData = None, builddata: bu }, 'targets': { 'func': lambda: list_targets(builddata, installdata, backend), + 'no_bd': lambda intr: list_targets_from_source(intr), 'desc': 'List top level targets.', }, 'tests': { @@ -115,6 +117,45 @@ def list_installed(installdata): res[path] = os.path.join(installdata.prefix, installpath) return res +def list_targets_from_source(intr: IntrospectionInterpreter): + tlist = [] + for i in intr.targets: + sources = [] + for n in i['sources']: + args = [] + if isinstance(n, FunctionNode): + args = list(n.args.arguments) + if n.func_name in build_target_functions: + args.pop(0) + elif isinstance(n, ArrayNode): + args = n.args.arguments + elif isinstance(n, ArgumentNode): + args = n.arguments + for j in args: + if isinstance(j, StringNode): + sources += [j.value] + elif isinstance(j, str): + sources += [j] + + tlist += [{ + 'name': i['name'], + 'id': i['id'], + 'type': i['type'], + 'defined_in': i['defined_in'], + 'filename': [os.path.join(i['subdir'], x) for x in i['outputs']], + 'build_by_default': i['build_by_default'], + 'target_sources': [{ + 'language': 'unknown', + 'compiler': [], + 'parameters': [], + 'sources': [os.path.normpath(os.path.join(os.path.abspath(intr.source_root), i['subdir'], x)) for x in sources], + 'generated_sources': [] + }], + 'installed': i['installed'] + }] + + return tlist + def list_targets(builddata: build.Build, installdata, backend: backends.Backend): tlist = [] build_dir = builddata.environment.get_build_dir() |