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:
# 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
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'
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:
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:
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:
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 = ".")
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:
f()
""")
-test.write("SConscript", """
-Import(['x', 'y'])
-assert x == 'x'
-assert y == 'zoom'
-""")
-
test.run(arguments = ".")
# Test export of local variables as a dictionary:
SConscript('SConscript')
""")
-test.write("SConscript", """
-Import(['x', 'y'])
-assert x == 'x'
-assert y == 'zoom'
-""")
-
test.run(arguments = ".")
# Test importing all variables: