summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkennyballou <kballou@onyx.boisestate.edu>2013-03-10 20:52:26 -0600
committerkennyballou <kballou@onyx.boisestate.edu>2013-03-10 20:52:26 -0600
commit4edf99b3064e9eb29e8d48e6f4954a71a8a98425 (patch)
treecd76cc668852de642233e53ab8c883d56316c7ab
parentdc48af934f5f5db12faddf9fd9419635d1e80368 (diff)
parentbef742210b3f620b6e805a77a5320b79ab78b985 (diff)
downloadxnt-4edf99b3064e9eb29e8d48e6f4954a71a8a98425.tar.gz
xnt-4edf99b3064e9eb29e8d48e6f4954a71a8a98425.tar.xz
Merge branch build spec feature -> parsing rewrite
Conflicts: docs/source/xenant.rst
-rw-r--r--README.rst3
-rw-r--r--docs/source/taskreference.rst5
-rw-r--r--docs/source/xenant.rst3
-rw-r--r--pylint.conf2
-rw-r--r--xnt/tasks.py6
-rw-r--r--xnt/tests/xenantargparsertests.py26
-rw-r--r--xnt/xenant.py27
7 files changed, 59 insertions, 13 deletions
diff --git a/README.rst b/README.rst
index b76b82d..4b55855 100644
--- a/README.rst
+++ b/README.rst
@@ -226,6 +226,9 @@ Where ``[options]`` are one of the following:
* ``-v`` or ``--verbose``: verbose, turn on logging
+* ``-b BUILDFILE`` or ``--build-file BUILDFILE``: Specify build file
+ for Xnt to load
+
And where ``[target]+`` are any target(s) method in your ``build.py``
file or:
diff --git a/docs/source/taskreference.rst b/docs/source/taskreference.rst
index a65f00e..3a36d21 100644
--- a/docs/source/taskreference.rst
+++ b/docs/source/taskreference.rst
@@ -89,15 +89,14 @@ Miscellaneous Tasks
change; I'm not sure how I feel about that yet.]
.. _xnt.tasks.xntcall:
-.. function:: xntcall(path, targets=None, props=None)
+.. function:: xntcall(buildfile, targets=None, props=None)
Invoke the *target(s)* of a build file in a different *path*.
*target* is the name of the target to invoke (similar to *target* of a
regular invocation.
- *path* is the relative or full path to where the "sub" *build.py* file can
- be found.
+ *buildfile* is the path (relative or full) and build file to use
Compile Tasks
=============
diff --git a/docs/source/xenant.rst b/docs/source/xenant.rst
index 156883f..f5907bb 100644
--- a/docs/source/xenant.rst
+++ b/docs/source/xenant.rst
@@ -84,6 +84,9 @@ Where options can be any and all of the following (unless otherwise specified):
* ``-v`` or ``--verbose``: add verbose output to the execution of Xnt
+* ``-b BUILDFILE`` or ``--build-file BUILDFILE``: specifiy to Xnt the build
+ module to load
+
.. _xntPropertiesParameters:
Properties and Parameter Passing
diff --git a/pylint.conf b/pylint.conf
index a56e0a5..aa74eda 100644
--- a/pylint.conf
+++ b/pylint.conf
@@ -249,7 +249,7 @@ max-attributes=7
min-public-methods=1
# Maximum number of public methods for a class (see R0904).
-max-public-methods=55
+max-public-methods=60
[EXCEPTIONS]
diff --git a/xnt/tasks.py b/xnt/tasks.py
index 679701c..02cde24 100644
--- a/xnt/tasks.py
+++ b/xnt/tasks.py
@@ -120,7 +120,7 @@ def log(msg="", lvl=logging.INFO):
"""Log message using tasks global logger"""
LOGGER.log(lvl, msg)
-def xntcall(path, targets=None, props=None):
+def xntcall(buildfile, targets=None, props=None):
"""Invoke xnt on another build file in a different directory
param: path - to the build file (including build file)
@@ -128,9 +128,11 @@ def xntcall(path, targets=None, props=None):
param: props - dictionary of properties to pass to the build module
"""
from xnt.xenant import invoke_build, load_build
+ build = load_build(buildfile)
+ path = os.path.dirname(buildfile)
cwd = os.getcwd()
os.chdir(path)
- error_code = invoke_build(load_build(path), targets=targets, props=props)
+ error_code = invoke_build(build, targets=targets, props=props)
os.chdir(cwd)
return error_code
diff --git a/xnt/tests/xenantargparsertests.py b/xnt/tests/xenantargparsertests.py
index 3a22b33..04c8d1c 100644
--- a/xnt/tests/xenantargparsertests.py
+++ b/xnt/tests/xenantargparsertests.py
@@ -128,5 +128,31 @@ class XenantArgParserTests(unittest.TestCase):
self.assertIsNotNone(args["targets"])
self.assertEqual(len(args["targets"]), 0)
+ def test_build_file_spec_short(self):
+ """Test build file option"""
+ args_in = ["-b", "mybuildfile.py"]
+ args = xnt.xenant.parse_args(args_in)
+ self.assertIsNotNone(args)
+ self.assertFalse(args["verbose"])
+ self.assertFalse(args["list-targets"])
+ self.assertIsNotNone(args["build-file"])
+ self.assertEqual(args["build-file"], "mybuildfile.py")
+ self.assertIsNone(args["properties"])
+ self.assertIsNotNone(args["targets"])
+ self.assertEqual(len(args["targets"]), 0)
+
+ def test_build_file_spec_long(self):
+ """Test build file option"""
+ args_in = ["--build-file", "mybuildfile.py"]
+ args = xnt.xenant.parse_args(args_in)
+ self.assertIsNotNone(args)
+ self.assertFalse(args["verbose"])
+ self.assertFalse(args["list-targets"])
+ self.assertIsNotNone(args["build-file"])
+ self.assertEqual(args["build-file"], "mybuildfile.py")
+ self.assertIsNone(args["properties"])
+ self.assertIsNotNone(args["targets"])
+ self.assertEqual(len(args["targets"]), 0)
+
if __name__ == "__main__":
unittest.main()
diff --git a/xnt/xenant.py b/xnt/xenant.py
index 9e5a3df..5e8dc66 100644
--- a/xnt/xenant.py
+++ b/xnt/xenant.py
@@ -33,12 +33,15 @@ def main():
"""Xnt Entry Point"""
start_time = time.time()
args = parse_args(sys.argv[1:])
+ build_file = "./build.py"
if args["verbose"]:
LOGGER.setLevel(logging.DEBUG)
+ if args["build-file"]:
+ build_file = args["build-file"]
if args["list-targets"]:
- error_code = list_targets(load_build())
+ error_code = list_targets(load_build(build_file))
else:
- error_code = invoke_build(load_build(),
+ error_code = invoke_build(load_build(build_file),
args["targets"],
args["properties"])
elapsed_time = time.time() - start_time
@@ -47,15 +50,20 @@ def main():
LOGGER.info("Failure")
from xnt.tasks import rm
rm("build.pyc",
- "__pycache__")
+ "__pycache__",
+ build_file + "c",
+ os.path.join(os.path.dirname(build_file), "__pycache__"))
if error_code != 0:
sys.exit(error_code)
-def load_build(path=""):
+def load_build(buildfile="./build.py"):
"""Load build file
Load the build.py and return the resulting import
"""
+ path = os.path.dirname(buildfile)
+ build = os.path.basename(buildfile)
+ buildmodule = os.path.splitext(build)[0]
if not path:
path = os.getcwd()
else:
@@ -63,17 +71,17 @@ def load_build(path=""):
sys.path.append(path)
cwd = os.getcwd()
os.chdir(path)
- if not os.path.exists("build.py"):
+ if not os.path.exists(build):
LOGGER.error("There was no build file")
sys.exit(1)
try:
- return __import__("build", fromlist=[])
+ return __import__(buildmodule, fromlist=[])
except ImportError:
LOGGER.error("HOW?!")
return None
finally:
sys.path.remove(path)
- del sys.modules["build"]
+ del sys.modules[buildmodule]
os.chdir(cwd)
def invoke_build(build, targets=None, props=None):
@@ -147,6 +155,11 @@ def parse_args(args_in):
action="version",
version=__version__,
help="Print Xnt Version and quit")
+ parser.add_argument(
+ "-b", "--build-file",
+ dest="build-file",
+ help="""Specify a build file if different than defaut or in different
+ path""")
parser.add_argument("-l", "--list-targets",
action="store_true",
dest="list-targets",