diff --git a/scripts/build.py b/scripts/build.py index fd4ec283..ba3234b5 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -14,6 +14,7 @@ import pwd import argparse import time import datetime +import re all_deps = Set() dep_tree = {} @@ -44,15 +45,22 @@ def read_deps(cur, prereq_type): dep_cache[prereq_type] = {} path = find_proj_path(cur) os.chdir(path) - # ignoring prereq_type, as it has never been anything but BUILD, now - # only looking for PREREQ without anything - p = subprocess.Popen("LD_LIBRARY_PATH= make echo-prereq | sed '/PREREQ " + " *=/ !d; s/.*=//'", shell=True, stdout=subprocess.PIPE) + # ignoring prereq_type, as it has never been anything but BUILD, now + # only looking for PREREQ without anything + # p = subprocess.Popen("LD_LIBRARY_PATH= make echo-prereq | sed '/PREREQ " + " *=/ !d; s/.*=//'", shell=True, stdout=subprocess.PIPE) + p = subprocess.Popen("LD_LIBRARY_PATH= make echo-prereq", shell=True, stdout=subprocess.PIPE) p.wait() - if p.returncode: # FIXME: doesn't work, because sed kills make's return code + if p.returncode: raise Exception("failed to get " + prereq_type + " prerequisites from " + path) r = Set() - for d in p.stdout.read().split(): - r.add(d) + pattern = re.compile(r'^ *PREREQ.*=') + for line in iter(p.stdout.readline,''): + if not pattern.match(line): + continue + for d in re.sub(pattern, '', line) .split(): + r.add(d) +# for d in p.stdout.read().split(): +# r.add(d) if cur in r: r.remove(cur) debug('inserting', prereq_type, "prerequisites of", cur, ":", ' '.join(r)) @@ -87,10 +95,18 @@ def calculate_order(order, modules, prereq_type): return 1 def run_make(module, target): + make_cmd = "make " + target + " 2>&1" path = find_proj_path(module) - print("========= running make " + target + " in " + path) + print(',---------- running ' + make_cmd + ' in ' + path + ' -------------------------- >') os.chdir(path) - if subprocess.call(["make", target]): + p = subprocess.Popen(make_cmd, shell=True, stdout=subprocess.PIPE) + p.wait() + for line in iter(p.stdout.readline,''): + sys.stdout.write('| ' + line) # avoid extra newlines from print() + sys.stdout.flush() + print('`---------- running ' + make_cmd + ' in ' + path + ' -------------------------- <') + if p.returncode: + print(make_cmd + ' failed') raise Exception(time.strftime("%Y-%m-%d %H:%M") + ": failed to make target " + target + " in module " + module + " below base " + proj_base) def build(modules, order, target):