diff options
author | Steven Knight <knight@baldmt.com> | 2002-04-11 05:04:42 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-04-11 05:04:42 (GMT) |
commit | e7578889702d1be9231592a0b2a39050f3702c51 (patch) | |
tree | 3c035451ea95a33b0473361d1446fe7cad1fe6df /src | |
parent | 3207c9ca9efaac1b8d3f2174d2e5f336f92887ab (diff) | |
download | SCons-e7578889702d1be9231592a0b2a39050f3702c51.zip SCons-e7578889702d1be9231592a0b2a39050f3702c51.tar.gz SCons-e7578889702d1be9231592a0b2a39050f3702c51.tar.bz2 |
Add abspath construction variable modifier and variable (Anthony Roach)
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 7 | ||||
-rw-r--r-- | src/engine/SCons/Action.py | 6 | ||||
-rw-r--r-- | src/engine/SCons/ActionTests.py | 3 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 7 | ||||
-rw-r--r-- | src/engine/SCons/UtilTests.py | 12 |
5 files changed, 31 insertions, 4 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 173fea6..5fb3c00 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -35,6 +35,13 @@ RELEASE 0.07 - - Implemented caching of content signatures, plus added --max-drift option to control caching. + - Implemented caching of dependency signatures, enabled by new + --implicit-cache option. + + - Added abspath construction variable modifier. + + - Added $SOURCE variable as a synonym for $SOURCES[0]. + RELEASE 0.06 - Thu, 28 Mar 2002 01:24:29 -0600 diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 3ed3d73..3d52142 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -216,8 +216,8 @@ class ActionBase: construction variables source - the source (object or array of objects), - used to generate the SOURCES construction - variable + used to generate the SOURCES and SOURCE + construction variables Any other keyword arguments are copied into the dictionary.""" @@ -253,6 +253,8 @@ class ActionBase: if not SCons.Util.is_List(s): s = [s] dict['SOURCES'] = SCons.Util.PathList(map(os.path.normpath, map(str, s))) + if dict['SOURCES']: + dict['SOURCE'] = dict['SOURCES'][0] dict.update(kw) diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index c7cad2d..1a0596f 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -88,6 +88,8 @@ class ActionBaseTestCase(unittest.TestCase): assert str(d['TARGETS']) == 't', d['TARGETS'] assert str(d['TARGET']) == 't', d['TARGET'] assert str(d['SOURCES']) == 's', d['SOURCES'] + assert str(d['SOURCE']) == 's', d['SOURCE'] + d = a.subst_dict(target = ['t1', 't2'], source = ['s1', 's2']) TARGETS = map(lambda x: str(x), d['TARGETS']) @@ -97,6 +99,7 @@ class ActionBaseTestCase(unittest.TestCase): SOURCES = map(lambda x: str(x), d['SOURCES']) SOURCES.sort() assert SOURCES == ['s1', 's2'], d['SOURCES'] + assert str(d['SOURCE']) == 's1', d['SOURCE'] class CommandActionTestCase(unittest.TestCase): diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index e31b1b0..3612b9a 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -116,11 +116,16 @@ class PathList(UserList.UserList): """Return the file name with path and suffix stripped.""" return self.__getFileName().__splitPath(os.path.splitext)[0] + def __getAbsPath(self): + """Return the absolute path""" + return map(os.path.abspath, self.data) + dictSpecialAttrs = { "file" : __getFileName, "base" : __getBasePath, "filebase" : __getBase, "dir" : __getDir, - "suffix" : __getSuffix } + "suffix" : __getSuffix, + "abspath" : __getAbsPath} def __str__(self): return string.join(self.data) diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 60d7d4d..8be22f8 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -46,6 +46,7 @@ class UtilTestCase(unittest.TestCase): loc['SOURCES'] = PathList(map(os.path.normpath, [ "./foo/blah.cpp", "/bar/ack.cpp", "../foo/ack.c" ])) + loc['SOURCE'] = loc['SOURCES'][0] loc['xxx'] = None loc['zero'] = 0 loc['one'] = 1 @@ -70,7 +71,7 @@ class UtilTestCase(unittest.TestCase): newcom = scons_subst("test $TARGET", loc, {}) assert newcom == cvt("test foo/bar.exe") - newcom = scons_subst("test $TARGET$SOURCE[0]", loc, {}) + newcom = scons_subst("test $TARGET$FOO[0]", loc, {}) assert newcom == cvt("test foo/bar.exe[0]") newcom = scons_subst("test ${TARGET.file}", loc, {}) @@ -88,6 +89,15 @@ class UtilTestCase(unittest.TestCase): newcom = scons_subst("test ${TARGET.dir}", loc, {}) assert newcom == cvt("test foo") + newcom = scons_subst("test ${TARGET.abspath}", loc, {}) + assert newcom == cvt("test %s/foo/bar.exe"%os.getcwd()), newcom + + newcom = scons_subst("test ${SOURCES.abspath}", loc, {}) + assert newcom == cvt("test %s/foo/blah.cpp /bar/ack.cpp %s/foo/ack.c"%(os.getcwd(),os.path.normpath(os.getcwd()+"/.."))), newcom + + newcom = scons_subst("test ${SOURCE.abspath}", loc, {}) + assert newcom == cvt("test %s/foo/blah.cpp"%os.getcwd()), newcom + newcom = scons_subst("test $xxx", loc, {}) assert newcom == cvt("test"), newcom |