summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcdist39
1 files changed, 21 insertions, 18 deletions
diff --git a/cdist b/cdist
index 8d3fe6f..e7e0dd0 100755
--- a/cdist
+++ b/cdist
@@ -315,7 +315,8 @@ def devel_to_git(git_commit, filename):
return filename
-def get_options(args, target):
+def get_command_line_options(args):
+ """Get the options specified by --option on the command line"""
options = dict()
if args.option is not None:
for o in args.option:
@@ -328,9 +329,6 @@ def get_options(args, target):
options[b[0]] = True
else:
options[b[0]] = b[1]
- # Add defaults for any unspecified options
- tree = globals.trees.get(args.project, args.checkout, target)
- tree.add_defaults(options)
return options
@@ -451,10 +449,7 @@ class Target(object):
pass
def package(self, project, checkout, output_dir, options):
- tree = globals.trees.get(project, checkout, self)
- if self.build_dependencies:
- tree.build_dependencies(options)
- tree.build(options)
+ tree = self.build(project, checkout, options)
if len(inspect.getargspec(tree.cscript['package']).args) == 3:
packages = tree.call('package', tree.version, options)
else:
@@ -472,6 +467,7 @@ class Target(object):
if self.build_dependencies:
tree.build_dependencies(options)
tree.build(options)
+ return tree
def test(self, tree, test, options):
"""test is the test case to run, or None"""
@@ -936,7 +932,7 @@ class Tree(object):
return self.cscript[function](self.target, *args)
def add_defaults(self, options):
- """Add the defaults from this into a dict options"""
+ """Add the defaults from self into a dict options"""
if 'option_defaults' in self.cscript:
from_cscript = self.cscript['option_defaults']
if isinstance(from_cscript, dict):
@@ -949,6 +945,10 @@ class Tree(object):
options[k] = v
def dependencies(self, options):
+ """
+ yield details of the dependencies of this tree. Each dependency is returned
+ as a tuple of (tree, options)
+ """
if not 'dependencies' in self.cscript:
return
@@ -963,16 +963,15 @@ class Tree(object):
# Start with the options passed in
dep_options = copy.copy(options)
- # Add things specified by the parent
+ # Override those options with anything the parent specifies
if len(d) > 2:
+ print("Building dep %s; parent's options are %s" % (d[0], d[2]))
for k, v in d[2].items():
- if not k in dep_options:
- dep_options[k] = v
- # Then fill in the dependency's defaults
- dep.add_defaults(dep_options)
+ dep_options[k] = v
for i in dep.dependencies(dep_options):
yield i
+ print("yield %s %s" % (dep, dep_options))
yield (dep, dep_options)
def checkout_dependencies(self, options={}):
@@ -980,10 +979,14 @@ class Tree(object):
pass
def build_dependencies(self, options):
+ # Start with the options passed in
+ options = copy.copy(options)
+ # Fill in the defaults
+ self.add_defaults(options)
for i in self.dependencies(options):
global args
if args.verbose:
- print('Building a dependency of %s %s %s with %s' % (self.name, self.specifier, self.version, options))
+ print('Building %s as a dependency of %s %s %s with %s' % (i[0].name, self.name, self.specifier, self.version, i[1]))
i[0].build(i[1])
def build(self, options):
@@ -1105,7 +1108,7 @@ def main():
raise Error('you must specify -t or --target')
target = target_factory(args)
- target.build(args.project, args.checkout, get_options(args, target))
+ target.build(args.project, args.checkout, get_command_line_options(args))
if not args.keep:
target.cleanup()
@@ -1126,7 +1129,7 @@ def main():
output_dir = args.output
makedirs(output_dir)
- target.package(args.project, args.checkout, output_dir, get_options(args, target))
+ target.package(args.project, args.checkout, output_dir, get_command_line_options(args))
except Error as e:
if target is not None and not args.keep:
target.cleanup()
@@ -1239,7 +1242,7 @@ def main():
target = target_factory(args)
tree = globals.trees.get(args.project, args.checkout, target)
with TreeDirectory(tree):
- target.test(tree, args.test, get_options(args, target))
+ target.test(tree, args.test, get_command_line_options(args))
except Error as e:
if target is not None and not args.keep:
target.cleanup()