Fix SConf chdir'ing so it works with CPPPATH and LIBPATH. (David Snopek)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 18 Jun 2003 21:34:03 +0000 (21:34 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 18 Jun 2003 21:34:03 +0000 (21:34 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@719 fdb21ef1-2011-0410-befe-b5e4ea1792b1

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

index b62dabff83dfa11a0291f16b4338185b3272c363..fad2dfbd3af84198302e162968e582e725d3d952 100644 (file)
@@ -186,8 +186,9 @@ class SConf:
             sys.stderr = self.logstream
 
         # the engine assumes the current path is the SConstruct directory ...
-        oldcwd = os.getcwd()
-        os.chdir(SConfFS.pathTop)
+        old_fs_dir = SConfFS.getcwd()
+        old_os_dir = os.getcwd()
+        SConfFS.chdir(SConfFS.Top, change_os_dir=1)
 
         self._setCache( nodes ) 
         ret = 1
@@ -220,7 +221,8 @@ class SConf:
                     # the node could not be built. we return 0 in this case
                     ret = 0
         finally:
-            os.chdir(oldcwd)
+            os.chdir(old_os_dir)
+            SConfFS.chdir(old_fs_dir, change_os_dir=0)
             if self.logstream != None:
                 # restore stdout / stderr
                 sys.stdout = oldStdout
index 78558fc576d1a5074657f5a2aeb0fa444eec964a..feaea0bb15c23ef746e6ce2fa1808338eff381fc 100644 (file)
@@ -220,7 +220,7 @@ Checking for C header no_std_c_header.h ... failed
     #     even if BuildDir is set
     reset()
 
-    test.subdir( 'sub' )
+    test.subdir( 'sub', ['sub', 'local'] )
     test.write( 'SConstruct', """
 opts = Options()
 opts.Add('chdir')
@@ -232,18 +232,28 @@ else:
 BuildDir( 'build', '.' )
 SConscript( 'build/SConscript' )
 """)
+    test.write( 'sub/local/local_header.h', "/* Hello World */" )
     test.write( 'SConscript', """
 SConscript( 'sub/SConscript' )
 """)
     test.write( 'sub/SConscript', """
+def CustomTest(context):
+  context.Message('Executing Custom Test ... ')
+  ret = context.TryCompile('#include "local_header.h"', '.c')
+  context.Result(ret)
+  return ret
+
 env = Environment()
+env.Append( CPPPATH='local' )
 import os
 env['ENV']['PATH'] = os.environ['PATH']
-conf = Configure( env )
+conf = Configure( env, custom_tests = {'CustomTest' : CustomTest} )
 if not conf.CheckCHeader( 'math.h' ):
   Exit(1)
 if conf.CheckCHeader( 'no_std_c_header.h' ):
   Exit(1)
+if not conf.CustomTest():
+  Exit(1)
 env = conf.Finish()
 env.Program( 'TestProgram', 'TestProgram.c' )
 """)
@@ -262,6 +272,7 @@ int main() {
                                        read_str=
     """Checking for C header math.h ... ok
 Checking for C header no_std_c_header.h ... failed
+Executing Custom Test ... ok
 """)
     # first with SConscriptChdir(0)
     test.run(stdout = required_stdout, arguments='chdir=no')
@@ -270,7 +281,7 @@ Checking for C header no_std_c_header.h ... failed
 
     test.run(stdout = required_stdout, arguments='chdir=no')
     checkFiles( test, [".sconf_temp/.cache", "config.log"] )
-    checkLog( test, 'config.log', 3, 1 )
+    checkLog( test, 'config.log', 5, 1 )
 
     shutil.rmtree(test.workpath(".sconf_temp"))
 
@@ -281,7 +292,7 @@ Checking for C header no_std_c_header.h ... failed
 
     test.run(stdout = required_stdout, arguments='chdir=yes')
     checkFiles( test, [".sconf_temp/.cache", "config.log"] )
-    checkLog( test, 'config.log', 3, 1 )
+    checkLog( test, 'config.log', 5, 1 )
 
     # 3.1 test custom tests
     reset()