From: stevenknight Date: Mon, 3 May 2004 13:58:44 +0000 (+0000) Subject: Have ParseConfig() support the -Wl option. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8c869a61baacf597dd16c05fae79eee1e6eeaf5e;p=scons.git Have ParseConfig() support the -Wl option. git-svn-id: http://scons.tigris.org/svn/scons/trunk@967 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index bb0bbd3c..aedefe4d 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 3e7fa911..3d3d4cec 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 d214e9be..d4279d17 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 d141d497..8bab2468 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