summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-05-23 12:11:42 (GMT)
committerSteven Knight <knight@baldmt.com>2004-05-23 12:11:42 (GMT)
commitd157a17661410b67ad01cefa8d60b4c265185738 (patch)
tree9c3de3248b5a9de87ec2e166227213fc768ac202
parent6f16c7447f7aa3be24662edf48fbf4466448cd9c (diff)
downloadSCons-d157a17661410b67ad01cefa8d60b4c265185738.zip
SCons-d157a17661410b67ad01cefa8d60b4c265185738.tar.gz
SCons-d157a17661410b67ad01cefa8d60b4c265185738.tar.bz2
Add support for fetching command-line arguments by position number. (Gary Oberbrunner)
-rw-r--r--doc/man/scons.142
-rw-r--r--src/CHANGES.txt9
-rw-r--r--src/engine/SCons/Script/SConscript.py3
-rw-r--r--test/ARGLIST.py48
4 files changed, 102 insertions, 0 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index ea0cf81..51c9e4c 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -314,6 +314,17 @@ else:
env = Environment()
.EE
+The command-line variable arguments are also available
+in the ARGLIST list,
+indexed by their order on the command line.
+This allows you to process them in order rather than by name,
+if necessary.
+ARGLIST[0] returns a tuple
+containing (argname, argvalue).
+A Python exception is thrown if you
+try to access a list member that
+does not exist.
+
.B scons
requires Python version 1.5.2 or later.
There should be no other dependencies or requirements to run
@@ -3751,6 +3762,37 @@ to affect how you want the build to be performed.
'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.TP
+ARGLIST
+A list
+.IR keyword = value
+arguments specified on the command line.
+Each element in the list is a tuple
+containing the
+.RI ( keyword , value )
+of the argument.
+The separate
+.I keyword
+and
+.I value
+elements of the tuple
+can be accessed by
+subscripting for element
+.B [0]
+and
+.B [1]
+of the tuple, respectively.
+
+.ES
+print "first keyword, value =", ARGLIST[0][0], ARGLIST[0][1]
+print "second keyword, value =", ARGLIST[1][0], ARGLIST[1][1]
+third_tuple = ARGLIST[2]
+print "third keyword, value =", third_tuple[0], third_tuple[1]
+for key, value in ARGLIST:
+ # process key and value
+.EE
+
+'\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.TP
ARGUMENTS
A dictionary of all the
.IR keyword = value
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 7aaabf5..57166df 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -25,6 +25,9 @@ RELEASE 0.96 - XXX
- Suppress null values in construction variables like $LIBS that use
the internal _concat() function.
+ - Remove .dll files from the construction variables searched for
+ libraries that can be fed to Win32 compilers.
+
From Chad Austin and Christoph Wiedemann:
- Add support for a $RPATH variable to supply a list of directories
@@ -139,6 +142,9 @@ RELEASE 0.96 - XXX
- Try to find the ICL license file path name in the external environment
and the registry before resorting to the hard-coded path name.
+ - Add support for fetching command-line keyword=value arguments in
+ order from an ARGLIST list.
+
From Simon Perkins:
- Fix a bug introduced in building shared libraries under MinGW.
@@ -150,6 +156,9 @@ RELEASE 0.96 - XXX
- If Visual Studio is installed, assume the C/C++ compiler, the linker
and the MIDL compiler that comes with it are available, too.
+ - Better error messages when evaluating a construction variable
+ expansion yields a Python syntax error.
+
From sam th:
- Allow SConf.CheckLib() to search a list of libraries, like the
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 6a414b7..405ce71 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -61,6 +61,7 @@ def do_nothing(text): pass
HelpFunction = do_nothing
Arguments = {}
+ArgList = []
CommandLineTargets = []
DefaultCalled = None
DefaultTargets = []
@@ -88,6 +89,7 @@ def _scons_add_args(alist):
for arg in alist:
a, b = string.split(arg, '=', 1)
Arguments[a] = b
+ ArgList.append((a, b))
def _scons_add_targets(tlist):
if tlist:
@@ -684,6 +686,7 @@ def BuildDefaultGlobals():
# Other variables we provide.
'ARGUMENTS' : Arguments,
+ 'ARGLIST' : ArgList,
'BUILD_TARGETS' : BuildTargets,
'COMMAND_LINE_TARGETS' : CommandLineTargets,
'DEFAULT_TARGETS' : DefaultTargets,
diff --git a/test/ARGLIST.py b/test/ARGLIST.py
new file mode 100644
index 0000000..c70ed8e
--- /dev/null
+++ b/test/ARGLIST.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# 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', """
+i = 0
+for key, value in ARGLIST:
+ print "%d: %s = %s" % (i, key, value)
+ i = i + 1
+""")
+
+expect = test.wrap_stdout(read_str="""\
+0: a = 1
+1: bz = 3
+2: xx = sd
+3: zzz = foo=bar
+""",
+ build_str="scons: `.' is up to date.\n")
+
+test.run(arguments='a=1 bz=3 xx=sd zzz=foo=bar .', stdout = expect)
+
+test.pass_test()