mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-22 22:20:39 +01:00
projects.py: Fix ldlibpath, path and prefix
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
962e882730
commit
6e94308f48
1 changed files with 26 additions and 14 deletions
|
|
@ -13,6 +13,8 @@ def re_section(name):
|
||||||
re.DOTALL)
|
re.DOTALL)
|
||||||
|
|
||||||
# --------------------------------------------------------------------- helpers
|
# --------------------------------------------------------------------- helpers
|
||||||
|
def strip_module_from_spec(mod):
|
||||||
|
return re.sub(r'-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip())
|
||||||
|
|
||||||
def get_section(path, section):
|
def get_section(path, section):
|
||||||
r = ''
|
r = ''
|
||||||
|
|
@ -62,23 +64,33 @@ def get_value(name, section, key):
|
||||||
file.close()
|
file.close()
|
||||||
if len(r):
|
if len(r):
|
||||||
return r[0]
|
return r[0]
|
||||||
return ""
|
return None
|
||||||
|
|
||||||
def add_modules_from_project_txt(buf, name, section, key, add_self, recursive):
|
def add_modules_from_project_txt(buf, name, section, key, add_self, recursive,
|
||||||
if name in buf:
|
names_only):
|
||||||
return
|
#if name in buf:
|
||||||
|
# return
|
||||||
if add_self:
|
if add_self:
|
||||||
buf.add(name)
|
buf.add(name)
|
||||||
deps = get_value(name, section, key).split()
|
deps = get_value(name, section, key)
|
||||||
|
if not deps:
|
||||||
|
return
|
||||||
|
deps = deps.split(',')
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
buf.add(dep)
|
if names_only:
|
||||||
|
buf.add(strip_module_from_spec(dep))
|
||||||
|
else:
|
||||||
|
buf.add(dep)
|
||||||
if recursive:
|
if recursive:
|
||||||
add_modules_from_project_txt(buf, dep, section, key, True, recursive)
|
add_modules_from_project_txt(buf, strip_module_from_spec(dep),
|
||||||
|
section, key, True, recursive, names_only)
|
||||||
|
|
||||||
def get_modules_from_project_txt(names, section, key, add_self, recursive):
|
def get_modules_from_project_txt(names, section, key, add_self, recursive,
|
||||||
|
names_only = True):
|
||||||
r = Set()
|
r = Set()
|
||||||
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, recursive,
|
||||||
|
names_only)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
# --------------------------------------------------------------------- commands
|
# --------------------------------------------------------------------- commands
|
||||||
|
|
@ -93,8 +105,8 @@ def cmd_ldlibpath(args_):
|
||||||
parser = argparse.ArgumentParser(description='ldlibpath')
|
parser = argparse.ArgumentParser(description='ldlibpath')
|
||||||
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, 'requires', 'run', True,
|
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'run',
|
||||||
True)
|
recursive=True, add_self=True, names_only=True)
|
||||||
r = ''
|
r = ''
|
||||||
for m in deps:
|
for m in deps:
|
||||||
r = r + ':' + projs_root + '/' + m + '/lib'
|
r = r + ':' + projs_root + '/' + m + '/lib'
|
||||||
|
|
@ -104,8 +116,8 @@ def cmd_path(args_):
|
||||||
parser = argparse.ArgumentParser(description='path')
|
parser = argparse.ArgumentParser(description='path')
|
||||||
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, 'requires', 'run', True,
|
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'run',
|
||||||
True)
|
recursive=True, add_self=True, names_only=True)
|
||||||
r = ''
|
r = ''
|
||||||
for m in deps:
|
for m in deps:
|
||||||
r = r + ':' + projs_root + '/' + m + '/bin'
|
r = r + ':' + projs_root + '/' + m + '/bin'
|
||||||
|
|
@ -148,7 +160,7 @@ parser.add_argument('cmd', default='', help='Command')
|
||||||
parser.add_argument('--prefix', '-p', nargs='?', default = expanduser("~") + '/local/src/cvs.stable/proj', help='Project Path Prefix')
|
parser.add_argument('--prefix', '-p', nargs='?', default = expanduser("~") + '/local/src/cvs.stable/proj', help='Project Path Prefix')
|
||||||
parser.add_argument('arg', nargs='*', help='Command arguments')
|
parser.add_argument('arg', nargs='*', help='Command arguments')
|
||||||
args=parser.parse_args(global_args)
|
args=parser.parse_args(global_args)
|
||||||
projs_root = args.p
|
projs_root = args.prefix
|
||||||
cmd = getattr(sys.modules[__name__], 'cmd_' + args.cmd.replace('-', '_'))
|
cmd = getattr(sys.modules[__name__], 'cmd_' + args.cmd.replace('-', '_'))
|
||||||
cmd(sys.argv[(len(global_args) + 1)::])
|
cmd(sys.argv[(len(global_args) + 1)::])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue