From f67616f4a1b6d6f06c47f288538d8fb1d72c1801 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Mon, 26 Nov 2012 20:47:28 +0000 Subject: Cleanup and extend build commands --- (limited to 'devbot') diff --git a/devbot/build.py b/devbot/build.py index 6705274..09580a2 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -17,7 +17,7 @@ def unlink_libtool_files(): os.path.walk(config.lib_dir, func, None) -def pull_source(module): +def pull_git_module(module): module_dir = module.get_source_dir() if os.path.exists(module_dir): @@ -27,27 +27,37 @@ def pull_source(module): command.run(["git", "remote", "update", "origin"], retry=10) else: os.chdir(config.get_source_dir()) - command.run(["git", "clone", "--progress", - module.repo, module.name], + command.run(["git", "clone", "--progress", module.repo, module.name], retry=10) os.chdir(module_dir) command.run(["git", "checkout", module.branch]) +def pull_module(module): + print "\n=== Pulling %s ===\n" % module.name + + try: + pull_git_module(module) + except subprocess.CalledProcessError: + sys.exit(1) + def build_make(module): command.run(["make"]) def build_autotools(module): - autogen = os.path.join(module.get_source_dir(), "autogen.sh") + makefile_path = os.path.join(module.get_build_dir(), "Makefile") - jobs = multiprocessing.cpu_count() * 2 + if not os.path.exists(makefile_path): + autogen = os.path.join(module.get_source_dir(), "autogen.sh") + + args = [autogen, + "--prefix", config.prefix_dir, + "--libdir", config.lib_dir] + args.extend(module.options) - args = [autogen, - "--prefix", config.prefix_dir, - "--libdir", config.lib_dir] - args.extend(module.options) + command.run(args) - command.run(args) + jobs = multiprocessing.cpu_count() * 2 command.run(["make", "-j", "%d" % jobs]) command.run(["make", "install"]) @@ -58,6 +68,8 @@ def build_activity(module): command.run(["./setup.py", "install", "--prefix", config.prefix_dir]) def build_module(module): + print "\n=== Building %s ===\n" % module.name + module_source_dir = module.get_source_dir() if module.out_of_source: @@ -70,14 +82,16 @@ def build_module(module): else: os.chdir(module_source_dir) - if os.path.exists(os.path.join(module_source_dir, "setup.py")): - build_activity(module) - elif os.path.exists(os.path.join(module_source_dir, "autogen.sh")): - build_autotools(module) - elif os.path.exists(os.path.join(module_source_dir, "Makefile")): - build_make(module) - else: - print "Unknown build system" + try: + if os.path.exists(os.path.join(module_source_dir, "setup.py")): + build_activity(module) + elif os.path.exists(os.path.join(module_source_dir, "autogen.sh")): + build_autotools(module) + elif os.path.exists(os.path.join(module_source_dir, "Makefile")): + build_make(module) + else: + raise RuntimeError("Unknown build system") + except subprocess.CalledProcessError: sys.exit(1) state.touch_built_commit_id(module) @@ -92,27 +106,40 @@ def rmtree(dir): print "Deleting %s" % dir shutil.rmtree(dir, ignore_errors=True) -def build(): +def build_one(module_name): environ.setup() - modules = config.load_modules() + for module in config.load_modules(): + if module.name == module_name: + build_module(module) - for i, module in enumerate(modules): - print "\n=== Building %s ===\n" % module.name +def pull_one(module_name): + environ.setup() + + for module in config.load_modules(): + if module.name == module_name: + pull_module(module) - try: - pull_source(module) +def pull(): + environ.setup() - old_commit_id = state.get_built_commit_id(module) - new_commit_id = module.get_commit_id() + for module in config.load_modules(): + pull_module(module) - if old_commit_id is None or old_commit_id != new_commit_id: - clear_built_modules(modules, i) - build_module(module) - else: - print "\n* Already built, skipping *" - except subprocess.CalledProcessError: - sys.exit(1) +def build(): + environ.setup() + + modules = config.load_modules() + + for i, module in enumerate(modules): + old_commit_id = state.get_built_commit_id(module) + new_commit_id = module.get_commit_id() + + if old_commit_id is None or old_commit_id != new_commit_id: + clear_built_modules(modules, i) + build_module(module) + else: + print "\n* Already built, skipping *" def clean(): rmtree(config.install_dir) -- cgit v0.9.1