summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/ast/interpreter.py25
-rw-r--r--mesonbuild/ast/introspection.py7
-rw-r--r--mesonbuild/mintro.py7
3 files changed, 9 insertions, 30 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py
index cd8156a3f..271ad7d6d 100644
--- a/mesonbuild/ast/interpreter.py
+++ b/mesonbuild/ast/interpreter.py
@@ -13,7 +13,6 @@ from .. import mparser, mesonlib
from .. import environment
from ..interpreterbase import (
- MesonInterpreterObject,
InterpreterBase,
InvalidArguments,
BreakRequest,
@@ -60,27 +59,6 @@ if T.TYPE_CHECKING:
UMinusNode,
)
-class DontCareObject(MesonInterpreterObject):
- pass
-
-class MockExecutable(MesonInterpreterObject):
- pass
-
-class MockStaticLibrary(MesonInterpreterObject):
- pass
-
-class MockSharedLibrary(MesonInterpreterObject):
- pass
-
-class MockCustomTarget(MesonInterpreterObject):
- pass
-
-class MockRunTarget(MesonInterpreterObject):
- pass
-
-ADD_SOURCE = 0
-REMOVE_SOURCE = 1
-
_T = T.TypeVar('_T')
_V = T.TypeVar('_V')
@@ -232,9 +210,6 @@ class AstInterpreter(InterpreterBase):
def evaluate_indexing(self, node: IndexNode) -> int:
return 0
- def unknown_function_called(self, func_name: str) -> None:
- pass
-
def reduce_arguments(
self,
args: mparser.ArgumentNode,
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index f2a0c5ae0..2f1572f38 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -43,8 +43,11 @@ class IntrospectionHelper:
return NotImplemented
class IntrospectionInterpreter(AstInterpreter):
- # Interpreter to detect the options without a build directory
- # Most of the code is stolen from interpreter.Interpreter
+ # If you run `meson setup ...` the `Interpreter`-class walks over the AST.
+ # If you run `meson rewrite ...` and `meson introspect meson.build ...`,
+ # the `AstInterpreter`-class walks over the AST.
+ # Works without a build directory.
+ # Most of the code is stolen from interpreter.Interpreter .
def __init__(self,
source_root: str,
subdir: str,
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index 462ee2fb4..7c3a85024 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -54,7 +54,7 @@ class IntroCommand:
def get_meson_introspection_types(coredata: T.Optional[cdata.CoreData] = None,
builddata: T.Optional[build.Build] = None,
- backend: T.Optional[backends.Backend] = None) -> 'T.Mapping[str, IntroCommand]':
+ backend: T.Optional[backends.Backend] = None) -> T.Mapping[str, IntroCommand]:
if backend and builddata:
benchmarkdata = backend.create_test_serialisation(builddata.get_benchmarks())
testdata = backend.create_test_serialisation(builddata.get_tests())
@@ -546,10 +546,11 @@ def run(options: argparse.Namespace) -> int:
datadir = os.path.join(options.builddir, datadir)
indent = 4 if options.indent else None
results: T.List[T.Tuple[str, T.Union[dict, T.List[T.Any]]]] = []
- sourcedir = '.' if options.builddir == 'meson.build' else options.builddir[:-11]
intro_types = get_meson_introspection_types()
- if 'meson.build' in [os.path.basename(options.builddir), options.builddir]:
+ # TODO: This if clause is undocumented.
+ if os.path.basename(options.builddir) == environment.build_filename:
+ sourcedir = '.' if options.builddir == environment.build_filename else options.builddir[:-len(environment.build_filename)]
# Make sure that log entries in other parts of meson don't interfere with the JSON output
with redirect_stdout(sys.stderr):
backend = backends.get_backend_from_name(options.backend)