self._dict[key] = kw[key]
elif SCons.Util.is_List(self._dict[key]) and not \
SCons.Util.is_List(kw[key]):
- self._dict[key] = self._dict[key] + [ kw[key] ]
+ if not kw[key] is None and kw[key] != '':
+ self._dict[key] = self._dict[key] + [ kw[key] ]
elif SCons.Util.is_List(kw[key]) and not \
SCons.Util.is_List(self._dict[key]):
- self._dict[key] = [ self._dict[key] ] + kw[key]
+ if self._dict[key] is None or self._dict[key] == '':
+ self._dict[key] = kw[key]
+ else:
+ self._dict[key] = [ self._dict[key] ] + kw[key]
elif SCons.Util.is_Dict(self._dict[key]) and \
SCons.Util.is_Dict(kw[key]):
self._dict[key].update(kw[key])
# the default parse function
def parse_conf(env, output):
- env_dict = env.Dictionary()
+ dict = {
+ 'CPPPATH' : [],
+ 'LIBPATH' : [],
+ 'LIBS' : [],
+ 'CCFLAGS' : [],
+ }
static_libs = []
- # setup all the dictionary options
- if not env_dict.has_key('CPPPATH'):
- env_dict['CPPPATH'] = []
- if not env_dict.has_key('LIBPATH'):
- env_dict['LIBPATH'] = []
- if not env_dict.has_key('LIBS'):
- env_dict['LIBS'] = []
- if not env_dict.has_key('CCFLAGS') or env_dict['CCFLAGS'] == "":
- env_dict['CCFLAGS'] = []
-
params = string.split(output)
for arg in params:
switch = arg[0:1]
opt = arg[1:2]
if switch == '-':
if opt == 'L':
- env_dict['LIBPATH'].append(arg[2:])
+ dict['LIBPATH'].append(arg[2:])
elif opt == 'l':
- env_dict['LIBS'].append(arg[2:])
+ dict['LIBS'].append(arg[2:])
elif opt == 'I':
- env_dict['CPPPATH'].append(arg[2:])
+ dict['CPPPATH'].append(arg[2:])
else:
- env_dict['CCFLAGS'].append(arg)
+ dict['CCFLAGS'].append(arg)
else:
static_libs.append(arg)
+ apply(env.Append, (), dict)
return static_libs
if function is None:
nkw = self.subst_kw(kw)
return apply(SCons.Scanner.Base, nargs, nkw)
- def SConsignFile(self, name=".sconsign.dbm"):
+ def SConsignFile(self, name=".sconsign.dbm", dbm_module=None):
name = self.subst(name)
if not os.path.isabs(name):
name = os.path.join(str(self.fs.SConstruct_dir), name)
- SCons.Sig.SConsignFile(name)
+ SCons.Sig.SConsignFile(name, dbm_module)
def SideEffect(self, side_effect, target):
"""Tell scons that side_effects are built as side
import UserList
UL = UserList.UserList
- env1 = Environment(AAA = 'a', BBB = 'b', CCC = 'c', DDD = 'd',
- EEE = ['e'], FFF = ['f'], GGG = ['g'], HHH = ['h'],
- III = UL(['i']), JJJ = UL(['j']),
- KKK = UL(['k']), LLL = UL(['l']))
- env1.Append(BBB = 'B', CCC = ['C'], DDD = UL(['D']),
- FFF = 'F', GGG = ['G'], HHH = UL(['H']),
- JJJ = 'J', KKK = ['K'], LLL = UL(['L']))
- env2 = Environment(AAA = 'a', BBB = 'bB',
- CCC = ['c', 'C'], DDD = UL(['d', 'D']),
- EEE = ['e'], FFF = ['f', 'F'],
- GGG = ['g', 'G'], HHH = UL(['h', 'H']),
- III = UL(['i']), JJJ = UL(['j', 'J']),
- KKK = UL(['k', 'K']), LLL = UL(['l', 'L']))
- assert env1 == env2, diff_env(env1, env2)
+ env1 = Environment(AAA = 'a',
+ AAA1 = 'a1', AAA2 = 'a2', AAA3 = 'a3',
+ EEE = ['e'],
+ EEE1 = ['e1'], EEE2 = ['e2'], EEE3 = ['e3'],
+ III = UL(['i']),
+ III1 = UL(['i1']), III2 = UL(['i2']), III3 = UL(['i3']),
+ MMM = '',
+ MMM1 = '', MMM2 = '', MMM3 = '',
+ NNN = [],
+ NNN1 = [], NNN2 = [], NNN3 = [],
+ OOO = UL([]),
+ OOO1 = UL([]), OOO2 = UL([]), OOO3 = UL([]),
+ PPP = [''],
+ PPP1 = [''], PPP2 = [''], PPP3 = [''],
+ QQQ = UL(['']),
+ QQQ1 = UL(['']), QQQ2 = UL(['']), QQQ3 = UL(['']))
+ env1.Append(AAA1 = 'A1', AAA2 = ['A2'], AAA3 = UL(['A3']),
+ EEE1 = 'E1', EEE2 = ['E2'], EEE3 = UL(['E3']),
+ III1 = 'I1', III2 = ['I2'], III3 = UL(['I3']),
+ MMM1 = 'M1', MMM2 = ['M2'], MMM3 = UL(['M3']),
+ NNN1 = 'N1', NNN2 = ['N2'], NNN3 = UL(['N3']),
+ OOO1 = 'O1', OOO2 = ['O2'], OOO3 = UL(['O3']),
+ PPP1 = 'P1', PPP2 = ['P2'], PPP3 = UL(['P3']),
+ QQQ1 = 'Q1', QQQ2 = ['Q2'], QQQ3 = UL(['Q3']))
+ assert env1['AAA'] == 'a', env1['AAA']
+ assert env1['AAA1'] == 'a1A1', env1['AAA1']
+ assert env1['AAA2'] == ['a2', 'A2'], env1['AAA2']
+ assert env1['AAA3'] == UL(['a3', 'A3']), env1['AAA3']
+ assert env1['EEE'] == ['e'], env1['EEE']
+ assert env1['EEE1'] == ['e1', 'E1'], env1['EEE1']
+ assert env1['EEE2'] == ['e2', 'E2'], env1['EEE2']
+ assert env1['EEE3'] == UL(['e3', 'E3']), env1['EEE3']
+ assert env1['III'] == UL(['i']), env1['III']
+ assert env1['III1'] == UL(['i1', 'I1']), env1['III1']
+ assert env1['III2'] == UL(['i2', 'I2']), env1['III2']
+ assert env1['III3'] == UL(['i3', 'I3']), env1['III3']
+ assert env1['MMM'] == '', env1['MMM']
+ assert env1['MMM1'] == 'M1', env1['MMM1']
+ assert env1['MMM2'] == ['M2'], env1['MMM2']
+ assert env1['MMM3'] == UL(['M3']), env1['MMM3']
+ assert env1['NNN1'] == ['N1'], env1['NNN1']
+ assert env1['NNN2'] == ['N2'], env1['NNN2']
+ assert env1['NNN3'] == UL(['N3']), env1['NNN3']
+ assert env1['OOO1'] == ['O1'], env1['OOO1']
+ assert env1['OOO2'] == ['O2'], env1['OOO2']
+ assert env1['OOO3'] == UL(['O3']), env1['OOO3']
+ assert env1['PPP1'] == ['', 'P1'], env1['PPP1']
+ assert env1['PPP2'] == ['', 'P2'], env1['PPP2']
+ assert env1['PPP3'] == UL(['', 'P3']), env1['PPP3']
+ assert env1['QQQ1'] == UL(['', 'Q1']), env1['QQQ1']
+ assert env1['QQQ2'] == UL(['', 'Q2']), env1['QQQ2']
+ assert env1['QQQ3'] == UL(['', 'Q3']), env1['QQQ3']
env3 = Environment(X = {'x1' : 7})
env3.Append(X = {'x1' : 8, 'x2' : 9}, Y = {'y1' : 10})
def test_ParseConfig(self):
"""Test the ParseConfig() method"""
- env = Environment(COMMAND='command')
+ env = Environment(COMMAND='command',
+ CPPPATH='string',
+ LIBPATH=['list'],
+ LIBS='',
+ CCFLAGS=[''])
save_command = []
orig_popen = os.popen
def my_popen(command, save_command=save_command):
libs = env.ParseConfig("fake $COMMAND")
assert save_command == ['fake command'], save_command
assert libs == ['abc'], libs
- assert env['CPPPATH'] == ['/usr/include/fum', 'bar'], env['CPPPATH']
- assert env['LIBPATH'] == ['/usr/fax', 'foo'], env['LIBPATH']
+ assert env['CPPPATH'] == ['string', '/usr/include/fum', 'bar'], env['CPPPATH']
+ assert env['LIBPATH'] == ['list', '/usr/fax', 'foo'], env['LIBPATH']
assert env['LIBS'] == ['xxx'], env['LIBS']
- assert env['CCFLAGS'] == ['-X'], env['CCFLAGS']
+ assert env['CCFLAGS'] == ['', '-X'], env['CCFLAGS']
finally:
os.popen = orig_popen
env.fs = MyFS()
try:
- save = []
- def capture(name, save=save):
- save.append(name)
+ fnames = []
+ dbms = []
+ def capture(name, dbm_module, fnames=fnames, dbms=dbms):
+ fnames.append(name)
+ dbms.append(dbm_module)
save_Sig_SConsignFile = SCons.Sig.SConsignFile
SCons.Sig.SConsignFile = capture
env.SConsignFile('foo')
- assert save[0] == os.path.join(os.sep, 'dir', 'foo'), save
+ assert fnames[0] == os.path.join(os.sep, 'dir', 'foo'), fnames
+ assert dbms[0] == None, dbms
env.SConsignFile('$FOO')
- assert save[1] == os.path.join(os.sep, 'dir', 'SConsign'), save
+ assert fnames[1] == os.path.join(os.sep, 'dir', 'SConsign'), fnames
+ assert dbms[1] == None, dbms
env.SConsignFile('/$FOO')
- assert save[2] == '/SConsign', save
+ assert fnames[2] == '/SConsign', fnames
+ assert dbms[2] == None, dbms
- env.SConsignFile('$BAR')
- assert save[3] == os.path.join(os.sep, 'File'), save
+ env.SConsignFile('$BAR', 'x')
+ assert fnames[3] == os.path.join(os.sep, 'File'), fnames
+ assert dbms[3] == 'x', dbms
- env.SConsignFile('__$BAR')
- assert save[4] == os.path.join(os.sep, 'dir', '__', 'File'), save
+ env.SConsignFile('__$BAR', 7)
+ assert fnames[4] == os.path.join(os.sep, 'dir', '__', 'File'), fnames
+ assert dbms[4] == 7, dbms
finally:
SCons.Sig.SConsignFile = save_Sig_SConsignFile