X-Git-Url: https://git.ralfj.de/mass-build.git/blobdiff_plain/7cc4b869c9189b01675fae5b8ff9e478c04ec68b:/kdebuildpy.py..dd327144735038acd1b61aa0046e8c9a63ab86ce:/static/git-logo.png diff --git a/kdebuildpy.py b/kdebuildpy.py deleted file mode 100755 index 99267e8..0000000 --- a/kdebuildpy.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/python -import vcs, build_system, imp -import argparse, os, sys, subprocess -from collections import OrderedDict - -# read command-line arguments -parser = argparse.ArgumentParser(description='Build KDE') -parser.add_argument("-c, --config", - dest="config", default="config.py", - help="kdebuildpy config file") -parser.add_argument("--reconfigure", - action="store_true", dest="reconfigure", - help="Force configuration to be run") -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") -parser.add_argument("modules", metavar='MODULE', nargs='*', - help="Manually specify modules to be built") -args = parser.parse_args() - -# load 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, config, folder, module): - self.folder = folder - self.name = module['name'] - # VCS - 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 - if config.get('buildDeb', False): - self.buildSystem = build_system.AutoDebuild(self.sourceFolder(), self.buildFolder(), module, self.vcs, config) - else: - 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 the position of the given item in the list -def findInList(list, item): - for i in xrange(len(list)): - if list[i] == item: - return i - raise Exception("%s not found in list" % str(item)) - -# populate list of projects -def loadProjects(config, modules, folder=''): - for module in modules: - if 'folder' in module: # a subpath - 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(config, folder, module) - -# now check what we have to do -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") - for module in args.modules: - if not module in projects: - raise Exception("Project %s does not exist" % module) - workProjects.append(projects[module]) -elif args.resume_from is None: - workProjects = projects.values() # all the projects -else: - if not args.resume_from in projects: - raise Exception("Project %s does not exist" % args.resume_from) - startWith = projects[args.resume_from] - startIndex = findInList(projects.values(), startWith) - workProjects = projects.values()[startIndex:] - -# and do it! -for project in workProjects: - try: - 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 - if isinstance(e, KeyboardInterrupt): # str(e) would be the empty string - print >> sys.stderr, "Interruped by user while processing %s" % (project.name) - else: - print >> sys.stderr, "Error while processing %s: %s" % (project.name, str(e)) - print >> sys.stderr - sys.exit(1)