[Scons-users] bug with AddOption?
Mats Wichmann
mats at wichmann.us
Thu Apr 28 17:21:04 EDT 2022
On 4/28/22 15:04, Gabe Black wrote:
> There seems to also be another problem here as well, although this one
> might be a usage error on my part. It looks like if you use the --linker
> option, you also have to use it in --linker=gold form, and can't use it
> as two arguments, ie --linker gold. I think both *should* work, so this
> might be another symptom of the first problem.
I didn't get a chance to digest the first question as I'm in between
stuff, but I definitely recognize this one.
I spent some time tearing my hair out over the problem with the option
handling a while back, and there are a whole bunch of bugs filed on it
from over the years. The brief summary: yup, it's broken. Fixing it
isn't easy (or it would have been done).
If you're going to reliably use option-argument forms, do use the
--foo=bar style. Sadly that can't be enforced from the Python side,
users just have to get used to doing that. If you want to use
multiple-option-arguments, use --foo=bar1,bar2, collect the single
argument, and process it into two yourself.
===
Fundamentally, there's a conflict.
SCons thinks a command line is:
scons [variables=values] [--arguments] [targets]
When it starts up it harvests these, because some have to be available
for use in SConscripts - command-line targets and variables both are
supposed to be available for SConscripts to poke around in. It proceses
the arguments it knows, and stashes the rest that looks like an argument
in case those get defined later. Variables are anything with an = in
them that wasn't taken out by argument processing. And the rest, the
free-standing words, are collected as targets - you can probably see
where this is going - your "gold" got collected as a target, and
disassociated from the deferred --linker..
*Now* we process SConscripts, and somewhere there we see an AddOption
defining --linker, so we can handle that... oops, its too late, its
option-arg is already in $ COMMAND_LINE_TARGETS .
Can't change the order of things, because then variables and targets
wouldn't be available to SConscripts, so it's not simple.
More information about the Scons-users
mailing list