diff options
-rw-r--r-- | doc/man/scons.1 | 30 | ||||
-rw-r--r-- | src/engine/SCons/Defaults.py | 1 | ||||
-rw-r--r-- | src/engine/SCons/Defaults.xml | 44 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 5 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 18 |
5 files changed, 73 insertions, 25 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1 index a1fc076..96bd467 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 e8df84f..88a167a 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 837dd63..71f2f21 100644 --- a/src/engine/SCons/Defaults.xml +++ b/src/engine/SCons/Defaults.xml @@ -71,16 +71,12 @@ env.PDF(target = 'bbb', source = 'bbb.dvi') <cvar name ="_concat"> <summary> -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. <example> env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)', @@ -239,6 +235,20 @@ env = Environment(CCCOM="my_compiler $_CPPINCFLAGS -c -o $TARGET $SOURCE") </summary> </cvar> +<cvar name="Dir"> +<summary> +A function that converts a string +into a Dir instance relative to the target being built. +</summary> +</cvar> + +<cvar name="Dirs"> +<summary> +A function that converts a list of strings +into a list of Dir instances relative to the target being built. +</summary> +</cvar> + <cvar name="DSUFFIXES"> <summary> The list of suffixes of files that will be scanned @@ -251,6 +261,13 @@ The default list is: </summary> </cvar> +<cvar name="File"> +<summary> +A function that converts a string into a File instance relative to the +target being built. +</summary> +</cvar> + <cvar name="IDLSUFFIXES"> <summary> 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. </summary> </cvar> + +<cvar name="RDirs"> +<summary> +A function that converts a string into a list of Dir instances by +searching the repositories. +</summary> +</cvar> diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index dbe7749..d073d53 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 a8b5b6d..c8c8ad7 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, |