mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
build.py, projects.py: Add projects.py
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
91f2c4505e
commit
90a80b5355
2 changed files with 100 additions and 2 deletions
|
|
@ -120,5 +120,3 @@ build(modules, order, target)
|
|||
|
||||
print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
|
|
|||
100
scripts/projects.py
Normal file
100
scripts/projects.py
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/python -u
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from sets import Set
|
||||
from os.path import expanduser
|
||||
import re
|
||||
|
||||
proj_root = expanduser("~") + '/local/src/cvs.stable/proj'
|
||||
|
||||
def re_section(name):
|
||||
return re.compile('[' + name + ']'
|
||||
'.*?'
|
||||
'(?=[)',
|
||||
re.DOTALL)
|
||||
|
||||
# --------------------------------------------------------------------- helpers
|
||||
def get_section(path, section):
|
||||
r = ''
|
||||
file = open(path)
|
||||
pat = '[' + section + ']'
|
||||
in_section = False
|
||||
for line in file:
|
||||
if (line.rstrip() == pat):
|
||||
in_section = True
|
||||
continue
|
||||
if in_section:
|
||||
if len(line) and line[0] == '[':
|
||||
break
|
||||
r = r + line
|
||||
file.close()
|
||||
return r.rstrip()
|
||||
|
||||
def get_value(path, section, key):
|
||||
r = ()
|
||||
file = open(path)
|
||||
if not len(section):
|
||||
for line in file:
|
||||
r = re.findall(key + ' *= *(.*)', line)
|
||||
if (len(r) > 0):
|
||||
break
|
||||
else:
|
||||
in_section = False
|
||||
pat = '[' + section + ']'
|
||||
for line in file:
|
||||
if (line.rstrip() == pat):
|
||||
in_section = True
|
||||
continue
|
||||
if in_section:
|
||||
if len(line) and line[0] == '[':
|
||||
break
|
||||
r = re.findall(key + ' *= *(.*)', line)
|
||||
if (len(r) > 0):
|
||||
break
|
||||
file.close()
|
||||
if len(r):
|
||||
return r[0]
|
||||
return ""
|
||||
|
||||
def add_module_from_projects_txt(buf, name, section, key):
|
||||
if name in buf:
|
||||
return
|
||||
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)
|
||||
|
||||
# --------------------------------------------------------------------- commands
|
||||
|
||||
def cmd_test(args_):
|
||||
parser = argparse.ArgumentParser(description='Test')
|
||||
parser.add_argument('blah', default='', help='The blah argument')
|
||||
args=parser.parse_args(args_)
|
||||
print "blah = " + args.blah
|
||||
|
||||
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')
|
||||
for m in deps:
|
||||
print m
|
||||
|
||||
global_args = []
|
||||
for a in sys.argv[1::]:
|
||||
global_args.append(a)
|
||||
if a[0] != '-':
|
||||
break
|
||||
|
||||
# -------------------------------------------------------------------- here we go
|
||||
|
||||
parser = argparse.ArgumentParser(description='Project metadata evaluation')
|
||||
parser.add_argument('cmd', default='', help='Command')
|
||||
parser.add_argument('arg', nargs='*', help='Command arguments')
|
||||
args=parser.parse_args(global_args)
|
||||
cmd = getattr(sys.modules[__name__], 'cmd_' + args.cmd);
|
||||
cmd(sys.argv[(len(global_args) + 1)::])
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue