From: stevenknight Date: Wed, 1 Sep 2004 00:03:16 +0000 (+0000) Subject: Allow to contain File Nodes. Have ParseConfig add libraries to . Add support for... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b00c10655e06394cc4d39abbd5e3de2ee3c286c;p=scons.git Allow to contain File Nodes. Have ParseConfig add libraries to . Add support for -framework. (Gary Oberbrunner) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1053 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 931a46f3..910d77de 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -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 diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 617b38f8..d9caa723 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/RELEASE.txt b/src/RELEASE.txt index e689f67d..b0e80484 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -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(), diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index c75ac252..a99850bf 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -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): diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index aeae2729..9e58ff6f 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -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 diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index de09fd78..4839e2ad 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -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 diff --git a/test/ParseConfig.py b/test/ParseConfig.py index 108aa313..7e31a179 100644 --- a/test/ParseConfig.py +++ b/test/ParseConfig.py @@ -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)