Handle Visual Studio project and solution files in Unicode. (Chen Lee)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 13 Aug 2005 15:33:43 +0000 (15:33 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 13 Aug 2005 15:33:43 +0000 (15:33 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1326 fdb21ef1-2011-0410-befe-b5e4ea1792b1

15 files changed:
doc/man/scons.1
etc/TestSCons.py
src/CHANGES.txt
src/engine/SCons/Defaults.py
src/engine/SCons/Defaults.xml
src/engine/SCons/Tool/dmd.py
src/engine/SCons/Tool/f77.py
src/engine/SCons/Tool/f90.py
src/engine/SCons/Tool/f95.py
src/engine/SCons/Tool/fortran.py
src/engine/SCons/Tool/mingw.py
src/engine/SCons/Tool/msvc.py
test/CPPPATH.py
test/Fortran/F77PATH.py
test/Fortran/F90PATH.py

index 5db1f53ad0e45c6eba1656a18281b571abc47a72..a1fc076b370ef8fbfe81dd83e861e34ec1fe153e 100644 (file)
@@ -4882,15 +4882,19 @@ 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 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)} $)',
+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)} $)',
 .EE
 
 .IP CPPDEFINES
index fec51a479742deaba1dad26a1ef88dd9b2ea93aa..7fd76d2b5e510342660c0b9a7931fc3551870eda 100644 (file)
@@ -162,12 +162,14 @@ class TestSCons(TestCommon):
         used as prog.
         """
         env = self.Environment(ENV)
-        try:
-            if prog is None:
-                prog = env[var]
-            return env[var] == prog and env.WhereIs(prog)
-        except KeyError:
+        v = env.subst('$'+var)
+        if not v:
+            return None
+        if prog is None:
+            prog = v
+        if v != prog:
             return None
+        return env.WhereIs(prog)
 
     def detect_tool(self, tool, prog=None, ENV=None):
         """
index b01a41dfd40d43c02cbdda0ea9caa48467016a5f..e575de329a49ec79473d8da1e9217bd2bac2406f 100644 (file)
@@ -42,6 +42,8 @@ RELEASE 0.97 - XXX
 
   - Allow Builders to take empty source lists when called.
 
+  - Allow access to both TARGET and SOURCE in $*PATH expansions.
+
   From Timothee Besset:
 
   - Add support for Objective C/C++ .m and .mm file suffixes (for
index 44d10fa56e873562085edee7881e5b92f7541a3a..e8df84febb573cbe2f0917f69a5e1ab2135e5d83 100644 (file)
@@ -193,7 +193,7 @@ def copyFunc(dest, source, env):
     os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
     return 0
 
-def _concat(prefix, list, suffix, env, f=lambda x: x, target=None):
+def _concat(prefix, list, suffix, env, f=lambda x: x, target=None, source=None):
     """Creates a new list from 'list' by first interpolating each
     element in the list using the 'env' dictionary and then calling f
     on the list, and finally concatenating 'prefix' and 'suffix' onto
@@ -206,7 +206,7 @@ def _concat(prefix, list, suffix, env, f=lambda x: x, target=None):
 
     if SCons.Util.is_List(list):
         list = SCons.Util.flatten(list)
-    list = f(env.subst_path(list, target=target))
+    list = f(env.subst_path(list, target=target, source=source))
 
     result = []
 
@@ -359,8 +359,8 @@ ConstructionEnvironment = {
     '_defines'      : _defines,
     '_stripixes'    : _stripixes,
     '_LIBFLAGS'     : '${_concat(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, __env__)}',
-    '_LIBDIRFLAGS'  : '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET)} $)',
-    '_CPPINCFLAGS'  : '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET)} $)',
+    '_LIBDIRFLAGS'  : '$( ${_concat(LIBDIRPREFIX, LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)',
+    '_CPPINCFLAGS'  : '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)',
     '_CPPDEFFLAGS'  : '${_defines(CPPDEFPREFIX, CPPDEFINES, CPPDEFSUFFIX, __env__)}',
     'TEMPFILE'      : NullCmdGenerator,
     'Dir'           : Variable_Method_Caller('TARGET', 'Dir'),
index 8d90ce29e157bae3ae77aeb4d8691fc7a7aa323f..837dd6398f346e68a336503b9aed78de4e623311 100644 (file)
@@ -71,12 +71,16 @@ env.PDF(target = 'bbb', source = 'bbb.dvi')
 
 <cvar name ="_concat">
 <summary>
-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.
+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.
 
 <example>
 env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)',
index 13f58a105488466a8fc3b5bc6a1a830ac08fc4d2..d850ab141bdda55e2439441595dd2e940be6a4c5 100644 (file)
@@ -95,7 +95,7 @@ def generate(env):
 
     env['DC'] = 'dmd'
     env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -of$TARGET $SOURCES'
-    env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET)}  $)'
+    env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}  $)'
     env['_DVERFLAGS'] = '$( ${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)}  $)'
     env['_DDEBUGFLAGS'] = '$( ${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)} $)'
     env['_DFLAGS'] = '$( ${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)} $)'
@@ -132,7 +132,7 @@ def generate(env):
         env['DLIB'] = 'lib'
         env['DLIBCOM'] = '$DLIB $_DLIBFLAGS -c $TARGET $SOURCES $_DLINKLIBFLAGS'
 
-        env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET)} $)'
+        env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
         env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
         env['DLINKFLAGS'] = []
         env['DLIBLINKPREFIX'] = ''
index d5acbb3cb947c0a98b63486da3e856c7473cc4a2..75c3c2dd129a10dc52b533dc6500d453689b36a1 100644 (file)
@@ -111,12 +111,12 @@ def add_to_env(env):
     env['_SHF77COMSTRG']    = ShF77CommandStrGenerator
     env['_SHF77PPCOMSTRG']  = ShF77PPCommandStrGenerator
 
-    env['_F77INCFLAGS'] = '$( ${_concat(INCPREFIX, F77PATH, INCSUFFIX, __env__, RDirs, TARGET)} $)'
+    env['_F77INCFLAGS'] = '$( ${_concat(INCPREFIX, F77PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
 
-    env['_F77COMD']     = '$_F77G $_F77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES'
-    env['_F77PPCOMD']   = '$_F77G $_F77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES'
-    env['_SHF77COMD']   = '$_SHF77G $_SHF77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES'
-    env['_SHF77PPCOMD'] = '$_SHF77G $_SHF77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES'
+    env['_F77COMD']     = '$_F77G -o $TARGET -c $_F77FLAGSG $_F77INCFLAGS $SOURCES'
+    env['_F77PPCOMD']   = '$_F77G -o $TARGET -c $_F77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS $SOURCES'
+    env['_SHF77COMD']   = '$_SHF77G -o $TARGET -c $_SHF77FLAGSG $_F77INCFLAGS $SOURCES'
+    env['_SHF77PPCOMD'] = '$_SHF77G -o $TARGET -c $_SHF77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS $SOURCES'
 
 def generate(env):
     fortran.add_to_env(env)
index 447497f6098bdf6311d8b9f75c5510a64a73b13e..2e2b5b114fc0ba5ed98a751afc4ea040d718e815 100644 (file)
@@ -111,11 +111,11 @@ def add_to_env(env):
     env['_SHF90PPCOMG']     = ShF90PPCommandGenerator
     env['_SHF90PPCOMSTRG']  = ShF90PPCommandStrGenerator
 
-    env['_F90INCFLAGS'] = '$( ${_concat(INCPREFIX, F90PATH, INCSUFFIX, __env__, RDirs, TARGET)} $)'
-    env['_F90COMD']     = '$_F90G $_F90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_F90PPCOMD']   = '$_F90G $_F90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_SHF90COMD']   = '$_SHF90G $_SHF90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_SHF90PPCOMD'] = '$_SHF90G $_SHF90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+    env['_F90INCFLAGS'] = '$( ${_concat(INCPREFIX, F90PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+    env['_F90COMD']     = '$_F90G -o $TARGET -c $_F90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_F90PPCOMD']   = '$_F90G -o $TARGET -c $_F90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_SHF90COMD']   = '$_SHF90G -o $TARGET -c $_SHF90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_SHF90PPCOMD'] = '$_SHF90G -o $TARGET -c $_SHF90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
 
 def generate(env):
     fortran.add_to_env(env)
index bc3ece30a501c2713a3593e0ba2894182b1bb8f0..9cd2664cb3570a5e9d5b29db4c87d9570a618295 100644 (file)
@@ -110,12 +110,12 @@ def add_to_env(env):
     env['_SHF95PPCOMG']    = ShF95PPCommandGenerator
     env['_SHF95PPCOMSTRG'] = ShF95PPCommandStrGenerator
 
-    env['_F95INCFLAGS'] = '$( ${_concat(INCPREFIX, F95PATH, INCSUFFIX, __env__, RDirs, TARGET)} $)'
+    env['_F95INCFLAGS'] = '$( ${_concat(INCPREFIX, F95PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
 
-    env['_F95COMD']     = '$_F95G $_F95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_F95PPCOMD']   = '$_F95G $_F95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_SHF95COMD']   = '$_SHF95G $_SHF95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_SHF95PPCOMD'] = '$_SHF95G $_SHF95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+    env['_F95COMD']     = '$_F95G -o $TARGET -c $_F95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_F95PPCOMD']   = '$_F95G -o $TARGET -c $_F95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_SHF95COMD']   = '$_SHF95G -o $TARGET -c $_SHF95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_SHF95PPCOMD'] = '$_SHF95G -o $TARGET -c $_SHF95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
 
 def generate(env):
     fortran.add_to_env(env)
index d559ac8ed688e5c214bea7e9093354eed551f407..b694a58c2e97bd23518cd2ca4840ae8ee5d376dd 100644 (file)
@@ -138,7 +138,7 @@ def add_to_env(env):
     env['_SHFORTRANPPCOMG']     = ShFortranPPCommandGenerator
     env['_SHFORTRANPPCOMSTRG']  = ShFortranPPCommandStrGenerator
 
-    env['_FORTRANINCFLAGS'] = '$( ${_concat(INCPREFIX, FORTRANPATH, INCSUFFIX, __env__, RDirs, TARGET)} $)'
+    env['_FORTRANINCFLAGS'] = '$( ${_concat(INCPREFIX, FORTRANPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
 
     env['FORTRANMODPREFIX'] = ''     # like $LIBPREFIX
     env['FORTRANMODSUFFIX'] = '.mod' # like $LIBSUFFIX
@@ -164,10 +164,10 @@ def add_to_env(env):
         static_obj.add_emitter(suffix, FortranEmitter)
         shared_obj.add_emitter(suffix, ShFortranEmitter)
 
-    env['_FORTRANCOMD']     = '$_FORTRANG $_FORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_FORTRANPPCOMD']   = '$_FORTRANG $_FORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_SHFORTRANCOMD']   = '$_SHFORTRANG $_SHFORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
-    env['_SHFORTRANPPCOMD'] = '$_SHFORTRANG $_SHFORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES'
+    env['_FORTRANCOMD']     = '$_FORTRANG -o $TARGET -c $_FORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_FORTRANPPCOMD']   = '$_FORTRANG -o $TARGET -c $_FORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_SHFORTRANCOMD']   = '$_SHFORTRANG -o $TARGET -c $_SHFORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
+    env['_SHFORTRANPPCOMD'] = '$_SHFORTRANG -o $TARGET -c $_SHFORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
 
 def generate(env):
     import f77
index c8b044be0671cb76a4c781f72af5d980b8d6b25d..2e737e14c64937971878a00e0e6a05c959deb18f 100644 (file)
@@ -139,7 +139,7 @@ def generate(env):
 
     env['RC'] = 'windres'
     env['RCFLAGS'] = SCons.Util.CLVar('')
-    env['RCINCFLAGS'] = '$( ${_concat(RCINCPREFIX, CPPPATH, RCINCSUFFIX, __env__, RDirs, TARGET)} $)'
+    env['RCINCFLAGS'] = '$( ${_concat(RCINCPREFIX, CPPPATH, RCINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
     env['RCINCPREFIX'] = '--include-dir '
     env['RCINCSUFFIX'] = ''
     env['RCCOM'] = '$RC $RCINCFLAGS $RCINCPREFIX ${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
index b47f331a61f0f0fcfe65c064ee91c31390589506..1077931e2c99ff8861306c32acb64059ff747265 100644 (file)
@@ -71,10 +71,24 @@ def _parse_msvc7_overrides(version):
         # now we parse the directories from this file, if it exists.
         # We only look for entries after: [VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories],
         # since this file could contain a number of things...
-        f = open(comps,'r')
-        line = f.readline()
+        lines = None
+        try:
+            import codecs
+        except ImportError:
+            pass
+        else:
+            try:
+                f = codecs.open(comps, 'r', 'utf16')
+                encoder = codecs.getencoder('ascii')
+            except LookupError:
+                lines = codecs.open(comps, 'r', 'utf8').readlines()
+            else:
+                lines = map(lambda l, e=encoder: e(l)[0], f.readlines())
+        if lines is None:
+            lines = open(comps, 'r').readlines()
+            
         found = 0
-        while line:
+        for line in lines:
             line.strip()
             if line.find(r'[VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]') >= 0:
                 found = 1
@@ -86,7 +100,6 @@ def _parse_msvc7_overrides(version):
                     (key, val) = kv
                 key = key.replace(' Dirs','')
                 dirs[key.upper()] = val
-            line = f.readline()
         f.close()
     else:
         # since the file didn't exist, we have only the defaults in
@@ -143,7 +156,7 @@ def _get_msvc7_path(path, version, platform):
 
     rv = []
     for entry in p.split(os.pathsep):
-        entry = s.sub(repl,entry)
+        entry = s.sub(repl,entry).rstrip('\n\r')
         rv.append(entry)
 
     return string.join(rv,os.pathsep)
index 6b41a38a01267100b24ea65ba413870931488d31..9ce5e153a0361430009fcf29fb9c861a29bdceaf 100644 (file)
@@ -38,10 +38,14 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog
 
 test = TestSCons.TestSCons()
 
-test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
+test.subdir('foobar',
+            'include',
+            'subdir',
+            ['subdir', 'include'],
+            'inc2')
 
 test.write('SConstruct', """
-env = Environment(CPPPATH = ['$FOO'],
+env = Environment(CPPPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
                   FOO='include')
 obj = env.Object(target='foobar/prog', source='subdir/prog.c')
 env.Program(target='prog', source=obj)
@@ -49,7 +53,7 @@ SConscript('subdir/SConscript', "env")
 
 BuildDir('variant', 'subdir', 0)
 include = Dir('include')
-env = Environment(CPPPATH=[include])
+env = Environment(CPPPATH=[include, '#foobar', '#subdir'])
 SConscript('variant/SConscript', "env")
 """)
 
@@ -70,9 +74,26 @@ r"""
 #define BAR_STRING "include/bar.h 1\n"
 """)
 
+test.write(['subdir', 'sss.h'],
+r"""
+#define SSS_STRING      "subdir/sss.h\n"
+""")
+
+test.write(['foobar', 'ttt.h'],
+r"""
+#define TTT_STRING      "foobar/ttt.h\n"
+""")
+
+test.write(['subdir', 'ttt.h'],
+r"""
+#define TTT_STRING      "subdir/ttt.h\n"
+""")
+
 test.write(['subdir', 'prog.c'],
 r"""
 #include <foo.h>
+#include <sss.h>
+#include <ttt.h>
 #include <stdio.h>
 
 int
@@ -82,6 +103,8 @@ main(int argc, char *argv[])
     printf("subdir/prog.c\n");
     printf(FOO_STRING);
     printf(BAR_STRING);
+    printf(SSS_STRING);
+    printf(TTT_STRING);
     return 0;
 }
 """)
@@ -102,13 +125,33 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = "subdir/prog.c\ninclude/foo.h 1\ninclude/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+include/foo.h 1
+include/bar.h 1
+subdir/sss.h
+foobar/ttt.h
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+subdir/include/foo.h 1
+subdir/include/bar.h 1
+subdir/sss.h
+subdir/ttt.h
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = "subdir/prog.c\ninclude/foo.h 1\ninclude/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+include/foo.h 1
+include/bar.h 1
+subdir/sss.h
+foobar/ttt.h
+""")
+
+
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
 test.fail_test(os.path.exists(test.workpath('variant', 'prog.c')))
@@ -124,19 +167,41 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+include/foo.h 2
+include/bar.h 1
+subdir/sss.h
+foobar/ttt.h
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+subdir/include/foo.h 1
+subdir/include/bar.h 1
+subdir/sss.h
+subdir/ttt.h
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+include/foo.h 2
+include/bar.h 1
+subdir/sss.h
+foobar/ttt.h
+""")
+
+
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
 test.fail_test(os.path.exists(test.workpath('variant', 'prog.c')))
 
 test.up_to_date(arguments = args)
 
+
+
 #
 test.write(['include', 'bar.h'],
 r"""
@@ -146,34 +211,56 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 2\n")
+         stdout = """\
+subdir/prog.c
+include/foo.h 2
+include/bar.h 2
+subdir/sss.h
+foobar/ttt.h
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+subdir/include/foo.h 1
+subdir/include/bar.h 1
+subdir/sss.h
+subdir/ttt.h
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 2\n")
+         stdout = """\
+subdir/prog.c
+include/foo.h 2
+include/bar.h 2
+subdir/sss.h
+foobar/ttt.h
+""")
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
 test.fail_test(os.path.exists(test.workpath('variant', 'prog.c')))
 
 test.up_to_date(arguments = args)
 
+
+
 # Change CPPPATH and make sure we don't rebuild because of it.
 test.write('SConstruct', """
-env = Environment(CPPPATH = Split('inc2 include'))
+env = Environment(CPPPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'))
 obj = env.Object(target='foobar/prog', source='subdir/prog.c')
 env.Program(target='prog', source=obj)
 SConscript('subdir/SConscript', "env")
 
 BuildDir('variant', 'subdir', 0)
 include = Dir('include')
-env = Environment(CPPPATH=['inc2', include])
+env = Environment(CPPPATH=['inc2', include, '#foobar', '#subdir'])
 SConscript('variant/SConscript', "env")
 """)
 
 test.up_to_date(arguments = args)
 
+
+
 #
 test.write(['inc2', 'foo.h'],
 r"""
@@ -184,16 +271,36 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = "subdir/prog.c\ninc2/foo.h 1\ninclude/bar.h 2\n")
+         stdout = """\
+subdir/prog.c
+inc2/foo.h 1
+include/bar.h 2
+subdir/sss.h
+foobar/ttt.h
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n")
+         stdout = """\
+subdir/prog.c
+subdir/include/foo.h 1
+subdir/include/bar.h 1
+subdir/sss.h
+subdir/ttt.h
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 2\n")
+         stdout = """\
+subdir/prog.c
+include/foo.h 2
+include/bar.h 2
+subdir/sss.h
+foobar/ttt.h
+""")
 
 test.up_to_date(arguments = args)
 
