mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-26 15:23:54 +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)
|
re.DOTALL)
|
||||||
|
|
||||||
# --------------------------------------------------------------------- helpers
|
# --------------------------------------------------------------------- helpers
|
||||||
|
|
||||||
def get_section(path, section):
|
def get_section(path, section):
|
||||||
r = ''
|
r = ''
|
||||||
file = open(path)
|
file = open(path)
|
||||||
|
|
@ -57,13 +58,22 @@ def get_value(path, section, key):
|
||||||
return r[0]
|
return r[0]
|
||||||
return ""
|
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:
|
if name in buf:
|
||||||
return
|
return
|
||||||
|
if add_self:
|
||||||
buf.add(name)
|
buf.add(name)
|
||||||
deps = get_value(proj_root + '/' + name + '/doc/share/project.txt', section, key).split()
|
deps = get_value(proj_root + '/' + name + '/doc/share/project.txt', section, key).split()
|
||||||
for dep in deps:
|
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
|
# --------------------------------------------------------------------- commands
|
||||||
|
|
||||||
|
|
@ -77,11 +87,23 @@ 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 = Set()
|
deps = get_modules_from_project_txt(args.module, 'requires', 'run', True,
|
||||||
for m in args.module:
|
True)
|
||||||
add_module_from_projects_txt(deps, m, 'dependencies', 'ldlibpath')
|
r = ''
|
||||||
for m in deps:
|
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 = []
|
global_args = []
|
||||||
for a in sys.argv[1::]:
|
for a in sys.argv[1::]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue