summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/man/scons.123
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Script/SConscript.py10
-rw-r--r--src/engine/SCons/Script/__init__.py9
-rw-r--r--test/ARGUMENTS.py47
5 files changed, 80 insertions, 13 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index 2603ada..ca03f60 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -40,6 +40,9 @@ scons \- software constructor
.IR options ...
]
[
+.IR name = val ...
+]
+[
.IR targets ...
]
.SH DESCRIPTION
@@ -169,16 +172,16 @@ scons -j 4
builds four targets in parallel, for example.
-.\" Values of variables to be passed to the configuration file(s)
-.\" may be specified on the command line:
-.\"
-.\" .ES
-.\" scons debug=1 .
-.\" .EE
-.\"
-.\" These variables can be used in the configuration file(s) to modify
-.\" the build in any way.
-.\"
+Values of variables to be passed to the configuration file(s)
+may be specified on the command line:
+
+.ES
+scons debug=1 .
+.EE
+
+These variables can be used in the configuration file(s) to modify
+the build in any way.
+
.\" .B scons
.\" can maintain a cache of target (derived) files that can
.\" be shared between multiple builds. When caching is enabled in a
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 6ac5948..3e19a1e 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -35,6 +35,10 @@ RELEASE 0.04 -
- Add examples using Library, LIBS, and LIBPATH.
+ From Steve Leblanc:
+
+ - Add var=value command-line arguments.
+
RELEASE 0.03 - Fri, 11 Jan 2002 01:09:30 -0600
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 8ba64d1..bb1064a 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -36,17 +36,22 @@ import SCons.Defaults
import SCons.Node
import SCons.Node.FS
import SCons.Environment
-import SCons.Scanner
-import SCons.Action
import string
import sys
default_targets = []
print_help = 0
+arguments = {}
# global exports set by Export():
global_exports = {}
+def _scons_add_args(alist):
+ global arguments
+ for arg in alist:
+ a, b = string.split(arg, '=', 2)
+ arguments[a] = b
+
class Frame:
"""A frame on the SConstruct/SConscript call stack"""
def __init__(self, exports):
@@ -163,6 +168,7 @@ def BuildDefaultGlobals():
globals = {}
globals['Action'] = SCons.Action.Action
+ globals['ARGUMENTS'] = arguments
globals['BuildDir'] = BuildDir
globals['Builder'] = SCons.Builder.Builder
globals['CScan'] = SCons.Defaults.CScan
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 1711f7a..1788fab 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -584,12 +584,19 @@ def _main():
opt_func[opt](opt, arg)
try:
- cmd_opts, targets = getopt.getopt(sys.argv[1:], short_opts, long_opts)
+ cmd_opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts)
except getopt_err, x:
_scons_user_error(x)
else:
for opt, arg in cmd_opts:
opt_func[opt](opt, arg)
+ xmit_args = []
+ for a in args:
+ if '=' in a:
+ xmit_args.append(a)
+ else:
+ targets.append(a)
+ SCons.Script.SConscript._scons_add_args(xmit_args)
if not scripts:
for file in ['SConstruct', 'Sconstruct', 'sconstruct']:
diff --git a/test/ARGUMENTS.py b/test/ARGUMENTS.py
new file mode 100644
index 0000000..1a8b10d
--- /dev/null
+++ b/test/ARGUMENTS.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+foo = open('foo.out', 'w')
+keys = ARGUMENTS.keys()
+keys.sort()
+for k in keys:
+ foo.write(k + " = " + ARGUMENTS[k] + "\\n")
+foo.close()
+""")
+
+test.run(arguments='a=1 bz=3 xx=sd')
+
+test.fail_test(test.read('foo.out') != """a = 1
+bz = 3
+xx = sd
+""")
+
+test.pass_test()