+
+
 # Check that neither a null-string CPPPATH nor a
 # a CPPPATH containing null values blows up.
 test.write('SConstruct', """
@@ -213,4 +320,6 @@ test.run(arguments = '.',
          stderr=TestSCons.noisy_ar,
          match=TestSCons.match_re_dotall)
 
+
+
 test.pass_test()
index 4308bed8da7cd1403747735b4378a7d32d9db9ac..2869d27f04fd17738396f8d2cd1d86c2c0edcd2d 100644 (file)
@@ -34,62 +34,85 @@ prog = 'prog' + _exe
 subdir_prog = os.path.join('subdir', 'prog' + _exe)
 variant_prog = os.path.join('variant', 'prog' + _exe)
 
-args = prog + ' ' + subdir_prog + ' ' + variant_prog
+args = prog + ' ' + variant_prog + ' ' + subdir_prog
 
 test = TestSCons.TestSCons()
 
-if not test.detect('F77', 'g77'):
+if not test.detect('_F77G', 'g77'):
     test.skip_test('Found no $F77 tool; skipping test.\n')
     
-test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
+test.subdir('include',
+            'subdir',
+            ['subdir', 'include'],
+            'foobar',
+            'inc2')
+
+
 
 test.write('SConstruct', """
-env = Environment(F77PATH = ['$FOO'], LIBS = %s, FOO='include')
-obj = env.Object(target='foobar/prog', source='subdir/prog.f')
+env = Environment(F77PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
+                  LIBS = %s,
+                  FOO='include',
+                  F77FLAGS = '-x f77')
+obj = env.Object(target='foobar/prog', source='subdir/prog.f77')
 env.Program(target='prog', source=obj)
 SConscript('subdir/SConscript', "env")
 
 BuildDir('variant', 'subdir', 0)
 include = Dir('include')
-env = Environment(F77PATH=[include], LIBS = %s)
+env = Environment(F77PATH=[include, '#foobar', '#subdir'],
+                  LIBS = %s,
+                  F77FLAGS = '-x f77')
 SConscript('variant/SConscript', "env")
 """ % (FTN_LIB, FTN_LIB))
 
 test.write(['subdir', 'SConscript'],
 """
 Import("env")
-env.Program(target='prog', source='prog.f')
+env.Program(target='prog', source='prog.f77')
 """)
 
-test.write(['include', 'foo.f'],
+test.write(['include', 'foo.f77'],
 r"""
-      PRINT *, 'include/foo.f 1'
-      INCLUDE 'bar.f'
+      PRINT *, 'include/foo.f77 1'
+      INCLUDE 'bar.f77'
 """)
 
-test.write(['include', 'bar.f'],
+test.write(['include', 'bar.f77'],
 r"""
-      PRINT *, 'include/bar.f 1'
+      PRINT *, 'include/bar.f77 1'
 """)
 
-test.write(['subdir', 'prog.f'],
+test.write(['subdir', 'prog.f77'],
 r"""
       PROGRAM PROG
-      PRINT *, 'subdir/prog.f'
-      include 'foo.f'
+      PRINT *, 'subdir/prog.f77'
+      include 'foo.f77'
+      include 'sss.f77'
+      include 'ttt.f77'
       STOP
       END
 """)
 
-test.write(['subdir', 'include', 'foo.f'],
+test.write(['subdir', 'include', 'foo.f77'],
+r"""
+      PRINT *, 'subdir/include/foo.f77 1'
+      INCLUDE 'bar.f77'
+""")
+
+test.write(['subdir', 'include', 'bar.f77'],
+r"""
+      PRINT *, 'subdir/include/bar.f77 1'
+""")
+
+test.write(['subdir', 'sss.f77'],
 r"""
-      PRINT *, 'subdir/include/foo.f 1'
-      INCLUDE 'bar.f'
+      PRINT *, 'subdir/sss.f77'
 """)
 
-test.write(['subdir', 'include', 'bar.f'],
+test.write(['subdir', 'ttt.f77'],
 r"""
-      PRINT *, 'subdir/include/bar.f 1'
+      PRINT *, 'subdir/ttt.f77'
 """)
 
 
@@ -97,106 +120,192 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f\n include/foo.f 1\n include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ include/foo.f77 1
+ include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ subdir/include/foo.f77 1
+ subdir/include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f\n include/foo.f 1\n include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ include/foo.f77 1
+ include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
-test.must_not_exist(test.workpath('variant', 'prog.f'))
+test.must_not_exist(test.workpath('variant', 'prog.f77'))
 
 test.up_to_date(arguments = args)
 
-test.write(['include', 'foo.f'],
+
+
+test.write(['include', 'foo.f77'],
 r"""
-      PRINT *, 'include/foo.f 2'
-      INCLUDE 'bar.f'
+      PRINT *, 'include/foo.f77 2'
+      INCLUDE 'bar.f77'
 """)
 
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ include/foo.f77 2
+ include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ subdir/include/foo.f77 1
+ subdir/include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ include/foo.f77 2
+ include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
-test.must_not_exist(test.workpath('variant', 'prog.f'))
+test.must_not_exist(test.workpath('variant', 'prog.f77'))
 
 test.up_to_date(arguments = args)
 
+
+
 #
-test.write(['include', 'bar.f'],
+test.write(['include', 'bar.f77'],
 r"""
-      PRINT *, 'include/bar.f 2'
+      PRINT *, 'include/bar.f77 2'
 """)
 
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n")
+         stdout = """\
+ subdir/prog.f77
+ include/foo.f77 2
+ include/bar.f77 2
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ subdir/include/foo.f77 1
+ subdir/include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n")
+         stdout = """\
+ subdir/prog.f77
+ include/foo.f77 2
+ include/bar.f77 2
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
-test.must_not_exist(test.workpath('variant', 'prog.f'))
+test.must_not_exist(test.workpath('variant', 'prog.f77'))
 
 test.up_to_date(arguments = args)
 
+
+
 # Change F77PATH and make sure we don't rebuild because of it.
 test.write('SConstruct', """
-env = Environment(F77PATH = Split('inc2 include'), LIBS = %s)
-obj = env.Object(target='foobar/prog', source='subdir/prog.f')
+env = Environment(F77PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
+                  LIBS = %s,
+                  F77FLAGS = '-x f77')
+obj = env.Object(target='foobar/prog', source='subdir/prog.f77')
 env.Program(target='prog', source=obj)
 SConscript('subdir/SConscript', "env")
 
 BuildDir('variant', 'subdir', 0)
 include = Dir('include')
-env = Environment(F77PATH=['inc2', include], LIBS = %s)
+env = Environment(F77PATH=['inc2', include, '#foobar', '#subdir'],
+                  LIBS = %s,
+                  F77FLAGS = '-x f77')
 SConscript('variant/SConscript', "env")
 """ % (FTN_LIB, FTN_LIB))
 
 test.up_to_date(arguments = args)
 
 #
-test.write(['inc2', 'foo.f'],
+test.write(['inc2', 'foo.f77'],
 r"""
-      PRINT *, 'inc2/foo.f 1'
-      INCLUDE 'bar.f'
+      PRINT *, 'inc2/foo.f77 1'
+      INCLUDE 'bar.f77'
 """)
 
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f\n inc2/foo.f 1\n include/bar.f 2\n")
+         stdout = """\
+ subdir/prog.f77
+ inc2/foo.f77 1
+ include/bar.f77 2
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f\n subdir/include/foo.f 1\n subdir/include/bar.f 1\n")
+         stdout = """\
+ subdir/prog.f77
+ subdir/include/foo.f77 1
+ subdir/include/bar.f77 1
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f\n include/foo.f 2\n include/bar.f 2\n")
+         stdout = """\
+ subdir/prog.f77
+ include/foo.f77 2
+ include/bar.f77 2
+ subdir/sss.f77
+ subdir/ttt.f77
+""")
 
 test.up_to_date(arguments = args)
 
+
+
 # Check that a null-string F77PATH doesn't blow up.
 test.write('SConstruct', """
-env = Environment(F77PATH = '', LIBS = %s)
-env.Library('foo', source = 'empty.f')
+env = Environment(F77PATH = '', LIBS = %s, F77FLAGS = '-x f77')
+env.Object('foo', source = 'empty.f77')
 """ % FTN_LIB)
 
-test.write('empty.f', '')
+test.write('empty.f77', '')
 
 test.run(arguments = '.')
 
+
+
 test.pass_test()
index c1b6f49005c8ba22a0ead06f669a38d56999c118..87ddda135a3e6c675b3c18a03f49a7b10c4a481a 100644 (file)
@@ -58,11 +58,17 @@ LIBPATH = os.path.join(base, 'lib')
 LIBS = ['irc']
 os.environ['LD_LIBRARY_PATH'] = LIBPATH
     
-test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
+test.subdir('include',
+            'subdir',
+            ['subdir', 'include'],
+            'foobar',
+            'inc2')
+
+
 
 test.write('SConstruct', """
 env = Environment(F90 = r'%s',
-                  F90PATH = ['$FOO'],
+                  F90PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
                   LINK = '$F90',
                   LIBPATH = %s,
                   LIBS = %s,
@@ -74,7 +80,7 @@ SConscript('subdir/SConscript', "env")
 BuildDir('variant', 'subdir', 0)
 include = Dir('include')
 env = Environment(F90 = r'%s',
-                  F90PATH=[include],
+                  F90PATH=[include, '#foobar', '#subdir'],
                   LINK = '$F90',
                   LIBPATH = %s,
                   LIBS = %s)
@@ -103,6 +109,8 @@ r"""
       PROGRAM PROG
       PRINT *, 'subdir/prog.f90'
       include 'foo.f90'
+      include 'sss.f90'
+      include 'ttt.f90'
       STOP
       END
 """)
@@ -118,24 +126,54 @@ r"""
       PRINT *, 'subdir/include/bar.f90 1'
 """)
 
