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.
This commit is contained in:
Chris Johns 2013-03-06 13:30:54 +11:00
parent 5e883dbc6f
commit 984e4e6f39
2 changed files with 26 additions and 18 deletions

View File

@ -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

View File

@ -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()