- Speed up turning file system Nodes into strings by caching the
values after we're finished reading the SConscript files.
+ - Have ParseConfig() recognize and supporting adding the -Wa, -Wl,
+ and -Wp, flags to ASFLAGS, LINKFLAGS and CPPFLAGS, respectively.
+
From Gary Oberbrunner:
- Add a --debug=presub option to print actions prior to substitution.
def ParseConfig(self, command, function=None):
"""
Use the specified function to parse the output of the command
- in order to modify the current environment. The 'command'
- can be a string or a list of strings representing a command and
+ in order to modify the current environment. The 'command' can
+ be a string or a list of strings representing a command and
it's arguments. 'Function' is an optional argument that takes
the environment and the output of the command. If no function is
specified, the output will be treated as the output of a typical
- 'X-config' command (i.e. gtk-config) and used to set the CPPPATH,
- LIBPATH, LIBS, and CCFLAGS variables.
+ 'X-config' command (i.e. gtk-config) and used to append to the
+ ASFLAGS, CCFLAGS, CPPFLAGS, CPPPATH, LIBPATH, LIBS, LINKFLAGS
+ and CCFLAGS variables.
"""
# the default parse function
def parse_conf(env, output):
dict = {
- 'CPPPATH' : [],
- 'LIBPATH' : [],
- 'LIBS' : [],
- 'CCFLAGS' : [],
+ 'ASFLAGS' : [],
+ 'CCFLAGS' : [],
+ 'CPPFLAGS' : [],
+ 'CPPPATH' : [],
+ 'LIBPATH' : [],
+ 'LIBS' : [],
+ 'LINKFLAGS' : [],
}
static_libs = []
params = string.split(output)
for arg in params:
- switch = arg[0:1]
- opt = arg[1:2]
- if switch == '-':
- if opt == 'L':
- dict['LIBPATH'].append(arg[2:])
- elif opt == 'l':
- dict['LIBS'].append(arg[2:])
- elif opt == 'I':
- dict['CPPPATH'].append(arg[2:])
- else:
- dict['CCFLAGS'].append(arg)
- else:
+ if arg[0] != '-':
static_libs.append(arg)
+ elif arg[:2] == '-L':
+ dict['LIBPATH'].append(arg[2:])
+ elif arg[:2] == '-l':
+ dict['LIBS'].append(arg[2:])
+ elif arg[:2] == '-I':
+ dict['CPPPATH'].append(arg[2:])
+ elif arg[:4] == '-Wa,':
+ dict['ASFLAGS'].append(arg)
+ elif arg[:4] == '-Wl,':
+ dict['LINKFLAGS'].append(arg)
+ elif arg[:4] == '-Wp,':
+ dict['CPPFLAGS'].append(arg)
+ else:
+ dict['CCFLAGS'].append(arg)
apply(env.Append, (), dict)
return static_libs
def test_ParseConfig(self):
"""Test the ParseConfig() method"""
- env = Environment(COMMAND='command',
+ env = Environment(ASFLAGS='assembler',
+ COMMAND='command',
+ CPPFLAGS=[''],
CPPPATH='string',
LIBPATH=['list'],
LIBS='',
+ LINKFLAGS=[''],
CCFLAGS=[''])
save_command = []
orig_popen = os.popen
class fake_file:
def read(self):
return "-I/usr/include/fum -Ibar -X\n" + \
- "-L/usr/fax -Lfoo -lxxx abc"
+ "-L/usr/fax -Lfoo -lxxx " + \
+ "-Wa,-as -Wl,-link -Wp,-cpp abc"
return fake_file()
try:
os.popen = my_popen
libs = env.ParseConfig("fake $COMMAND")
assert save_command == ['fake command'], save_command
assert libs == ['abc'], libs
+ assert env['ASFLAGS'] == ['assembler', '-Wa,-as'], env['ASFLAGS']
assert env['CPPPATH'] == ['string', '/usr/include/fum', 'bar'], env['CPPPATH']
+ assert env['CPPFLAGS'] == ['', '-Wp,-cpp'], env['CPPFLAGS']
assert env['LIBPATH'] == ['list', '/usr/fax', 'foo'], env['LIBPATH']
assert env['LIBS'] == ['xxx'], env['LIBS']
+ assert env['LINKFLAGS'] == ['', '-Wl,-link'], env['LINKFLAGS']
assert env['CCFLAGS'] == ['', '-X'], env['CCFLAGS']
finally:
os.popen = orig_popen