Allow to contain File Nodes. Have ParseConfig add libraries to . Add support for...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 1 Sep 2004 00:03:16 +0000 (00:03 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 1 Sep 2004 00:03:16 +0000 (00:03 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1053 fdb21ef1-2011-0410-befe-b5e4ea1792b1

doc/man/scons.1
src/CHANGES.txt
src/RELEASE.txt
src/engine/SCons/Defaults.py
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py
test/ParseConfig.py

index 931a46f3d0635c288bef1545c123e5605b0d74c7..910d77dec085e3310aca65a5de2fac572841014c 100644 (file)
@@ -3071,6 +3071,16 @@ option gets added to both the
 and
 .B LINKFLAGS
 variables.
+A returned
+.B -framework
+option gets added to the
+.B LINKFLAGS
+variable.
+Any other strings not associated with options
+are assumed to be the names of libraries
+and added to the
+.B LIBS 
+construction variable.
 
 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 .TP
index 617b38f8a03f470a14176a827a47b27a893a4e93..d9caa723224fa6271a2416adc7a20fbd5ec327ef 100644 (file)
@@ -20,6 +20,13 @@ RELEASE 0.97 - XXX
   - Add an Environment.Dump() method to print the contents of a
     construction environment.
 
+  - Allow $LIBS (and similar variables) to contain explicit File Nodes.
+
+  - Change ParseConfig to add the found library names directly to the
+    $LIBS variable, instead of returning them.
+
+  - Add ParseConfig() support for the -framework GNU linker option.
+
   From Kevin Quick:
 
   - Fix the Builder name returned from ListBuilders and other instances
index e689f67dbc183ce888100729b51cee704938d8aa..b0e80484e286c2eef1636c688a150ffa57d6d5b0 100644 (file)
@@ -26,6 +26,13 @@ RELEASE 0.97 - XXX
   Please consult the CHANGES.txt file for a list of specific changes
   since last release.
 
+  Please note the following important changes since release 0.96:
+
+    - The ParseConfig() method now adds library file names returned
+      by the specified *-config command to the $LIBS construction
+      variable, instead of returning them (the same way it handles
+      the -l option).
+
   Please note the following important changes since release 0.95:
 
     - All Builder calls (both built-in like Program(), Library(),
index c75ac25222178bb4b6d09cf2746f039f0c42336d..a99850bfe6a8d2002c9edad791328bd3ed963d32 100644 (file)
@@ -234,31 +234,34 @@ def _concat(prefix, list, suffix, env, f=lambda x: x):
 
     list = f(env.subst_path(list))
 
-    ret = []
+    result = []
 
     # ensure that prefix and suffix are strings
     prefix = str(env.subst(prefix, SCons.Util.SUBST_RAW))
     suffix = str(env.subst(suffix, SCons.Util.SUBST_RAW))
 
     for x in list:
+        if isinstance(x, SCons.Node.FS.File):
+            result.append(x)
+            continue
         x = str(x)
         if x:
 
             if prefix:
                 if prefix[-1] == ' ':
-                    ret.append(prefix[:-1])
+                    result.append(prefix[:-1])
                 elif x[:len(prefix)] != prefix:
                     x = prefix + x
 
-            ret.append(x)
+            result.append(x)
 
             if suffix:
                 if suffix[0] == ' ':
-                    ret.append(suffix[1:])
+                    result.append(suffix[1:])
                 elif x[-len(suffix):] != suffix:
-                    ret[-1] = ret[-1]+suffix
+                    result[-1] = result[-1]+suffix
 
-    return ret
+    return result
 
 def _stripixes(prefix, list, suffix, stripprefix, stripsuffix, env, c=None):
     """This is a wrapper around _concat() that checks for the existence
@@ -272,16 +275,19 @@ def _stripixes(prefix, list, suffix, stripprefix, stripsuffix, env, c=None):
         else:
             c = _concat
     def f(list, sp=stripprefix, ss=stripsuffix):
-        ret = []
+        result = []
         for l in list:
+            if isinstance(l, SCons.Node.FS.File):
+                result.append(l)
+                continue
             if not SCons.Util.is_String(l):
                 l = str(l)
             if l[:len(sp)] == sp:
                 l = l[len(sp):]
             if l[-len(ss):] == ss:
                 l = l[:-len(ss)]
-            ret.append(l)
-        return ret
+            result.append(l)
+        return result
     return c(prefix, list, suffix, env, f)
 
 def _defines(prefix, defs, suffix, env, c=_concat):
index aeae2729f9e9efb102088eb8ab34ca290eab656f..9e58ff6f87cab024edab0ce1f57a40b8eff311af 100644 (file)
@@ -739,7 +739,7 @@ class Base:
         """
 
         # the default parse function
-        def parse_conf(env, output):
+        def parse_conf(env, output, fs=self.fs):
             dict = {
                 'ASFLAGS'       : [],
                 'CCFLAGS'       : [],
@@ -749,12 +749,15 @@ class Base:
                 'LIBS'          : [],
                 'LINKFLAGS'     : [],
             }
-            static_libs = []
     
             params = string.split(output)
+            append_next_arg_to=''       # for multi-word args
             for arg in params:
-                if arg[0] != '-':
-                    static_libs.append(arg)
+                if append_next_arg_to:
+                    dict[append_next_arg_to].append(arg)
+                    append_next_arg_to = ''
+                elif arg[0] != '-':
+                    dict['LIBS'].append(fs.File(arg))
                 elif arg[:2] == '-L':
                     dict['LIBPATH'].append(arg[2:])
                 elif arg[:2] == '-l':
@@ -767,13 +770,15 @@ class Base:
                     dict['LINKFLAGS'].append(arg)
                 elif arg[:4] == '-Wp,':
                     dict['CPPFLAGS'].append(arg)
+                elif arg == '-framework':
+                    dict['LINKFLAGS'].append(arg)
+                    append_next_arg_to='LINKFLAGS'
                 elif arg == '-pthread':
                     dict['CCFLAGS'].append(arg)
                     dict['LINKFLAGS'].append(arg)
                 else:
                     dict['CCFLAGS'].append(arg)
             apply(env.Append, (), dict)
-            return static_libs
     
         if function is None:
             function = parse_conf
index de09fd7807203fb89b5cc2b672f4a8db0df5b4cd..4839e2ad064c571601a4c0f42c7ddd35a7a2e7c9 100644 (file)
@@ -1335,19 +1335,18 @@ class EnvironmentTestCase(unittest.TestCase):
                 def read(self):
                     return "-I/usr/include/fum -Ibar -X\n" + \
                            "-L/usr/fax -Lfoo -lxxx " + \
-                           "-Wa,-as -Wl,-link -Wp,-cpp abc -pthread"
+                           "-Wa,-as -Wl,-link -Wp,-cpp abc -pthread -framework Carbon"
             return fake_file()
         try:
             os.popen = my_popen
-            libs = env.ParseConfig("fake $COMMAND")
+            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', '-pthread'], env['LINKFLAGS']
+            assert env['LIBS'] == ['xxx', env.File('abc')], env['LIBS']
+            assert env['LINKFLAGS'] == ['', '-Wl,-link', '-pthread', '-framework', 'Carbon'], env['LINKFLAGS']
             assert env['CCFLAGS'] == ['', '-X', '-pthread'], env['CCFLAGS']
         finally:
             os.popen = orig_popen
index 108aa31392abda18a2795f86a2ea422d44c3e85c..7e31a1798947040fb1629f11e1f66fd8a2adbe2d 100644 (file)
@@ -33,6 +33,9 @@ test = TestSCons.TestSCons()
 
 test_config = test.workpath('test-config')
 
+# 'abc' is supposed to be a static lib; it is included in LIBS as a
+# File node.
+# It used to be returned as the 'static_libs' output of ParseConfig.
 test.write('test-config', """#! /usr/bin/env python
 print "-I/usr/include/fum -Ibar -X"
 print "-L/usr/fax -Lfoo -lxxx abc"
@@ -40,41 +43,37 @@ print "-L/usr/fax -Lfoo -lxxx abc"
 
 test.write('SConstruct', """
 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '')
-static_libs = env.ParseConfig([r"%s", r"%s", "--libs --cflags"])
+env.ParseConfig([r"%s", r"%s", "--libs --cflags"])
 print env['CPPPATH']
 print env['LIBPATH']
-print env['LIBS']
+print map(lambda x: str(x), env['LIBS'])
 print env['CCFLAGS']
-print static_libs
 """ % (TestSCons.python, test_config))
 
 test.write('SConstruct2', """
 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '',
                   PYTHON = '%s')
-static_libs = env.ParseConfig(r"$PYTHON %s --libs --cflags")
+env.ParseConfig(r"$PYTHON %s --libs --cflags")
 print env['CPPPATH']
 print env['LIBPATH']
-print env['LIBS']
+print map(lambda x: str(x), env['LIBS'])
 print env['CCFLAGS']
-print static_libs
 """ % (TestSCons.python, test_config))
 
 test.write('SConstruct3', """
 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '')
-static_libs = ParseConfig(env, r"%s %s --libs --cflags")
+ParseConfig(env, r"%s %s --libs --cflags")
 print env['CPPPATH']
 print env['LIBPATH']
-print env['LIBS']
+print map(lambda x: str(x), env['LIBS'])
 print env['CCFLAGS']
-print static_libs
 """ % (TestSCons.python, test_config))
 
 good_stdout = test.wrap_stdout(read_str = """\
 ['/usr/include/fum', 'bar']
 ['/usr/fax', 'foo']
-['xxx']
+['xxx', 'abc']
 ['-X']
-['abc']
 """, build_str = "scons: `.' is up to date.\n")
 
 test.run(arguments = ".", stdout = good_stdout)