def build_tree(tree, conn, verbose): """Build the tree, pre_process, build and post_process.""" # Load indexers indexers = load_indexers(tree) # Get system environment variables environ = {} for key, val in os.environ.items(): environ[key] = val # Let plugins preprocess # modify environ, change makefile, hack things whatever! for indexer in indexers: indexer.pre_process(tree, environ) # Add source and build directories to the command environ["source_folder"] = tree.source_folder environ["build_folder"] = tree.object_folder # Open log file with open_log(tree, 'build.log', verbose) as log: # Call the make command print "Building the '%s' tree" % tree.name r = subprocess.call( tree.build_command.replace('$jobs', tree.config.nb_jobs), shell = True, stdout = log, stderr = log, env = environ, cwd = tree.object_folder ) # Abort if build failed! if r != 0: print >> sys.stderr, ("Build command for '%s' failed, exited non-zero." % tree.name) if not verbose: print >> sys.stderr, 'Log follows:' with open(log.name) as log_file: print >> sys.stderr, ' | %s ' % ' | '.join(log_file) sys.exit(1) # Let plugins post process for indexer in indexers: indexer.post_process(tree, conn)