aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/ast
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2019-02-16 14:17:49 +0200
committerGitHub <noreply@github.com>2019-02-16 14:17:49 +0200
commit939b011114838b886d48521806988973205aecb4 (patch)
tree77eef03f5c136867100ded7dfcfcaa442b184f33 /mesonbuild/ast
parent3ac7df6a6a016cf3ae92494bb510cbc4005571ed (diff)
parent0ce02b57d71bf4365e30063efa95a0a414a4a92a (diff)
downloadmeson-939b011114838b886d48521806988973205aecb4.zip
meson-939b011114838b886d48521806988973205aecb4.tar.gz
meson-939b011114838b886d48521806988973205aecb4.tar.bz2
Merge pull request #4858 from mensinda/rwKWARGS
rewriter: Add support for kwargs modification
Diffstat (limited to 'mesonbuild/ast')
-rw-r--r--mesonbuild/ast/interpreter.py4
-rw-r--r--mesonbuild/ast/introspection.py22
2 files changed, 20 insertions, 6 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py
index 68c017a..ce4b93c 100644
--- a/mesonbuild/ast/interpreter.py
+++ b/mesonbuild/ast/interpreter.py
@@ -113,7 +113,7 @@ class AstInterpreter(interpreterbase.InterpreterBase):
prev_subdir = self.subdir
subdir = os.path.join(prev_subdir, args[0])
absdir = os.path.join(self.source_root, subdir)
- buildfilename = os.path.join(self.subdir, environment.build_filename)
+ buildfilename = os.path.join(subdir, environment.build_filename)
absname = os.path.join(self.source_root, buildfilename)
symlinkless_dir = os.path.realpath(absdir)
if symlinkless_dir in self.visited_subdirs:
@@ -128,7 +128,7 @@ class AstInterpreter(interpreterbase.InterpreterBase):
code = f.read()
assert(isinstance(code, str))
try:
- codeblock = mparser.Parser(code, self.subdir).parse()
+ codeblock = mparser.Parser(code, subdir).parse()
except mesonlib.MesonException as me:
me.file = buildfilename
raise me
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index 4a03e98..b6a523b 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -51,9 +51,12 @@ class IntrospectionInterpreter(AstInterpreter):
self.default_options = {'backend': self.backend}
self.project_data = {}
self.targets = []
+ self.dependencies = []
+ self.project_node = None
self.funcs.update({
'add_languages': self.func_add_languages,
+ 'dependency': self.func_dependency,
'executable': self.func_executable,
'jar': self.func_jar,
'library': self.func_library,
@@ -65,6 +68,9 @@ class IntrospectionInterpreter(AstInterpreter):
})
def func_project(self, node, args, kwargs):
+ if self.project_node:
+ raise InvalidArguments('Second call to project()')
+ self.project_node = node
if len(args) < 1:
raise InvalidArguments('Not enough arguments to project(). Needs at least the project name.')
@@ -125,6 +131,16 @@ class IntrospectionInterpreter(AstInterpreter):
if lang not in self.coredata.compilers:
self.environment.detect_compilers(lang, need_cross_compiler)
+ def func_dependency(self, node, args, kwargs):
+ args = self.flatten_args(args)
+ if not args:
+ return
+ name = args[0]
+ self.dependencies += [{
+ 'name': name,
+ 'node': node
+ }]
+
def build_target(self, node, args, kwargs, targetclass):
if not args:
return
@@ -159,10 +175,8 @@ class IntrospectionInterpreter(AstInterpreter):
if elemetary_nodes:
source_nodes += [curr]
- # Filter out kwargs from other target types. For example 'soversion'
- # passed to library() when default_library == 'static'.
- kwargs = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs}
-
+ # Make sure nothing can crash when creating the build class
+ kwargs = {}
is_cross = False
objects = []
empty_sources = [] # Passing the unresolved sources list causes errors