[Scons-users] AddOption() strange behaviour
Hartmut Brandt
hartmut.brandt at dlr.de
Fri Dec 12 02:57:04 EST 2014
Hi Dirk
On Thu, 11 Dec 2014, Dirk B?chle wrote:
DB>Hi Hartmut,
DB>
DB>On 11.12.2014 12:42, Hartmut.Brandt at dlr.de wrote:
DB>> Hi,
DB>>
DB>> looks like there is something broken with the option parser. I have
DB>>
DB>> AddOption('--build',
DB>> dest = 'build',
DB>> type = 'string',
DB>> nargs = 1,
DB>> action = 'store',
DB>> metavar = 'DIR',
DB>> default = '.',
DB>> help = 'build directory')
DB>>
DB>> AddOption('--prefix',
DB>> dest = 'build',
DB>> type = 'string',
DB>> nargs = 1,
DB>> action = 'store',
DB>> metavar = 'DIR',
DB>> default = '/ndvb',
DB>> help = 'build directory')
DB>> in my SConstruct file. If I call
DB>errm...did you already notice that you are using the same "dest" string for
DB>both of your options? I guess this is where your problems are coming from.
Ahh, well. This crept in when I copy and pasted the stuff by hand into the
mail. Here is the actual test that I use:
AddOption('--prefix',
dest = 'prefix',
type = 'string',
nargs = 1,
action = 'store',
metavar = 'DIR',
default = '/prefix',
help = 'set the prefix directory')
AddOption('--build',
dest = 'build',
type = 'string',
nargs = 1,
action = 'store',
metavar = 'DIR',
default = '/build',
help = 'set the build directory')
# set up and export the build environment
env = Environment(
tools = [
'default'])
Export('env')
# text for -h
# Help(vars.GenerateHelpText(env))
print "prefix=%s" % GetOption('prefix')
print "build=%s" % GetOption('build')
print "COMMAND_LINE_TARGETS=%s" % str(COMMAND_LINE_TARGETS)
print "ARGUMENTS=%s" % str(ARGUMENTS)
It exhibits the same behaviour:
# scons --prefix=prefix --build=build
scons: Reading SConscript files ...
prefix=prefix
build=build
COMMAND_LINE_TARGETS=[]
ARGUMENTS={}
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
# scons --prefix prefix --build=build
scons: Reading SConscript files ...
prefix=prefix
build=build
COMMAND_LINE_TARGETS=['prefix']
ARGUMENTS={}
scons: done reading SConscript files.
scons: Building targets ...
scons: *** Do not know how to make File target `prefix'
(/usr/home/brandt_h/src/xtest/prefix). Stop.
scons: building terminated because of errors.
# scons --prefix=prefix --build build
scons: Reading SConscript files ...
usage: scons [OPTION] [TARGET] ...
SCons Error: --build option requires an argument
# scons --prefix prefix --build build
scons: Reading SConscript files ...
usage: scons [OPTION] [TARGET] ...
SCons Error: --build option requires an argument
If I import OptionParser from python and replace AddOption by a
corresponding add_option then it works as expected.
When I swap the AddOption() calls then the mis-behaviour of the options
also swaps. It is independent of the order on the command-line.
harti
More information about the Scons-users
mailing list