mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
projects.py: Add commands cflags and ldflags
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
7965d9cd91
commit
3668da6ee5
1 changed files with 59 additions and 18 deletions
|
|
@ -13,6 +13,9 @@ def re_section(name):
|
|||
re.DOTALL)
|
||||
|
||||
# --------------------------------------------------------------------- helpers
|
||||
def proj_dir(name):
|
||||
return projs_root + '/' + name
|
||||
|
||||
def strip_module_from_spec(mod):
|
||||
return re.sub(r'-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip())
|
||||
|
||||
|
|
@ -33,7 +36,7 @@ def get_section(path, section):
|
|||
return r.rstrip()
|
||||
|
||||
def get_value(name, section, key):
|
||||
proj_root = projs_root + '/' + name
|
||||
proj_root = proj_dir(name)
|
||||
if section == 'version':
|
||||
with open(proj_root + '/VERSION', 'r') as file:
|
||||
r=file.read().replace('\n', '').replace('-dev', '')
|
||||
|
|
@ -69,31 +72,38 @@ def get_value(name, section, key):
|
|||
if len(r):
|
||||
return r[0]
|
||||
return None
|
||||
|
||||
def add_modules_from_project_txt(buf, spec, section, key, add_self, recursive,
|
||||
|
||||
# scope 0: no children
|
||||
# scope 1: children
|
||||
# scope 2: recursive
|
||||
|
||||
def add_modules_from_project_txt(buf, spec, section, key, add_self, scope,
|
||||
names_only):
|
||||
name = strip_module_from_spec(spec)
|
||||
if names_only:
|
||||
spec = name
|
||||
if spec in buf:
|
||||
return
|
||||
if recursive:
|
||||
deps = get_value(name, section, key)
|
||||
if deps:
|
||||
deps = deps.split(',')
|
||||
for dep in deps:
|
||||
add_modules_from_project_txt(buf, dep,
|
||||
section, key, add_self=True, recursive=True,
|
||||
names_only=names_only)
|
||||
deps = get_value(name, section, key)
|
||||
if deps and scope > 0:
|
||||
if scope == 1:
|
||||
subscope = 0
|
||||
else:
|
||||
subscope = 2
|
||||
deps = deps.split(',')
|
||||
for dep in deps:
|
||||
add_modules_from_project_txt(buf, dep,
|
||||
section, key, add_self=True, scope=subscope,
|
||||
names_only=names_only)
|
||||
if add_self:
|
||||
buf.append(name)
|
||||
buf.append(spec)
|
||||
|
||||
def get_modules_from_project_txt(names, section, key, add_self, recursive,
|
||||
def get_modules_from_project_txt(names, section, key, add_self, scope,
|
||||
names_only = True):
|
||||
#r = Set()
|
||||
r = []
|
||||
for name in names:
|
||||
add_modules_from_project_txt(r, name, section, key, add_self, recursive,
|
||||
add_modules_from_project_txt(r, name, section, key, add_self, scope,
|
||||
names_only)
|
||||
return r
|
||||
|
||||
|
|
@ -110,10 +120,32 @@ def cmd_ldlibpath(args_):
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'run',
|
||||
recursive=True, add_self=True, names_only=True)
|
||||
scope = 2, add_self=True, names_only=True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
r = r + ':' + projs_root + '/' + m + '/lib'
|
||||
r = r + ':' + proj_dir(m) + '/lib'
|
||||
print r[1:]
|
||||
|
||||
def cmd_ldflags(args_):
|
||||
parser = argparse.ArgumentParser(description='ldlibpath')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'build',
|
||||
scope = 1, add_self=True, names_only=True)
|
||||
r = ''
|
||||
for m in reversed(deps):
|
||||
r = r + ' -L' + proj_dir(m) + '/lib -l' + m
|
||||
print r[1:]
|
||||
|
||||
def cmd_cflags(args_):
|
||||
parser = argparse.ArgumentParser(description='ldlibpath')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'build',
|
||||
scope = 1, add_self=True, names_only=True)
|
||||
r = ''
|
||||
for m in reversed(deps):
|
||||
r = r + ' -I' + proj_dir(m) + '/include'
|
||||
print r[1:]
|
||||
|
||||
def cmd_path(args_):
|
||||
|
|
@ -121,10 +153,10 @@ def cmd_path(args_):
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'run',
|
||||
recursive=True, add_self=True, names_only=True)
|
||||
scope = 2, add_self=True, names_only=True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
r = r + ':' + projs_root + '/' + m + '/bin'
|
||||
r = r + ':' + proj_dir(m) + '/bin'
|
||||
print r[1:]
|
||||
|
||||
def cmd_pkg_requires(args_):
|
||||
|
|
@ -151,6 +183,15 @@ def cmd_pkg_requires(args_):
|
|||
r.append(' '.join(dep))
|
||||
print ', '.join(r)
|
||||
|
||||
def cmd_proj_dir(args_):
|
||||
parser = argparse.ArgumentParser(description='proj-dir')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
r = []
|
||||
for m in args.module:
|
||||
r.append(proj_dir(m))
|
||||
print ' '.join(r)
|
||||
|
||||
# -------------------------------------------------------------------- here we go
|
||||
|
||||
global_args = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue