[Scons-users] What is the difference between Variables and Options

Andrew C. Morrow andrew.c.morrow at gmail.com
Sat Jan 2 13:15:41 EST 2016


It isn't the best solution since it doesn't show up in --help directly, but
the MongoDB build uses an Option called --variables-help which, when
present, calls GenerateHelpText on the Variables. Generally, we use Options
for things that control the presence or absence of features or require
multi-step configuration, and use Variables for things that have direct
meaning in the Environment (CFLAGS, etc.) or control Tool setup.

--variables-help implementation:
https://github.com/mongodb/mongo/blob/master/SConstruct#L391-L394
https://github.com/mongodb/mongo/blob/master/SConstruct#L839-L841

Our Options:
https://github.com/mongodb/mongo/blob/master/SConstruct#L132-L466

Our Variables:
https://github.com/mongodb/mongo/blob/master/SConstruct#L563-L696

Some of those options should probably be Variables, but we originally
started with all Options and have not completely converted.

Andrew



On Sat, Jan 2, 2016 at 12:55 PM, William Blevins <wblevins001 at gmail.com>
wrote:

> Stefan,
>
> SCons parses commandline arguments in multiple stages, so the commandline
> gets parsed multiple times by various parsers. I don't remember the exact
> logic, but options and variables are disjoint concepts.
>
> The SCons Option implementation is simply a wrapper around optparse (which
> will get replaced by argparse in the future).
> The SCons variable implementation is simply a pair-wise key:value ordering
> of non-option tokens.
>
> If you want to add variables to the help, then you may have to interact
> with OptParse more directly.
>
> V/R,
> William
>
> On Sat, Jan 2, 2016 at 3:10 PM, Stefan Seefeld <stefan at seefeld.name>
> wrote:
>
>> On 02.01.2016 02:15, Bill Deegan wrote:
>> > Stefan,
>> >
>> > Previously they were called options, but we changed the name to
>> variables.
>> > So don't use options as you can see it's deprecated.
>> >
>> > Please point to where Options.GenerateHelpText() is recommended so we
>> > can change it.
>>
>> There are a few places:
>> http://scons.org/doc/production/HTML/scons-user.html#chap-command-line
>> discusses (very briefly) the difference between "Options" and
>> "Variables", and I found some code in the wiki:
>> https://bitbucket.org/scons/scons/wiki/UnitTests
>>
>> As the documentation above points out, options always begin with hyphen
>> characters, while variables are passed as key-value pairs separated by
>> an equal-sign. Is that convention affected by your statement above about
>> options now being called variables ? And what about
>>
>> >     However, if I try to add the "--python" option as a variable key,
>> >     I get
>> >     the error "scons: *** Illegal Variables.Add() key `--python'".
>> >
>>
>> I.e. how can I define the "--python" option ? I used to use
>> "AddOption()" (which is still documented and works fine), but now want
>> to extract the help text when invoking Help(), but since Options() is
>> deprecated and Variables().add("--python", ...) doesn't work, I'm not
>> sure what to use for that.
>>
>> Thanks,
>>         Stefan
>>
>>
>> --
>>
>>       ...ich hab' noch einen Koffer in Berlin...
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20160102/c4346a3a/attachment-0001.html>


More information about the Scons-users mailing list