+# helper functions
+def load_module(name, path, write_bytecode = False):
+ old_val = sys.dont_write_bytecode
+ sys.dont_write_bytecode = not write_bytecode
+ module = None
+ try:
+ from importlib.machinery import SourceFileLoader
+ module = SourceFileLoader(name, path).load_module()
+ except ImportError:
+ import imp
+ module = imp.load_source(name, path)
+ finally:
+ sys.dont_write_bytecode = old_val
+ return module
+
+# an entire Project
+class Project:
+ def __init__(self, folder, config):
+ self.folder = folder
+ self.name = config['name']
+ # VCS
+ vcsName = config['vcs']
+ if vcsName == 'git':
+ self.vcs = vcs.Git(self.sourceFolder(), config)
+ elif vcsName == 'svn':
+ self.vcs = vcs.SVN(self.sourceFolder(), config['url'])
+ else:
+ raise Exception("Unknown VCS type "+vcsName)
+ # build system
+ if config.get('buildDeb', False):
+ self.buildSystem = build_system.AutoDebuild(self.sourceFolder(), self.buildFolder(), config, self.vcs)
+ else:
+ buildSystemName = config['buildSystem']
+ if buildSystemName == 'cmake':
+ self.buildSystem = build_system.CMake(self.sourceFolder(), self.buildFolder(), config)
+ else:
+ raise Exception("Unknown build system type "+buildSystemName)
+
+ def sourceFolder(self):
+ return os.path.join(self.folder, self.name)
+
+ def buildFolder(self):
+ return os.path.join(config['buildDir'], self.sourceFolder())
+