I have a project set up with several individual Sconstruct files and one toplevel SConstruct file.
project/SConstruct -- toplevel SConstruct file
project/binary1/SConstruct -- lower level SConstructs
project/binary2/SConstruct
project/binary3/src/SConstruct
I want to be able to call the individual SConstruct files with options. So each SConstruct can be called like this:
scons install --prefix=/usr/local/bin
and they have a section for that option in the SConstruct file:
AddOption('--prefix',
dest='prefix',
type='string',
nargs=1,
action='store',
metavar='DIR',
default=prefix,
help='installation prefix')
Also, in the toplevel SConstruct file, I would like to be able to call all of the lower level SConstruct files, so I added this to the toplevel SConstruct:
SConscript(binary1/SConstruct)
SConscript(binary2/SConstruct)
SConscript(binary3/src/SConstruct)
However, if I try to do this, I will get an OptionConflictError
on binary2/SConstruct
because the --prefix
option is already defined (in binary1/SConstruct
):
OptionConflictError: option --prefix: conflicting option string(s): --prefix:
Is there a way to get around this OptionConflictError
?
I know I can surround the call to AddOption()
with a try
block, but are there better ways? Can I add a conflict_handler
? Can I check if the --prefix
option already exists?
Can I organize things better? I need the individual SConstruct files unfortunately, so I can't reorganize too much.