Commits

Anonymous committed 9f5f3e9

Add a Dirs() function that can be used in hBcexpansions. (Stanislav Baranov)

Comments (0)

Files changed (5)

 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.
-
-.ES
-env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)',
+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)} $)',
 .EE
 
 .IP CPPDEFINES
 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
 .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
 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

src/engine/SCons/Defaults.py

     '_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'),
 }

src/engine/SCons/Defaults.xml

 
 <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)} $)',
 </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
 </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
 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>

src/engine/SCons/Node/FS.py

         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."""

src/engine/SCons/Node/FSTests.py

         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):
         BaseTestCase,
         BuildInfoTestCase,
         EntryTestCase,
+        FileTestCase,
         NodeInfoTestCase,
         FSTestCase,
         DirTestCase,