mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-24 06:40:39 +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)
|
re.DOTALL)
|
||||||
|
|
||||||
# --------------------------------------------------------------------- helpers
|
# --------------------------------------------------------------------- helpers
|
||||||
|
def proj_dir(name):
|
||||||
|
return projs_root + '/' + name
|
||||||
|
|
||||||
def strip_module_from_spec(mod):
|
def strip_module_from_spec(mod):
|
||||||
return re.sub(r'-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip())
|
return re.sub(r'-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip())
|
||||||
|
|
||||||
|
|
@ -33,7 +36,7 @@ def get_section(path, section):
|
||||||
return r.rstrip()
|
return r.rstrip()
|
||||||
|
|
||||||
def get_value(name, section, key):
|
def get_value(name, section, key):
|
||||||
proj_root = projs_root + '/' + name
|
proj_root = proj_dir(name)
|
||||||
if section == 'version':
|
if section == 'version':
|
||||||
with open(proj_root + '/VERSION', 'r') as file:
|
with open(proj_root + '/VERSION', 'r') as file:
|
||||||
r=file.read().replace('\n', '').replace('-dev', '')
|
r=file.read().replace('\n', '').replace('-dev', '')
|
||||||
|
|
@ -69,31 +72,38 @@ def get_value(name, section, key):
|
||||||
if len(r):
|
if len(r):
|
||||||
return r[0]
|
return r[0]
|
||||||
return None
|
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):
|
names_only):
|
||||||
name = strip_module_from_spec(spec)
|
name = strip_module_from_spec(spec)
|
||||||
if names_only:
|
if names_only:
|
||||||
spec = name
|
spec = name
|
||||||
if spec in buf:
|
if spec in buf:
|
||||||
return
|
return
|
||||||
if recursive:
|
deps = get_value(name, section, key)
|
||||||
deps = get_value(name, section, key)
|
if deps and scope > 0:
|
||||||
if deps:
|
if scope == 1:
|
||||||
deps = deps.split(',')
|
subscope = 0
|
||||||
for dep in deps:
|
else:
|
||||||
add_modules_from_project_txt(buf, dep,
|
subscope = 2
|
||||||
section, key, add_self=True, recursive=True,
|
deps = deps.split(',')
|
||||||
names_only=names_only)
|
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:
|
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):
|
names_only = True):
|
||||||
#r = Set()
|
#r = Set()
|
||||||
r = []
|
r = []
|
||||||
for name in names:
|
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)
|
names_only)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
@ -110,10 +120,32 @@ def cmd_ldlibpath(args_):
|
||||||
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.required', 'run',
|
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 = ''
|
r = ''
|
||||||
for m in deps:
|
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:]
|
print r[1:]
|
||||||
|
|
||||||
def cmd_path(args_):
|
def cmd_path(args_):
|
||||||
|
|
@ -121,10 +153,10 @@ def cmd_path(args_):
|
||||||
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.required', 'run',
|
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 = ''
|
r = ''
|
||||||
for m in deps:
|
for m in deps:
|
||||||
r = r + ':' + projs_root + '/' + m + '/bin'
|
r = r + ':' + proj_dir(m) + '/bin'
|
||||||
print r[1:]
|
print r[1:]
|
||||||
|
|
||||||
def cmd_pkg_requires(args_):
|
def cmd_pkg_requires(args_):
|
||||||
|
|
@ -151,6 +183,15 @@ def cmd_pkg_requires(args_):
|
||||||
r.append(' '.join(dep))
|
r.append(' '.join(dep))
|
||||||
print ', '.join(r)
|
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
|
# -------------------------------------------------------------------- here we go
|
||||||
|
|
||||||
global_args = []
|
global_args = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue