From: gregnoel Date: Sun, 17 May 2009 15:54:14 +0000 (+0000) Subject: Issue 2229, fix, tests, doc X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3c516c40b47f10d3a2a1223079c495ddabad79eb;p=scons.git Issue 2229, fix, tests, doc git-svn-id: http://scons.tigris.org/svn/scons/trunk@4202 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 593d416f..03e40767 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -3669,9 +3669,10 @@ so subsequent calls to will over-write previous exports that have the same name. Multiple variable names can be passed to .BR Export () -as separate arguments or as a list. A dictionary can be used to map -variables to a different name when exported. Both local variables and -global variables can be exported. +as separate arguments or as a list. +Keyword arguments can be used to provide names and their values. +A dictionary can be used to map variables to a different name when exported. +Both local variables and global variables can be exported. Examples: @@ -3687,7 +3688,10 @@ Export("env", "package") # Make env and package available for all SConscript files: Export(["env", "package"]) -# Make env available using the name debug:. +# Make env available using the name debug: +Export(debug = env) + +# Make env available using the name debug: Export({"debug":env}) .EE diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 9a67e676..a34278a6 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -491,9 +491,10 @@ class SConsEnvironment(SCons.Environment.Base): def Exit(self, value=0): sys.exit(value) - def Export(self, *vars): + def Export(self, *vars, **kw): for var in vars: global_exports.update(compute_exports(self.Split(var))) + global_exports.update(kw) def GetLaunchDir(self): global launch_dir diff --git a/test/SConscript/variables.py b/test/SConscript/variables.py index dd51155c..828a62c8 100644 --- a/test/SConscript/variables.py +++ b/test/SConscript/variables.py @@ -33,6 +33,13 @@ import TestSCons test = TestSCons.TestSCons() +# SConscript to detect if exported variables are intact +test.write("SConscript", """ +Import(['x', 'y']) +assert x == 'x' +assert y == 'zoom' +""") + # Test exporting all global variables as a list of keys: test.write("SConstruct", """ x = 'x' @@ -41,12 +48,6 @@ Export(globals().keys()) SConscript('SConscript') """) -test.write("SConscript", """ -Import(['x', 'y']) -assert x == 'x' -assert y == 'zoom' -""") - test.run(arguments = ".") # Test exporting all global variables as a list of keys in SConscript call: @@ -56,12 +57,6 @@ y = 'zoom' SConscript('SConscript', globals().keys()) """) -test.write("SConscript", """ -Import(['x', 'y']) -assert x == 'x' -assert y == 'zoom' -""") - test.run(arguments = ".") # Test exporting all global variables as a dictionary: @@ -72,12 +67,6 @@ Export(globals()) SConscript('SConscript') """) -test.write("SConscript", """ -Import(['x', 'y']) -assert x == 'x' -assert y == 'zoom' -""") - test.run(arguments = ".") # Test exporting all global variables as dictionary in SConscript call: @@ -87,10 +76,11 @@ y = 'zoom' SConscript('SConscript', globals()) """) -test.write("SConscript", """ -Import(['x', 'y']) -assert x == 'x' -assert y == 'zoom' +test.run(arguments = ".") + +# Test exporting variables as keywords: +test.write("SConstruct", """ +Export(x = 'x', y = 'zoom') """) test.run(arguments = ".") @@ -106,12 +96,6 @@ f() SConscript('SConscript') """) -test.write("SConscript", """ -Import(['x', 'y']) -assert x == 'x' -assert y == 'zoom' -""") - test.run(arguments = ".") # Test export of local variables in SConscript call: @@ -123,12 +107,6 @@ def f(): f() """) -test.write("SConscript", """ -Import(['x', 'y']) -assert x == 'x' -assert y == 'zoom' -""") - test.run(arguments = ".") # Test export of local variables as a dictionary: @@ -142,12 +120,6 @@ f() SConscript('SConscript') """) -test.write("SConscript", """ -Import(['x', 'y']) -assert x == 'x' -assert y == 'zoom' -""") - test.run(arguments = ".") # Test importing all variables: