From 984e4e6f398184da18b80d10f24a8f5ec91750d8 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Wed, 6 Mar 2013 13:30:54 +1100 Subject: [PATCH] Provide better control of sharing the defaults. When using the set builder and nesting builds prpvide the nested set builder and build objects with copies of the master defaults. Python's variable sharing was sharing a single set of defaults across all build sets and this resulted in popluted configurations. --- source-builder/sb/defaults.py | 26 +++++++++++++------------- source-builder/sb/setbuilder.py | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/source-builder/sb/defaults.py b/source-builder/sb/defaults.py index 3eea5bb..9743c9a 100644 --- a/source-builder/sb/defaults.py +++ b/source-builder/sb/defaults.py @@ -216,16 +216,6 @@ FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; class command_line: """Process the command line in a common way for all Tool Builder commands.""" - _defaults = { 'params' : [], - 'warn-all' : '0', - 'quiet' : '0', - 'force' : '0', - 'trace' : '0', - 'dry-run' : '0', - 'no-clean' : '0', - 'no-smp' : '0', - 'rebuild' : '0' } - # # The define and if it is a path and needs conversion. # @@ -292,12 +282,22 @@ class command_line: if len(self.command_path) == 0: self.command_path = '.' self.command_name = path.basename(argv[0]) + self.argv = argv self.args = argv[1:] self.optargs = optargs self.defaults = {} for to in command_line._long_true_opts: self.defaults[command_line._long_true_opts[to]] = ('none', 'none', '0') self.defaults['_sbdir'] = ('dir', 'required', path.shell(self.command_path)) + self.opts = { 'params' : [], + 'warn-all' : '0', + 'quiet' : '0', + 'force' : '0', + 'trace' : '0', + 'dry-run' : '0', + 'no-clean' : '0', + 'no-smp' : '0', + 'rebuild' : '0' } self._process() def __str__(self): @@ -339,7 +339,6 @@ class command_line: return lo, long_opts[lo], True, arg return None, None, None, arg - self.opts = command_line._defaults i = 0 while i < len(self.args): a = self.args[i] @@ -502,7 +501,7 @@ class command_line: if not configbase.endswith('.cfg'): configbase = configbase + '.cfg' if len(configdir) == 0: - configdir = self.expand(defaults['_configdir'][2], defaults) + configdir = self.expand(self.defaults['_configdir'][2], self.defaults) configs = [] for cp in configdir.split(':'): hostconfigdir = path.host(cp) @@ -540,7 +539,8 @@ def load(args, optargs = None): line merging in any command line overrides. Finally post process the command line. """ - d = defaults + import copy + d = copy.deepcopy(defaults) overrides = None if os.name == 'nt': import windows diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index 5681299..253362d 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -22,6 +22,7 @@ # set lists the various tools. These are specific tool configurations. # +import copy import datetime import distutils.dir_util import glob @@ -64,8 +65,8 @@ class buildset: def __init__(self, bset, _configs, _defaults, opts): _trace(opts, '_bset:%s: init' % (bset)) - self.opts = opts self.configs = _configs + self.opts = opts self.defaults = _defaults self.bset = bset self.bset_pkg = '%s-%s-set' % (self.opts.expand('%{_target}', _defaults), @@ -269,18 +270,25 @@ class buildset: builds = [] for s in range(0, len(configs)): try: + # + # Each section of the build set gets a separate set of + # defaults so we do not contaminate one configuration with + # another. + # + _opts = copy.deepcopy(self.opts) + _defaults = copy.deepcopy(self.defaults) if configs[s].endswith('.bset'): bs = buildset(configs[s], _configs = self.configs, - _defaults = self.defaults, - opts = self.opts) + _defaults = _defaults, + opts = _opts) bs.build() del bs elif configs[s].endswith('.cfg'): b = build.build(configs[s], self.opts.get_arg('--pkg-tar-files'), - _defaults = self.defaults, - opts = self.opts) + _defaults = _defaults, + opts = _opts) if s == 0: tmproot = self.first_package(b) b.make()