+test.write(['subdir', 'sss.f90'],
+r"""
+      PRINT *, 'subdir/sss.f90'
+""")
+
+test.write(['subdir', 'ttt.f90'],
+r"""
+      PRINT *, 'subdir/ttt.f90'
+""")
+
 
 
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f90\n include/foo.f90 1\n include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ include/foo.f90 1
+ include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f90\n subdir/include/foo.f90 1\n subdir/include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ subdir/include/foo.f90 1
+ subdir/include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f90\n include/foo.f90 1\n include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ include/foo.f90 1
+ include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
 test.must_not_exist(test.workpath('variant', 'prog.f90'))
 
 test.up_to_date(arguments = args)
 
+
+
 test.write(['include', 'foo.f90'],
 r"""
       PRINT *, 'include/foo.f90 2'
@@ -145,19 +183,39 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f90\n include/foo.f90 2\n include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ include/foo.f90 2
+ include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f90\n subdir/include/foo.f90 1\n subdir/include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ subdir/include/foo.f90 1
+ subdir/include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f90\n include/foo.f90 2\n include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ include/foo.f90 2
+ include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
 test.must_not_exist(test.workpath('variant', 'prog.f90'))
 
 test.up_to_date(arguments = args)
 
+
+
 #
 test.write(['include', 'bar.f90'],
 r"""
@@ -167,23 +225,43 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f90\n include/foo.f90 2\n include/bar.f90 2\n")
+         stdout = """\
+ subdir/prog.f90
+ include/foo.f90 2
+ include/bar.f90 2
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f90\n subdir/include/foo.f90 1\n subdir/include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ subdir/include/foo.f90 1
+ subdir/include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f90\n include/foo.f90 2\n include/bar.f90 2\n")
+         stdout = """\
+ subdir/prog.f90
+ include/foo.f90 2
+ include/bar.f90 2
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 # Make sure we didn't duplicate the source file in the variant subdirectory.
 test.must_not_exist(test.workpath('variant', 'prog.f90'))
 
 test.up_to_date(arguments = args)
 
+
+
 # Change F90PATH and make sure we don't rebuild because of it.
 test.write('SConstruct', """
 env = Environment(F90 = r'%s',
-                  F90PATH = Split('inc2 include'),
+                  F90PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
                   LINK = '$F90',
                   LIBPATH = %s,
                   LIBS = %s)
@@ -194,7 +272,7 @@ SConscript('subdir/SConscript', "env")
 BuildDir('variant', 'subdir', 0)
 include = Dir('include')
 env = Environment(F90 = r'%s',
-                  F90PATH=['inc2', include],
+                  F90PATH=['inc2', include, '#foobar', '#subdir'],
                   LINK = '$F90',
                   LIBPATH = %s,
                   LIBS = %s)
@@ -203,6 +281,8 @@ SConscript('variant/SConscript', "env")
 
 test.up_to_date(arguments = args)
 
+
+
 #
 test.write(['inc2', 'foo.f90'],
 r"""
@@ -213,14 +293,34 @@ r"""
 test.run(arguments = args)
 
 test.run(program = test.workpath(prog),
-         stdout = " subdir/prog.f90\n inc2/foo.f90 1\n include/bar.f90 2\n")
+         stdout = """\
+ subdir/prog.f90
+ inc2/foo.f90 1
+ include/bar.f90 2
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(subdir_prog),
-         stdout = " subdir/prog.f90\n subdir/include/foo.f90 1\n subdir/include/bar.f90 1\n")
+         stdout = """\
+ subdir/prog.f90
+ subdir/include/foo.f90 1
+ subdir/include/bar.f90 1
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.run(program = test.workpath(variant_prog),
-         stdout = " subdir/prog.f90\n include/foo.f90 2\n include/bar.f90 2\n")
+         stdout = """\
+ subdir/prog.f90
+ include/foo.f90 2
+ include/bar.f90 2
+ subdir/sss.f90
+ subdir/ttt.f90
+""")
 
 test.up_to_date(arguments = args)
 
+
+
 test.pass_test()