Fix use of SConf with SConscriptChdir(). (David Snopek, Christoph Wiedemann)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 10 Jun 2003 14:48:53 +0000 (14:48 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 10 Jun 2003 14:48:53 +0000 (14:48 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@706 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/SConf.py
test/Configure.py

index b4d409c365ff133cdf9293715759e83d52fe75c8..b86c2dea24d5fc24cb68f81c670726b36307d44f 100644 (file)
 
 RELEASE 0.15 - XXX
 
-  From Matt Balvin:
-
-  - Fix handling of library prefixes when the subdirectory matches
-    the prefix.
-
-  From Timothee Bessett:
-
-  - Add an M4 Builder.
-
-  From Charles Crain:
-
-  - Use '.lnk' as the suffix on the temporary file for linking long
-    command lines (necessary for the Phar Lap linkloc linker).
-
   From Steven Knight:
 
   - SCons now enforces (with an error) that construction variables
@@ -35,27 +21,10 @@ RELEASE 0.15 - XXX
   - Eliminate a dependency on the distutils.fancy_getopt module by
     copying and pasting its wrap_text() function directly.
 
-  - Make the Script.Options() subclass match the underlying base class
-    implementation.
-
-  From Steve Leblanc:
-
-  - Don't update the .sconsign files when run with -n.
-
   From David Snopek and Christoph Wiedemann
 
   - Fix use of the SConf subsystem with SConscriptChdir().
 
-  From Greg Spencer
-
-  - Check for the existence of MS Visual Studio on disk before using it,
-    to avoid getting fooled by leftover junk in the registry.
-
-  - Add support for MSVC++ .NET.
-
-  - Add support for MS Visual Studio project files (DSP, DSW,
-    SLN and VCPROJ files).
-
 
 
 RELEASE 0.14 - Wed, 21 May 2003 05:16:32 -0500
index 1546fb119c39b9d31707147c66fd0cd716229b1f..d01ce7ec29708c67c19631d15bf3c8676fb8a410 100644 (file)
@@ -163,6 +163,11 @@ class SConf:
             sys.stdout = self.logstream
             oldStderr = sys.stderr
             sys.stderr = self.logstream
+
+        # the engine assumes the current path is the SConstruct directory ...
+        oldcwd = os.getcwd()
+        os.chdir(SConfFS.pathTop)
+
         self._setCache( nodes ) 
         ret = 1
 
@@ -190,6 +195,7 @@ class SConf:
                     # the node could not be built. we return 0 in this case
                     ret = 0
         finally:
+            os.chdir(oldcwd)
             if self.logstream != None:
                 # restore stdout / stderr
                 sys.stdout = oldStdout
index 97333ab489df54ea08e04aee481fa049773364c6..eeb040d762099764351a24d3d243fc2ad82eaf1e 100644 (file)
@@ -27,6 +27,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import os
 import re
 import sys
+import shutil
 
 import TestCmd
 import TestSCons
@@ -64,7 +65,7 @@ def checkLog( test, logfile, numUpToDate, numCache ):
         test.fail_test( len( re.findall( "is up to date", log ) ) != numUpToDate )
         test.fail_test( len( re.findall( "\(cached\): Building \S+ failed in a previous run.", log ) ) != numCache )
     except:
-        #print "contents of log ", test.workpath(logfile), "\n", log
+        print "contents of log ", test.workpath(logfile), "\n", log
         raise 
 
 
@@ -218,10 +219,16 @@ Checking for C header no_std_c_header.h ... failed
     # 2.3 test that Configure calls in SConscript files work
     #     even if BuildDir is set
     reset()
-    
 
     test.subdir( 'sub' )
     test.write( 'SConstruct', """
+opts = Options()
+opts.Add('chdir')
+env = Environment(options=opts)
+if env['chdir'] == 'yes':
+  SConscriptChdir(1)
+else:
+  SConscriptChdir(0)
 BuildDir( 'build', '.' )
 SConscript( 'build/SConscript' )
 """)
@@ -233,7 +240,10 @@ env = Environment()
 import os
 env['ENV']['PATH'] = os.environ['PATH']
 conf = Configure( env )
-conf.CheckCHeader( 'math.h' )
+if not conf.CheckCHeader( 'math.h' ):
+  Exit(1)
+if conf.CheckCHeader( 'no_std_c_header.h' ):
+  Exit(1)
 env = conf.Finish()
 env.Program( 'TestProgram', 'TestProgram.c' )
 """)
@@ -248,13 +258,34 @@ int main() {
   printf( "Hello\\n" );
 }
 """)
-    test.run()
+    required_stdout = test.wrap_stdout(build_str='.*',
+                                       read_str=
+    """Checking for C header math.h ... ok
+Checking for C header no_std_c_header.h ... failed
+""")
+    # first with SConscriptChdir(0)
+    test.run(stdout = required_stdout, arguments='chdir=no')
     checkFiles( test, [".sconf_temp/.cache", "config.log"] )
+    checkLog( test, 'config.log', 0, 0 )
+
+    test.run(stdout = required_stdout, arguments='chdir=no')
+    checkFiles( test, [".sconf_temp/.cache", "config.log"] )
+    checkLog( test, 'config.log', 3, 1 )
+
+    shutil.rmtree(test.workpath(".sconf_temp"))
+
+    # now with SConscriptChdir(1)
+    test.run(stdout = required_stdout, arguments='chdir=yes')
+    checkFiles( test, [".sconf_temp/.cache", "config.log"] )
+    checkLog( test, 'config.log', 0, 0 )
+
+    test.run(stdout = required_stdout, arguments='chdir=yes')
+    checkFiles( test, [".sconf_temp/.cache", "config.log"] )
+    checkLog( test, 'config.log', 3, 1 )
 
     # 3.1 test custom tests
     reset()
     
-
     compileOK = '#include <stdio.h>\\nint main() {printf("Hello");return 0;}'
     compileFAIL = "syntax error" 
     linkOK = compileOK