aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/ast/introspection.py6
-rw-r--r--mesonbuild/mintro.py43
2 files changed, 46 insertions, 3 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index 6ac5929..da2f740 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -180,11 +180,11 @@ class IntrospectionInterpreter(AstInterpreter):
source_nodes += [curr]
# Make sure nothing can crash when creating the build class
- kwargs = {}
+ kwargs_reduced = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs and k in ['install', 'build_by_default', 'build_always']}
is_cross = False
objects = []
empty_sources = [] # Passing the unresolved sources list causes errors
- target = targetclass(name, self.subdir, self.subproject, is_cross, empty_sources, objects, self.environment, kwargs)
+ target = targetclass(name, self.subdir, self.subproject, is_cross, empty_sources, objects, self.environment, kwargs_reduced)
self.targets += [{
'name': target.get_basename(),
@@ -193,6 +193,8 @@ class IntrospectionInterpreter(AstInterpreter):
'defined_in': os.path.normpath(os.path.join(self.source_root, self.subdir, environment.build_filename)),
'subdir': self.subdir,
'build_by_default': target.build_by_default,
+ 'installed': target.should_install(),
+ 'outputs': target.get_outputs(),
'sources': source_nodes,
'kwargs': kwargs,
'node': node,
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()