diff --git a/scripts/build.py b/scripts/build.py index c02aea13..35a4405b 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -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") - diff --git a/scripts/projects.py b/scripts/projects.py new file mode 100644 index 00000000..73e1d1cf --- /dev/null +++ b/scripts/projects.py @@ -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)::]) +