foo = SConscript('subdir/SConscript', "env")
.EE
+.TP
+.RI SConscriptChdir( value )
+When a non-negative
+.I value
+is specified,
+this instructs
+.B scons
+to change its working directory (chdir)
+to the directory in which each subsidiary
+configure (SConscript) file lives.
+Note that you may enable and disable
+this ability by calling
+.R SConscriptChdir()
+multiple times:
+
+.ES
+SConscriptChdir(1)
+SConscript('foo/SConscript') # will chdir to foo
+SConscriptChdir(0)
+SConscript('bar/SConscript') # will not chdir to bar
+.EE
+
.TP
.RI SetCommandHandler( function )
- Man page: Add a hierarchical libraries + Program example.
+ From Steve Leblanc:
+
+ - Add the SConscriptChdir() method.
+
From Anthony Roach:
- Fix --debug=tree when used with directory targets.
import SCons.Node.FS
import SCons.Util
+import os
import string
import sys
# global exports set by Export():
global_exports = {}
+# chdir flag
+sconscript_chdir = 0
+
+def SConscriptChdir(flag):
+ global sconscript_chdir
+ sconscript_chdir = flag
+
def _scons_add_args(alist):
global arguments
for arg in alist:
# push:
stack.append(Frame(exports))
+ old_dir = None
try:
# call:
if script == "-":
if script.exists():
file = open(str(script), "r")
SCons.Node.FS.default_fs.chdir(script.dir)
+ if sconscript_chdir:
+ old_dir = os.getcwd()
+ os.chdir(str(script.dir))
exec file in stack[-1].globals
else:
sys.stderr.write("Ignoring missing SConscript '%s'\n" % script.path)
# pop:
frame = stack.pop()
SCons.Node.FS.default_fs.chdir(frame.prev_dir)
+ if old_dir:
+ os.chdir(old_dir)
return frame.retval
globals['Return'] = Return
globals['Scanner'] = SCons.Scanner.Base
globals['SConscript'] = SConscript
+ globals['SConscriptChdir'] = SConscriptChdir
globals['SetCommandHandler'] = SCons.Action.SetCommandHandler
globals['WhereIs'] = SCons.Util.WhereIs
return globals