From: stevenknight Date: Sat, 13 Aug 2005 19:09:11 +0000 (+0000) Subject: Add a Dirs() function that can be used in hBcexpansions. (Stanislav Baranov) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=95c0757c72f353ba002e1fc6c1778cff751ce3d6;p=scons.git Add a Dirs() function that can be used in hBcexpansions. (Stanislav Baranov) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1329 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index a1fc076b..96bd467f 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -4882,19 +4882,15 @@ This may or may not be set, depending on the specific C compiler being used. .IP _concat -A function used to produce variables like $_CPPINCFLAGS. -It takes four to seven arguments: -a prefix to concatenate onto each element; -a list of elements; -a suffix to concatenate onto each element; -an environment for variable interpolation; -an optional function that will be -called to transform the list before concatenation; -a target or list of targets; -and a source or list of sources. +A function used to produce variables like $_CPPINCFLAGS. It takes +four or five +arguments: a prefix to concatenate onto each element, a list of +elements, a suffix to concatenate onto each element, an environment +for variable interpolation, and an optional function that will be +called to transform the list before concatenation. .ES -env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)', +env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)', .EE .IP CPPDEFINES @@ -5151,8 +5147,12 @@ This may or may not be set, depending on the specific C++ compiler being used. .IP Dir -A function that converts a file name into a Dir instance relative to the -target being built. +A function that converts a string +into a Dir instance relative to the target being built. + +.IP Dirs +A function that converts a list of strings +into a list of Dir instances relative to the target being built. .IP DSUFFIXES The list of suffixes of files that will be scanned @@ -5723,7 +5723,7 @@ The default list is: .EE .IP File -A function that converts a file name into a File instance relative to the +A function that converts a string into a File instance relative to the target being built. .IP FRAMEWORKPATH @@ -6756,7 +6756,7 @@ The string displayed when registering a newly-built DLL file. If this is not set, then $REGSVRCOM (the command line) is displayed. .IP RDirs -A function that converts a file name into a list of Dir instances by +A function that converts a string into a list of Dir instances by searching the repositories. .IP RMIC diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index e8df84fe..88a167a6 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -364,6 +364,7 @@ ConstructionEnvironment = { '_CPPDEFFLAGS' : '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}', 'TEMPFILE' : NullCmdGenerator, 'Dir' : Variable_Method_Caller('TARGET', 'Dir'), + 'Dirs' : Variable_Method_Caller('TARGET', 'Dirs'), 'File' : Variable_Method_Caller('TARGET', 'File'), 'RDirs' : Variable_Method_Caller('TARGET', 'RDirs'), } diff --git a/src/engine/SCons/Defaults.xml b/src/engine/SCons/Defaults.xml index 837dd639..71f2f218 100644 --- a/src/engine/SCons/Defaults.xml +++ b/src/engine/SCons/Defaults.xml @@ -71,16 +71,12 @@ env.PDF(target = 'bbb', source = 'bbb.dvi') -A function used to produce variables like &cv-_CPPINCFLAGS;. -It takes four to seven arguments: -a prefix to concatenate onto each element; -a list of elements; -a suffix to concatenate onto each element; -an environment for variable interpolation; -an optional function that will be -called to transform the list before concatenation; -a target or list of targets; -and a source or list of sources. +A function used to produce variables like &cv-_CPPINCFLAGS;. It takes +four or five +arguments: a prefix to concatenate onto each element, a list of +elements, a suffix to concatenate onto each element, an environment +for variable interpolation, and an optional function that will be +called to transform the list before concatenation. env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)', @@ -239,6 +235,20 @@ env = Environment(CCCOM="my_compiler $_CPPINCFLAGS -c -o $TARGET $SOURCE") + + +A function that converts a string +into a Dir instance relative to the target being built. + + + + + +A function that converts a list of strings +into a list of Dir instances relative to the target being built. + + + The list of suffixes of files that will be scanned @@ -251,6 +261,13 @@ The default list is: + + +A function that converts a string into a File instance relative to the +target being built. + + + The list of suffixes of files that will be scanned @@ -473,3 +490,10 @@ The prefix used for PDF file names. The suffix used for PDF file names. + + + +A function that converts a string into a list of Dir instances by +searching the repositories. + + diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index dbe77492..d073d539 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1614,6 +1614,11 @@ class File(Base): the SConscript directory of this file.""" return self.fs.Dir(name, self.cwd) + def Dirs(self, pathlist): + """Create a list of directories relative to the SConscript + directory of this file.""" + return map(lambda p, s=self: s.Dir(p), pathlist) + def File(self, name): """Create a file node named 'name' relative to the SConscript directory of this file.""" diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index a8b5b6d3..c8c8ad79 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1808,6 +1808,23 @@ class EntryTestCase(_tempdirTestCase): self.fs.Entry('#topdir') self.fs.Entry('#topdir/a/b/c') + + +class FileTestCase(_tempdirTestCase): + + def test_Dirs(self): + """Test the File.Dirs() method""" + fff = self.fs.File('subdir/fff') + # This simulates that the SConscript file that defined + # fff is in subdir/. + fff.cwd = self.fs.Dir('subdir') + d1 = self.fs.Dir('subdir/d1') + d2 = self.fs.Dir('subdir/d2') + dirs = fff.Dirs(['d1', 'd2']) + assert dirs == [d1, d2], map(str, dirs) + + + class RepositoryTestCase(_tempdirTestCase): def setUp(self): @@ -2798,6 +2815,7 @@ if __name__ == "__main__": BaseTestCase, BuildInfoTestCase, EntryTestCase, + FileTestCase, NodeInfoTestCase, FSTestCase, DirTestCase,