Some more subproject reorganisation.

pull/15/head
Jussi Pakkanen 11 years ago
parent 1f1a3f516e
commit c3db9f4909
  1. 12
      interpreter.py

@ -610,6 +610,7 @@ class Interpreter():
self.visited_subdirs = {} self.visited_subdirs = {}
self.global_flags_frozen = False self.global_flags_frozen = False
self.subprojects = {} self.subprojects = {}
self.subproject_stack = []
def build_func_dict(self): def build_func_dict(self):
self.funcs = {'project' : self.func_project, self.funcs = {'project' : self.func_project,
@ -795,10 +796,12 @@ class Interpreter():
raise InterpreterException('Subproject argument must be a string') raise InterpreterException('Subproject argument must be a string')
if self.subdir != '': if self.subdir != '':
raise InterpreterException('Subprojects must be defined at the root directory.') raise InterpreterException('Subprojects must be defined at the root directory.')
if self.subproject != '': if dirname in self.subproject_stack:
raise InterpreterException('Subprojects of subprojects are not yet supported.') fullstack = self.subdir_stack + [dirname]
if dirname in self.build.subprojects: incpath = ' => '.join(fullstack)
raise InterpreterException('Tried to add the same subproject twice.') raise InterpreterException('Recursive include of subprojects: %s.' % incpath)
if dirname == self.subprojects:
return self.subprojects[dirname]
subdir = os.path.join('subprojects', dirname) subdir = os.path.join('subprojects', dirname)
abs_subdir = os.path.join(self.build.environment.get_source_dir(), subdir) abs_subdir = os.path.join(self.build.environment.get_source_dir(), subdir)
if not os.path.isdir(abs_subdir): if not os.path.isdir(abs_subdir):
@ -806,6 +809,7 @@ class Interpreter():
self.global_flags_frozen = True self.global_flags_frozen = True
mlog.log('\nExecuting subproject ', mlog.bold(dirname), '.\n', sep='') mlog.log('\nExecuting subproject ', mlog.bold(dirname), '.\n', sep='')
subi = Interpreter(self.build, subdir) subi = Interpreter(self.build, subdir)
subi.subproject_stack = self.subproject_stack + [subdir]
subi.run() subi.run()
mlog.log('\nSubproject', mlog.bold(dirname), 'finished.') mlog.log('\nSubproject', mlog.bold(dirname), 'finished.')
self.build.subprojects[dirname] = True self.build.subprojects[dirname] = True

Loading…
Cancel
Save