diff options
author | Steven Knight <knight@baldmt.com> | 2005-08-13 19:09:11 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2005-08-13 19:09:11 (GMT) |
commit | b3ca0cc97e059fef06657862492c2d285617a9e5 (patch) | |
tree | deb438a6f6be998a4f70d0af8cdb937fc2788e51 /src | |
parent | dc6f5a2d7ee951962f6e29cb15ed70c0186cdfee (diff) | |
download | SCons-b3ca0cc97e059fef06657862492c2d285617a9e5.zip SCons-b3ca0cc97e059fef06657862492c2d285617a9e5.tar.gz SCons-b3ca0cc97e059fef06657862492c2d285617a9e5.tar.bz2 |
Add a Dirs() function that can be used in hBcexpansions. (Stanislav Baranov)
Diffstat (limited to 'src')
-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 |
4 files changed, 58 insertions, 10 deletions
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, |