projects.py: Support make/project.conf, fix --prefix

- Allow make/project.conf as alternative project config file
  - Fix --prefix option

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2016-01-27 14:27:38 +00:00
commit 7965d9cd91

View file

@ -40,9 +40,13 @@ def get_value(name, section, key):
file.close() file.close()
return r return r
path = proj_root + '/doc/share/project.txt' for conf in [ '/doc/share/project.txt', '/make/project.conf' ]:
path = proj_root + conf
r = () r = ()
try:
file = open(path) file = open(path)
except:
continue
if not len(section): if not len(section):
for line in file: for line in file:
r = re.findall('^ *' + key + ' *= *(.*)', line) r = re.findall('^ *' + key + ' *= *(.*)', line)
@ -147,14 +151,21 @@ def cmd_pkg_requires(args_):
r.append(' '.join(dep)) r.append(' '.join(dep))
print ', '.join(r) print ', '.join(r)
# -------------------------------------------------------------------- here we go
global_args = [] global_args = []
skip = 0
for a in sys.argv[1::]: for a in sys.argv[1::]:
global_args.append(a) global_args.append(a)
if a in [ '--prefix', '-p' ]:
skip = 1
continue
if skip > 0:
skip = skip -1
continue
if a[0] != '-': if a[0] != '-':
break break
# -------------------------------------------------------------------- here we go
parser = argparse.ArgumentParser(description='Project metadata evaluation') parser = argparse.ArgumentParser(description='Project metadata evaluation')
parser.add_argument('cmd', default='', help='Command') 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')