build.py: Add basic support for --debug argument

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2016-09-16 11:32:27 +00:00
commit 93827e187b
2 changed files with 24 additions and 13 deletions

View file

@ -45,7 +45,8 @@ ifeq ($(CVS_RSH),)
export CVS_RSH
endif
PGIT = CLONE_PROJECTS="$(PROJECTS)" PGIT_CLONE_FROM_USER="$(JANWARE_USER)" /bin/bash $(firstword $(wildcard ./ytools/devutil/scripts/pgit.sh /opt/ytools/bin/pgit.sh))
PGIT = CLONE_PROJECTS="$(PROJECTS)" PGIT_CLONE_FROM_USER="$(JANWARE_USER)" /bin/bash $(firstword $(wildcard ./ytools/devutil/scripts/pgit.sh /opt/ytools/bin/pgit.sh))
BUILD_PY = python ./ytools/devutil/scripts/build.py -b $(shell pwd) $(BUILD_PY_EXTRA_OPTS)
EXCLUDE_FROM_BUILD = \
dspider-btools \
@ -59,15 +60,15 @@ EXCLUDE_FROM_BUILD = \
all: links.done clone.done cvs-update.done
all clean: config.done
python ./ytools/devutil/scripts/build.py -b $(shell pwd) $@ $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS))
$(BUILD_PY) $@ $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS))
pkg-%:
python ./ytools/devutil/scripts/build.py -b $(shell pwd) $@ $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS))
$(BUILD_PY) $@ $(filter-out $(EXCLUDE_FROM_BUILD),$(PROJECTS))
clean: done.clean
clean-dirs:
ls */dirs-all.done 2>/dev/null | sed 's%/.*%%' | xargs -r build.py -b $(shell pwd) clean
ls */dirs-all.done 2>/dev/null | sed 's%/.*%%' | xargs -r $(BUILD_PY) clean
cpp:
@find $(PROJECTS) -name '*.cpp' | grep /worker/ | grep -ve "old\|tmp\|nomake\|new" | \

View file

@ -1,6 +1,7 @@
#!/usr/bin/python -u
# -*- coding: iso-8859-15 -*-
from __future__ import print_function
import os
import sys
import dircache
@ -22,6 +23,10 @@ search_path=[".", "dspc/src", "dspc/src/dspcd-plugins", "dspc/src/io" ]
glob_prereq_type="BUILD"
dep_cache = {}
def debug(*objs):
if args.debug:
print("DEBUG: ", *objs, file=sys.stderr)
def find_proj_path(name):
name=name.replace("dspider-", "")
for sub in search_path:
@ -50,7 +55,7 @@ def read_deps(cur, prereq_type):
r.add(d)
if cur in r:
r.remove(cur)
#print 'inserting', prereq_type, cur, r
debug('inserting', prereq_type, "prerequisites of", cur, ":", ' '.join(r))
dep_cache[prereq_type][cur] = r
return r
@ -72,7 +77,7 @@ def calculate_order(order, modules, prereq_type):
if not len(dep_tree[d]):
break
else:
print all_deps
print(all_deps)
raise Exception("fatal: the dependencies between these modules are unresolvable")
order.append(d)
all_deps.remove(d)
@ -83,7 +88,7 @@ def calculate_order(order, modules, prereq_type):
def run_make(module, target):
path = find_proj_path(module)
print "========= running make " + target + " in " + path
print("========= running make " + target + " in " + path)
os.chdir(path)
if subprocess.call(["make", target]):
raise Exception(time.strftime("%Y-%m-%d %H:%M") + ": failed to make target " + target + " in module " + module + " below base " + proj_base)
@ -95,7 +100,7 @@ def build(modules, order, target):
if m in modules:
modules.remove(m)
if not len(modules):
print "all modules cleaned"
print("all modules cleaned")
return
else:
for m in order:
@ -107,10 +112,15 @@ modules = Set()
parser = argparse.ArgumentParser(description='jannet software project build tool')
parser.add_argument('--base', '-b', nargs='?', default=proj_base, help='Project base directory')
parser.add_argument('--exclude', nargs='?', default='', help='List of modules to be excluded from build')
parser.add_argument('--debug', '-d', action='store_true',
default=False, help='Output debug information to stderr')
parser.add_argument('target', default='all', help='Build target')
parser.add_argument('modules', nargs='+', default='', help='Modules to be built')
args=parser.parse_args()
debug("----------------------------------------- running ", ' '.join(sys.argv))
proj_base=args.base
exclude=args.exclude
target=args.target
@ -118,21 +128,21 @@ modules=args.modules
env_exclude=os.getenv('BUILD_EXCLUDE', '')
if len(env_exclude):
print "exluding modules from environment: " + env_exclude
print("exluding modules from environment: " + env_exclude)
exclude += " " + env_exclude
# -- build
if target != 'order':
print "calculating order for modules: " + ' '.join(modules)
print("calculating order for modules: " + ' '.join(modules))
order = []
calculate_order(order, modules, glob_prereq_type)
order = [m for m in order if m not in exclude]
if target == 'order':
print ' '.join(order)
print(' '.join(order))
exit(0)
print "order is: " + ' '.join(order)
print("order is: " + ' '.join(order))
build(modules, order, target)
print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))