aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-12-09 02:59:15 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2013-12-09 02:59:15 +0200
commit8e9879a83c39a0085bb279570401418ae62a05eb (patch)
treee0d996a1e57b8796c3d114b74a4f1341fb9399da
parentf6937e99ebd03a9f25ad1e5222bea060e7bfb48e (diff)
downloadmeson-8e9879a83c39a0085bb279570401418ae62a05eb.zip
meson-8e9879a83c39a0085bb279570401418ae62a05eb.tar.gz
meson-8e9879a83c39a0085bb279570401418ae62a05eb.tar.bz2
Can parse subprojects but it does not work yet.
-rw-r--r--build.py2
-rw-r--r--interpreter.py26
-rw-r--r--test cases/common/49 subproject/meson.build2
3 files changed, 21 insertions, 9 deletions
diff --git a/build.py b/build.py
index 8a861ec..5468483 100644
--- a/build.py
+++ b/build.py
@@ -52,7 +52,7 @@ class Build:
self.cross_compilers.append(compiler)
def get_project(self):
- return self.project
+ return self.projects['']
def get_targets(self):
return self.targets
diff --git a/interpreter.py b/interpreter.py
index 6098d43..e1e4414 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -357,9 +357,21 @@ class Test(InterpreterObject):
return self.name
class SubprojectHolder(InterpreterObject):
- def __init(self):
+
+ def __init__(self, subinterpreter):
super().__init__()
-
+ self.subinterpreter = subinterpreter
+ self.methods.update({
+ 'get_variable' : self.get_variable_method,
+ })
+
+ def get_variable_method(self, args, kwargs):
+ if len(args) != 1:
+ raise InterpreterException('Get_variable takes one argument.')
+ varname = args[0]
+ if not isinstance(varname, str):
+ raise InterpreterException('Get_variable takes a string argument.')
+ return self.subinterpreter.variables[varname]
class CompilerHolder(InterpreterObject):
def __init__(self, compiler, env):
@@ -545,8 +557,8 @@ class Interpreter():
def __init__(self, build, subproject=''):
self.build = build
self.subproject = subproject
- code = open(os.path.join(build.environment.get_source_dir(),\
- subproject, environment.build_filename)).read()
+ self.source_root = os.path.join(build.environment.get_source_dir(), subproject)
+ code = open(os.path.join(self.source_root, environment.build_filename)).read()
if len(code.strip()) == 0:
raise InvalidCode('Builder file is empty.')
assert(isinstance(code, str))
@@ -729,7 +741,7 @@ class Interpreter():
self.global_flags_frozen = True
subi = Interpreter(self.build, subdir)
subi.run()
- self.subprojects[dirname] = SubprojectHolder()
+ self.subprojects[dirname] = SubprojectHolder(subi)
return self.subprojects[dirname]
def func_get_option(self, nodes, args, kwargs):
@@ -1032,7 +1044,7 @@ class Interpreter():
objs = [objs]
if name in self.build.targets:
raise InvalidCode('Tried to create target "%s", but a target of that name already exists.' % name)
- self.check_sources_exist(os.path.join(self.environment.source_dir, self.subdir), sources)
+ self.check_sources_exist(os.path.join(self.source_root, self.subdir), sources)
l = targetclass(name, self.subdir, is_cross, sources, objs, self.environment, kwargs)
self.build.targets[name] = l.held_object
if self.environment.is_cross_build() and l.is_cross:
@@ -1047,7 +1059,7 @@ class Interpreter():
for s in sources:
if not isinstance(s, str):
continue # This means a generated source and they always exist.
- fname = os.path.join(subdir, s)
+ fname = os.path.join(self.subproject, subdir, s)
if not os.path.isfile(fname):
raise InterpreterException('Tried to add non-existing source %s.' % s)
diff --git a/test cases/common/49 subproject/meson.build b/test cases/common/49 subproject/meson.build
index fcb2c2d..18531f5 100644
--- a/test cases/common/49 subproject/meson.build
+++ b/test cases/common/49 subproject/meson.build
@@ -5,5 +5,5 @@ sub = subproject('sublib')
inc = sub.get_variable('i')
lib = sub.get_variable('l')
-e = executable('user.c', include_dirs : inc, link_with : lib)
+e = executable('user', 'user.c', include_dirs : inc, link_with : lib)
test('subdirtest', e)