list.
More than one value may be specified,
with all values separated by commas.
+The default may be a string of
+comma-separated default values,
+or a list of the default values.
.TP
.RI PackageOption( key ", " help ", " default )
so it prints a meaningful string, not the binary representation of
the function contents.
+ - Allow a ListOption's default value(s) to be a Python list of specified
+ values, not just a string containing a comma-separated list of names.
+
From Elliot Murphy:
- Enhance the tests to guarantee persistence of ListOption
import string
import UserList
+import SCons.Util
+
class _ListOption(UserList.UserList):
def __init__(self, initlist=[], allowedElems=[]):
package names (separated by space).
"""
names_str = 'allowed names: %s' % string.join(names, ' ')
+ if SCons.Util.is_List(default):
+ default = string.join(default, ',')
help = string.join(
(help, '(all|none|comma-separated list of names)', names_str),
'\n ')
assert o.validator is None, o.validator
assert not o.converter is None, o.converter
+ opts = SCons.Options.Options()
+ opts.Add(SCons.Options.ListOption('test2', 'test2 help',
+ ['one', 'three'],
+ ['one', 'two', 'three']))
+
+ o = opts.options[0]
+ assert o.default == 'one,three'
+
def test_converter(self):
"""Test the ListOption converter"""
opts = SCons.Options.Options()
File "SConstruct", line 14, in ?
""", status=2)
+test.write('SConstruct', """
+from SCons.Options import ListOption
+
+opts = Options(args=ARGUMENTS)
+opts.AddOptions(
+ ListOption('gpib',
+ 'comment',
+ ['ENET', 'GPIB'],
+ names = ['ENET', 'GPIB', 'LINUX_GPIB', 'NO_GPIB']),
+ )
+
+env = Environment(options=opts)
+Help(opts.GenerateHelpText(env))
+
+print env['gpib']
+Default(env.Alias('dummy', None))
+""")
+
+test.run(stdout=test.wrap_stdout(read_str="ENET,GPIB\n", build_str="""\
+scons: Nothing to be done for `dummy'.
+"""))
#### test PackageOption ####