X-Git-Url: https://git.ralfj.de/mass-build.git/blobdiff_plain/546c80d1c559cb94223f9c459db719d143df7291..e14e79eb3d371385da62524a6555307446296482:/kdebuildpy.py diff --git a/kdebuildpy.py b/kdebuildpy.py index d7e8158..99267e8 100755 --- a/kdebuildpy.py +++ b/kdebuildpy.py @@ -11,9 +11,9 @@ parser.add_argument("-c, --config", parser.add_argument("--reconfigure", action="store_true", dest="reconfigure", help="Force configuration to be run") -parser.add_argument("--phases", choices=["update", "configure", "compile"], nargs='*', metavar='PHASE', - dest="phases", default=["update", "configure", "compile"], - help="For each module, run the given phases in the given order. Possible phases are: update, configure, compile") +parser.add_argument("--no-update", + action="store_false", dest="update", + help="Do not update modules before compilation") parser.add_argument("--resume-from", metavar='MODULE', dest="resume_from", help="Resume building from the given repository") @@ -22,35 +22,39 @@ parser.add_argument("modules", metavar='MODULE', nargs='*', args = parser.parse_args() # load config -config = imp.load_source('config', args.config) +config = imp.load_source('config', args.config).__dict__ +os.remove(args.config+'c') # remove compiled python file projects = OrderedDict() # all projects workProjects = [] # projects we work on # an entire Project class Project: - def __init__(self, folder, module): + def __init__(self, config, folder, module): self.folder = folder self.name = module['name'] # VCS - vcsName = module.get('vcs', 'kde+git') - if vcsName == 'kde+git': - self.vcs = vcs.KDEGit(self.sourceFolder(), module['name'], module['version']) - elif vcsName == 'kde+svn': - self.vcs = vcs.KDESVN(self.sourceFolder(), module['svn-path']) + vcsName = module['vcs'] + if vcsName == 'git': + self.vcs = vcs.Git(self.sourceFolder(), module['url'], module['version']) + elif vcsName == 'svn': + self.vcs = vcs.SVN(self.sourceFolder(), module['url'], module.get('versionName')) else: raise Exception("Unknown VCS type "+vcsName) # build system - buildSystemName = module.get('build-system', 'cmake') - if buildSystemName == 'cmake': - self.buildSystem = build_system.CMake(self.sourceFolder(), self.buildFolder(), config) + if config.get('buildDeb', False): + self.buildSystem = build_system.AutoDebuild(self.sourceFolder(), self.buildFolder(), module, self.vcs, config) else: - raise Exception("Unknown build system type "+buildSystemName) + buildSystemName = module['buildSystem'] + if buildSystemName == 'cmake': + self.buildSystem = build_system.CMake(self.sourceFolder(), self.buildFolder(), module, 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()) + return os.path.join(config['buildDir'], self.sourceFolder()) # return the position of the given item in the list def findInList(list, item): @@ -60,17 +64,17 @@ def findInList(list, item): raise Exception("%s not found in list" % str(item)) # populate list of projects -def loadProjects(modules, folder=''): +def loadProjects(config, modules, folder=''): for module in modules: if 'folder' in module: # a subpath - loadProjects(module['modules'], os.path.join(folder, module['folder'])) + loadProjects(config, module['modules'], os.path.join(folder, module['folder'])) else: # a proper project if module['name'] in projects: raise Exception("Duplicate module name "+module['name']) - projects[module['name']] = Project(folder, module) + projects[module['name']] = Project(config, folder, module) # now check what we have to do -loadProjects(config.modules) +loadProjects(config, config['modules']) if args.modules: if args.resume_from is not None: raise Exception("Can not use --resume-from and manually specify modules") @@ -90,16 +94,12 @@ else: # and do it! for project in workProjects: try: - for phase in args.phases: - if phase == 'update': - project.vcs.update() - elif phase == 'configure': - project.buildSystem.configure(force=args.reconfigure) - elif phase == 'compile': - project.buildSystem.build() - project.buildSystem.install() - else: - raise Exception("Invalid phase "+phase) + if args.update: + print "Updating module",project.sourceFolder() + project.vcs.update() + print "Building module",project.sourceFolder() + project.buildSystem.build(reconfigure=args.reconfigure) + print except (subprocess.CalledProcessError, KeyboardInterrupt) as e: print >> sys.stderr print >> sys.stderr