.IP TARGETS
The file names of all targets being built.
+.IP SOURCE
+The file name of the source of the build command, or the file name of the
+first source if multiple sources are being built.
+
.IP SOURCES
The file names of the sources of the build command.
+
.LP
For example, given the construction variable CC='cc', targets=['foo'], and
sources=['foo.c', 'bar.c']:
.IP suffix
Just the file suffix.
+.IP abspath
+The absolute path name of the file.
+
.LP
For example, the specified target will
expand as follows for the corresponding modifiers:
${TARGET.file} => file.x
${TARGET.filebase} => file
${TARGET.suffix} => .x
+${TARGET.abspath} => /top/dir/sub/dir/file.x
.EE
.LP
- 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
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."""
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)
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'])
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):
"""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)
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
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, {})
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