projects.py: Add support for --skip-excluded to command requires-pkg

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2018-03-07 17:28:20 +00:00
commit 9d2e192256

View file

@ -153,16 +153,11 @@ class Build(object):
print(',' + delim + ' >') print(',' + delim + ' >')
# -- check exclude patt = is_excluded_from_build(module)
exclude = get_modules_from_project_txt([ module ], 'build', 'exclude', if patt is not None:
scope = 1, add_self=False, names_only=True) print('| Configured to skip build on platform >' + patt + '<')
cascade = os_cascade() + [ 'all' ] print('`' + delim + ' <')
for p1 in exclude: return
for p2 in cascade:
if p1 == p2:
print('| Configured to skip build on platform >' + p1 + '<')
print('`' + delim + ' <')
return
os.chdir(path) os.chdir(path)
p = subprocess.Popen(make_cmd, shell=False, stdout=subprocess.PIPE, stderr=None, close_fds=True) p = subprocess.Popen(make_cmd, shell=False, stdout=subprocess.PIPE, stderr=None, close_fds=True)
@ -480,7 +475,7 @@ def pkg_relations(rel_type, args_):
default=False, help='Always treat VERSION macro as VERSION-REVISION') default=False, help='Always treat VERSION macro as VERSION-REVISION')
parser.add_argument('--dont-expand-version-macros', action='store_true', parser.add_argument('--dont-expand-version-macros', action='store_true',
default=False, help='Don\'t expand VERSION and REVISION macros') default=False, help='Don\'t expand VERSION and REVISION macros')
args=parser.parse_args(args_) args = parser.parse_args(args_)
version_pattern=re.compile("[0-9-.]*") version_pattern=re.compile("[0-9-.]*")
if args.subsections is None: if args.subsections is None:
subsecs = os_cascade() subsecs = os_cascade()
@ -533,6 +528,17 @@ def get_libname(names):
vals.remove('none') vals.remove('none')
return ' '.join(reversed(vals)) return ' '.join(reversed(vals))
def is_excluded_from_build(module):
debug("checking if module " + module + " is excluded from build")
exclude = get_modules_from_project_txt([ module ], 'build', 'exclude',
scope = 1, add_self=False, names_only=True)
cascade = os_cascade() + [ 'all' ]
for p1 in exclude:
for p2 in cascade:
if p1 == p2:
return p1
return None
# -L needs to contain more paths than libs linked with -l would require # -L needs to contain more paths than libs linked with -l would require
def get_ldpathflags(names, exclude = []): def get_ldpathflags(names, exclude = []):
deps = get_modules_from_project_txt(names, 'pkg.requires.jw', 'build', deps = get_modules_from_project_txt(names, 'pkg.requires.jw', 'build',
@ -598,11 +604,18 @@ def cmd_requires_pkg(args_):
parser = argparse.ArgumentParser(description='requires-pkg') parser = argparse.ArgumentParser(description='requires-pkg')
parser.add_argument('module', nargs='*', help='Modules') parser.add_argument('module', nargs='*', help='Modules')
parser.add_argument('--flavours', help='Dependency flavours', default='build') parser.add_argument('--flavours', help='Dependency flavours', default='build')
args=parser.parse_args(args_) parser.add_argument('--skip-excluded', action='store_true', default=False,
help='Output empty prerequisite list if module is excluded')
args = parser.parse_args(args_)
modules = args.module
flavours = args.flavours.split() flavours = args.flavours.split()
debug("flavours = " + args.flavours) debug("flavours = " + args.flavours)
deps = get_modules_from_project_txt(args.module, 'pkg.requires.jw', flavours, deps = get_modules_from_project_txt(modules, 'pkg.requires.jw', flavours,
scope = 2, add_self=True, names_only=True) scope = 2, add_self=True, names_only=True)
if args.skip_excluded:
for d in deps:
if is_excluded_from_build(d) is not None:
deps.remove(d)
subsecs = os_cascade() subsecs = os_cascade()
debug("subsecs = ", subsecs) debug("subsecs = ", subsecs)
requires = [] requires = []
@ -700,7 +713,7 @@ def cmd_prereq(args_):
parser = argparse.ArgumentParser(description='path') parser = argparse.ArgumentParser(description='path')
parser.add_argument('flavour', help='Flavour') parser.add_argument('flavour', help='Flavour')
parser.add_argument('module', nargs='*', help='Modules') parser.add_argument('module', nargs='*', help='Modules')
args=parser.parse_args(args_) args = parser.parse_args(args_)
deps = get_modules_from_project_txt(args.module, 'pkg.requires.jw', deps = get_modules_from_project_txt(args.module, 'pkg.requires.jw',
args.flavour, scope = 2, add_self=False, names_only=True) args.flavour, scope = 2, add_self=False, names_only=True)
print(' '.join(deps)) print(' '.join(deps))