From 294fbf069e116719cd63ad18c4b7610a0754e5da Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Mon, 3 May 2004 13:58:44 +0000 Subject: Have ParseConfig() support the -Wl option. --- doc/man/scons.1 | 6 +++++ src/CHANGES.txt | 3 +++ src/engine/SCons/Environment.py | 47 +++++++++++++++++++++--------------- src/engine/SCons/EnvironmentTests.py | 11 +++++++-- 4 files changed, 45 insertions(+), 22 deletions(-) diff --git a/doc/man/scons.1 b/doc/man/scons.1 index bb0bbd3..aedefe4 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -2869,11 +2869,17 @@ expects the output of a typical and parses the returned .BR -L , .BR -l , +.BR -Wa , +.BR -Wl , +.BR -Wp , .B -I and other options into the .BR LIBPATH , .BR LIBS , +.BR ASFLAGS , +.BR LINKFLAGS , +.BR CPPFLAGS , .B CPPPATH and .B CCFLAGS diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 3e7fa91..3d3d4ce 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -104,6 +104,9 @@ RELEASE 0.96 - XXX - 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. diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index d214e9b..d4279d1 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -701,40 +701,47 @@ class Base: 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 diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index d141d49..8bab246 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1302,10 +1302,13 @@ class EnvironmentTestCase(unittest.TestCase): 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 @@ -1314,16 +1317,20 @@ class EnvironmentTestCase(unittest.TestCase): 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 -- cgit v0.12