mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +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)
|
||||
|
||||
# --------------------------------------------------------------------- helpers
|
||||
def strip_module_from_spec(mod):
|
||||
return re.sub(r'-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip())
|
||||
|
||||
def get_section(path, section):
|
||||
r = ''
|
||||
|
|
@ -62,23 +64,33 @@ def get_value(name, section, key):
|
|||
file.close()
|
||||
if len(r):
|
||||
return r[0]
|
||||
return ""
|
||||
return None
|
||||
|
||||
def add_modules_from_project_txt(buf, name, section, key, add_self, recursive):
|
||||
if name in buf:
|
||||
return
|
||||
def add_modules_from_project_txt(buf, name, section, key, add_self, recursive,
|
||||
names_only):
|
||||
#if name in buf:
|
||||
# return
|
||||
if add_self:
|
||||
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:
|
||||
buf.add(dep)
|
||||
if names_only:
|
||||
buf.add(strip_module_from_spec(dep))
|
||||
else:
|
||||
buf.add(dep)
|
||||
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()
|
||||
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
|
||||
|
||||
# --------------------------------------------------------------------- commands
|
||||
|
|
@ -93,8 +105,8 @@ def cmd_ldlibpath(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, 'requires', 'run', True,
|
||||
True)
|
||||
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'run',
|
||||
recursive=True, add_self=True, names_only=True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
r = r + ':' + projs_root + '/' + m + '/lib'
|
||||
|
|
@ -104,8 +116,8 @@ def cmd_path(args_):
|
|||
parser = argparse.ArgumentParser(description='path')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
deps = get_modules_from_project_txt(args.module, 'requires', 'run', True,
|
||||
True)
|
||||
deps = get_modules_from_project_txt(args.module, 'pkg.required', 'run',
|
||||
recursive=True, add_self=True, names_only=True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
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('arg', nargs='*', help='Command arguments')
|
||||
args=parser.parse_args(global_args)
|
||||
projs_root = args.p
|
||||
projs_root = args.prefix
|
||||
cmd = getattr(sys.modules[__name__], 'cmd_' + args.cmd.replace('-', '_'))
|
||||
cmd(sys.argv[(len(global_args) + 1)::])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue