mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-17 04:40:48 +01:00
projects.py: Make cmd_path and cmd_libpath return sensible values
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
90a80b5355
commit
754a4c59e6
1 changed files with 29 additions and 7 deletions
|
|
@ -15,6 +15,7 @@ def re_section(name):
|
|||
re.DOTALL)
|
||||
|
||||
# --------------------------------------------------------------------- helpers
|
||||
|
||||
def get_section(path, section):
|
||||
r = ''
|
||||
file = open(path)
|
||||
|
|
@ -57,13 +58,22 @@ def get_value(path, section, key):
|
|||
return r[0]
|
||||
return ""
|
||||
|
||||
def add_module_from_projects_txt(buf, name, section, key):
|
||||
def add_modules_from_project_txt(buf, name, section, key, add_self, recursive):
|
||||
if name in buf:
|
||||
return
|
||||
buf.add(name)
|
||||
if add_self:
|
||||
buf.add(name)
|
||||
deps = get_value(proj_root + '/' + name + '/doc/share/project.txt', section, key).split()
|
||||
for dep in deps:
|
||||
add_module_from_projects_txt(buf, dep, section, key)
|
||||
buf.add(dep)
|
||||
if recursive:
|
||||
add_modules_from_project_txt(buf, dep, section, key, True, recursive)
|
||||
|
||||
def get_modules_from_project_txt(names, section, key, add_self, recursive):
|
||||
r = Set()
|
||||
for name in names:
|
||||
add_modules_from_project_txt(r, name, section, key, add_self, recursive)
|
||||
return r
|
||||
|
||||
# --------------------------------------------------------------------- commands
|
||||
|
||||
|
|
@ -77,11 +87,23 @@ def cmd_ldlibpath(args_):
|
|||
parser = argparse.ArgumentParser(description='ldlibpath')
|
||||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
args=parser.parse_args(args_)
|
||||
deps = Set()
|
||||
for m in args.module:
|
||||
add_module_from_projects_txt(deps, m, 'dependencies', 'ldlibpath')
|
||||
deps = get_modules_from_project_txt(args.module, 'requires', 'run', True,
|
||||
True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
print m
|
||||
r = r + ':' + proj_root + '/' + m + '/lib'
|
||||
print r[1:]
|
||||
|
||||
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)
|
||||
r = ''
|
||||
for m in deps:
|
||||
r = r + ':' + proj_root + '/' + m + '/bin'
|
||||
print r[1:]
|
||||
|
||||
global_args = []
|
||||
for a in sys.argv[1::]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue