diff options
-rw-r--r-- | mesonbuild/ast/__init__.py | 4 | ||||
-rw-r--r-- | mesonbuild/ast/introspection.py | 9 | ||||
-rw-r--r-- | mesonbuild/mintro.py | 4 | ||||
-rw-r--r-- | mesonbuild/rewriter.py | 4 |
4 files changed, 13 insertions, 8 deletions
diff --git a/mesonbuild/ast/__init__.py b/mesonbuild/ast/__init__.py index 4fb56cb..d14620f 100644 --- a/mesonbuild/ast/__init__.py +++ b/mesonbuild/ast/__init__.py @@ -24,11 +24,11 @@ __all__ = [ 'AstVisitor', 'AstPrinter', 'IntrospectionInterpreter', - 'build_target_functions', + 'BUILD_TARGET_FUNCTIONS', ] from .interpreter import AstInterpreter -from .introspection import IntrospectionInterpreter, build_target_functions +from .introspection import IntrospectionInterpreter, BUILD_TARGET_FUNCTIONS from .visitor import AstVisitor from .postprocess import AstConditionLevel, AstIDGenerator, AstIndentationGenerator from .printer import AstPrinter, AstJSONPrinter diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 135ce05..f7d3e20 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -35,7 +35,12 @@ if T.TYPE_CHECKING: from ..interpreterbase import TYPE_nvar from .visitor import AstVisitor -build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries'] + +# TODO: it would be nice to not have to duplicate this +BUILD_TARGET_FUNCTIONS = [ + 'executable', 'jar', 'library', 'shared_library', 'shared_module', + 'static_library', 'both_libraries' +] class IntrospectionHelper(argparse.Namespace): # mimic an argparse namespace @@ -245,7 +250,7 @@ class IntrospectionInterpreter(AstInterpreter): continue arg_nodes = arg_node.arguments.copy() # Pop the first element if the function is a build target function - if isinstance(curr, FunctionNode) and curr.func_name in build_target_functions: + if isinstance(curr, FunctionNode) and curr.func_name in BUILD_TARGET_FUNCTIONS: arg_nodes.pop(0) elemetary_nodes = [x for x in arg_nodes if isinstance(x, (str, StringNode))] inqueue += [x for x in arg_nodes if isinstance(x, (FunctionNode, ArrayNode, IdNode, ArithmeticNode))] diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 223c31d..e83c08b 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -23,7 +23,7 @@ import collections import json from . import build, coredata as cdata from . import mesonlib -from .ast import IntrospectionInterpreter, build_target_functions, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstJSONPrinter +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 @@ -166,7 +166,7 @@ def list_targets_from_source(intr: IntrospectionInterpreter) -> T.List[T.Dict[st args = [] # type: T.List[BaseNode] if isinstance(n, FunctionNode): args = list(n.args.arguments) - if n.func_name in build_target_functions: + if n.func_name in BUILD_TARGET_FUNCTIONS: args.pop(0) elif isinstance(n, ArrayNode): args = n.args.arguments diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py index 7c8e414..7912fc7 100644 --- a/mesonbuild/rewriter.py +++ b/mesonbuild/rewriter.py @@ -24,7 +24,7 @@ # - reindent? from __future__ import annotations -from .ast import IntrospectionInterpreter, build_target_functions, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstPrinter +from .ast import IntrospectionInterpreter, BUILD_TARGET_FUNCTIONS, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstPrinter from mesonbuild.mesonlib import MesonException from . import mlog, environment from functools import wraps @@ -628,7 +628,7 @@ class Rewriter: args = [] if isinstance(n, FunctionNode): args = list(n.args.arguments) - if n.func_name in build_target_functions: + if n.func_name in BUILD_TARGET_FUNCTIONS: args.pop(0) elif isinstance(n, ArrayNode): args = n.args.arguments |