Can check if running as a subproject.

pull/15/head
Jussi Pakkanen 11 years ago
parent 9cde4e4012
commit 2e91184b38
  1. 4
      interpreter.py
  2. 4
      test cases/common/49 subproject/meson.build
  3. 4
      test cases/common/49 subproject/sublib/meson.build

@ -614,6 +614,7 @@ class Interpreter():
'option' : self.func_option,
'get_option' : self.func_get_option,
'subproject' : self.func_subproject,
'is_subproject' : self.func_is_subproject,
}
def get_build_def_files(self):
@ -730,6 +731,9 @@ class Interpreter():
def func_option(self, nodes, args, kwargs):
raise InterpreterException('Tried to call option() in build description file. All options must be in the option file.')
def func_is_subproject(self, nodes, args, kwargs):
return self.subproject != ''
def func_subproject(self, nodes, args, kwargs):
if len(args) != 1:
raise InterpreterException('Subproject takes exactly one argument')

@ -2,6 +2,10 @@ project('subproj user', 'c')
sub = subproject('sublib')
if is_subproject()
error('Claimed to be a subproject even though we are the master project.')
endif
inc = sub.get_variable('i')
lib = sub.get_variable('l')

@ -1,5 +1,9 @@
project('subproject', 'c')
if not is_subproject()
error('Claimed to be master project even though we are a subproject.')
endif
i = include_directories('include')
l = shared_library('sublib', 'sublib.c', include_dirs : i, install : true)
t = executable('simpletest', 'simpletest.c', include_dirs : i, link_with : l)

Loading…
Cancel
Save