mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-22 22:20:39 +01:00
build.py: Better evaluation of external make output
Output of running external make was a) parsed incorrectly (PREREQ_BUILD and PREREQ sometimes contain different values) b) not flushed correctly after printing, so build.py output and make output would interleave badly Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
93827e187b
commit
dbd7836099
1 changed files with 24 additions and 8 deletions
|
|
@ -14,6 +14,7 @@ import pwd
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
import re
|
||||||
|
|
||||||
all_deps = Set()
|
all_deps = Set()
|
||||||
dep_tree = {}
|
dep_tree = {}
|
||||||
|
|
@ -44,15 +45,22 @@ def read_deps(cur, prereq_type):
|
||||||
dep_cache[prereq_type] = {}
|
dep_cache[prereq_type] = {}
|
||||||
path = find_proj_path(cur)
|
path = find_proj_path(cur)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
# ignoring prereq_type, as it has never been anything but BUILD, now
|
# ignoring prereq_type, as it has never been anything but BUILD, now
|
||||||
# only looking for PREREQ without anything
|
# 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 | 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()
|
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)
|
raise Exception("failed to get " + prereq_type + " prerequisites from " + path)
|
||||||
r = Set()
|
r = Set()
|
||||||
for d in p.stdout.read().split():
|
pattern = re.compile(r'^ *PREREQ.*=')
|
||||||
r.add(d)
|
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:
|
if cur in r:
|
||||||
r.remove(cur)
|
r.remove(cur)
|
||||||
debug('inserting', prereq_type, "prerequisites of", cur, ":", ' '.join(r))
|
debug('inserting', prereq_type, "prerequisites of", cur, ":", ' '.join(r))
|
||||||
|
|
@ -87,10 +95,18 @@ def calculate_order(order, modules, prereq_type):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def run_make(module, target):
|
def run_make(module, target):
|
||||||
|
make_cmd = "make " + target + " 2>&1"
|
||||||
path = find_proj_path(module)
|
path = find_proj_path(module)
|
||||||
print("========= running make " + target + " in " + path)
|
print(',---------- running ' + make_cmd + ' in ' + path + ' -------------------------- >')
|
||||||
os.chdir(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)
|
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):
|
def build(modules, order, target):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue