summaryrefslogtreecommitdiff
path: root/xnt/xenant.py
diff options
context:
space:
mode:
authorkennyballou <kballou@onyx.boisestate.edu>2013-01-18 18:00:37 -0700
committerkennyballou <kballou@onyx.boisestate.edu>2013-01-18 18:00:37 -0700
commita4227e297f6a531cd632dc3123ce2096b6f11ced (patch)
tree1ae57b7fa1ab34147ff1eb5301f2c656d938bcbb /xnt/xenant.py
parent9c9f8dd86839468142538d75d8ab5b72e46bad60 (diff)
downloadxnt-a4227e297f6a531cd632dc3123ce2096b6f11ced.tar.gz
xnt-a4227e297f6a531cd632dc3123ce2096b6f11ced.tar.xz
Add initial hack for `-D` parameter passing
This allows for invocations of Xnt to accept arguments of the form `-D{name}={value}` to be inserted into the build.py's `properties` dictionary. Currently, it's only over writing the dictionary; I intend to clean this up and have it only over write the specified key(s)
Diffstat (limited to 'xnt/xenant.py')
-rw-r--r--xnt/xenant.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/xnt/xenant.py b/xnt/xenant.py
index 8df1277..ab93afc 100644
--- a/xnt/xenant.py
+++ b/xnt/xenant.py
@@ -44,14 +44,19 @@ actions = {
def main():
start_time = time.time()
- opts = list(o for o in sys.argv[1:] if o.startswith('-'))
- arg = list(a for a in sys.argv[1:] if a not in opts)
+ params = list(p for p in sys.argv[1:] if p.startswith('-D'))
+ opts = list(o for o in sys.argv[1:]
+ if o.startswith('-') and not o.startswith('-D'))
+ arg = list(a for a in sys.argv[1:] if a not in opts and a not in params)
for opt in opts:
if opt in actions:
actions[opt]()
else:
logger.debug("%s is not a valid option", opt)
- ec = invokeBuild(__loadBuild(), arg[0] if len(arg) == 1 else "default")
+ ec = invokeBuild(
+ __loadBuild(),
+ arg[0] if len(arg) == 1 else "default",
+ __processParams(params))
from xnt.tasks import rm
rm("build.pyc",
"__pycache__")
@@ -59,10 +64,12 @@ def main():
logger.info("Execution time: %.3f", elapsed_time)
print("Success" if ec == 0 else "Failure")
-def invokeBuild(build, targetName):
+def invokeBuild(build, targetName, props={}):
if targetName == "list-targets":
return printTargets(build)
try:
+ if len(props) > 0:
+ setattr(build, "properties", props)
target = getattr(build, targetName)
ec = target()
return ec if ec else 0
@@ -134,5 +141,12 @@ def __loadBuild(path=""):
del sys.modules["build"]
os.chdir(cwd)
+def __processParams(params):
+ properties = {}
+ for p in params:
+ name, value = p[2:].split("=")
+ properties[name] = value
+ return properties
+
if __name__ == "__main__":
main()