-"""engine.SCons.Options
+"""engine.SCons.Options.PackageOption
This file defines the option type for SCons implementing 'package
activation'.
from BoolOption import True, False
import SCons.Errors
-__enable_strings = ('yes', 'true', 'on', 'enable', 'search')
-__disable_strings = ('no', 'false', 'off', 'disable')
+__enable_strings = (str(True), 'yes', 'true', 'on', 'enable', 'search')
+__disable_strings = (str(False), 'no', 'false', 'off', 'disable')
def _converter(val):
"""
import SCons.Errors
import SCons.Options
+from SCons.Options.BoolOption import True, False
import TestCmd
x = o.converter('/explicit/path')
assert x == '/explicit/path', x
+ # Make sure the converter returns True if we give it str(True) and
+ # False when we give it str(False). This assures consistent operation
+ # through a cycle of Options.Save(<file>) -> Options(<file>).
+ x = o.converter(str(True))
+ assert x == True, "converter returned a string when given str(True)"
+
+ x = o.converter(str(False))
+ assert x == False, "converter returned a string when given str(False)"
+
def test_validator(self):
"""Test the PackageOption validator"""
opts = SCons.Options.Options()
test.run()
check(['1'])
test.run(arguments='x11=no'); check(['0'])
+test.run(arguments='x11=0'); check(['0'])
test.run(arguments='"x11=%s"' % test.workpath()); check([test.workpath()])
-test.run(arguments='x11=0',
- stderr = """
-scons: *** Path does not exist for option x11: 0
-File "SConstruct", line 11, in ?
-""", status=2)
-
test.run(arguments='x11=/non/existing/path/',
stderr = """
scons: *** Path does not exist for option x11: /non/existing/path/
test.write('SConstruct', """
from SCons.Options import PathOption
-qtdir = '%s'
+qtdir = r'%s'
opts = Options(args=ARGUMENTS)
opts.AddOptions(
PathOption('qtdir', 'where the root of Qt is installed', qtdir),
- PathOption('qt_libraries', 'where the Qt library is installed', '%s'),
+ PathOption('qt_libraries', 'where the Qt library is installed', r'%s'),
)
env = Environment(options=opts)
PackageOption, PathOption
list_of_libs = Split('x11 gl qt ical')
-qtdir = '%(qtdir)s'
+qtdir = r'%(qtdir)s'
opts = Options(args=ARGUMENTS)
opts.AddOptions(
'yes'), PathOption('qtdir', 'where the root of Qt is installed', qtdir),
PathOption('qt_libraries',
'where the Qt library is installed',
- '%(libdirvar)s'),
+ r'%(libdirvar)s'),
)
env = Environment(options=opts)
actual: %(qtdir)s
qt_libraries: where the Qt library is installed ( /path/to/qt_libraries )
- default: $qtdir/lib
+ default: %(qtdir_lib)s
actual: %(libdir)s
Use scons -H for help about command-line options.
-""" % {'qtdir': qtpath, 'libdirvar': libdirvar, 'libdir': libpath})
+""" % {'qtdir': qtpath, 'qtdir_lib' : os.path.join('$qtdir', 'lib'),
+ 'libdirvar': libdirvar, 'libdir': libpath})
test.pass_test()