Have ParseConfig() support the -Wl option.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 3 May 2004 13:58:44 +0000 (13:58 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 3 May 2004 13:58:44 +0000 (13:58 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@967 fdb21ef1-2011-0410-befe-b5e4ea1792b1

doc/man/scons.1
src/CHANGES.txt
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py

index bb0bbd3c98527d92ef50fdcdb6515e268b6ab11e..aedefe4dad751c5d644f93c4b668089d1080776b 100644 (file)
@@ -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
index 3e7fa911a2c1fa74949916357620b8786bb2f09c..3d3d4cecf6ac9c8b1f2323b5d53ae510bcbdf394 100644 (file)
@@ -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.
index d214e9be4a9a625ad83f8cdde9474bf33c630f1a..d4279d17c7c0671635faf9f976b921c2b2e85a80 100644 (file)
@@ -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
     
index d141d497ffdacc4d19056fa2995972215062dbba..8bab2468ec812bd51f21417c6021b6320ffc7720 100644 (file)
@@ -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