|
Boost-Build : |
Subject: Re: [Boost-build] b2 option parsing
From: Stefan Seefeld (stefan_at_[hidden])
Date: 2016-10-30 12:12:34
On 30.10.2016 09:18, aaron_at_[hidden] wrote:
> > how (where) does b2 parse and interpret command-line options ? I have
> > looked at jam.c and option.c, of course, but couldn't find how for
> > example "--python" is handled.
>
> There are two types of option parsing that occur. Any of the single
> dash options
> like -h, -a, -j, etc. are parsed by the C engine. All of the double
> dash options
> are ignored by the engine so that they can be examined by Jam. Typically,
> a jam file will peek at the global ARGV variable to see if any flags
> are set.
>
> The --python flag is handled in bootstrap.jam (yes, even in the Python
> port, Jam is still called).
Oh, yuk !
> Within that file and when the --python flag is passed, it sets up some
> Jam rules that
> Python itself can't create (e.g. setting target variables, creating
> actions, etc) then loads the
> bootstrap.py module and executes its one function.
Well, I don't think target variables or action creation should be done
prior to starting the Python layer, simply as a matter of separation of
concerns.
I'll see whether I can manage to short-circuit the calling of Jam and
somehow run the bootstrap.py module directly.
>
> > Also, when I run `.../b2 --python foo
> > bar=baz` I get output such as
> >
> > don't know how to make bar=baz
>
> "bar=baz" is not a flag.
I know. Ideally the entire handling of the command-line should be done
in a higher layer, so the engine layer (that's what I call anything
beyond Python) doesn't have to know anything about concepts such as
"target variables", "features", etc.
> Have a look at build_system.py
> <https://github.com/boostorg/build/blob/develop/src/build_system.py#L510>.
> In the main()
> it tries to parse each of the non-dashed command line arguments as a
> property. or a target
> In this case, "bar" would have had to be registered as a feature in
> order for it
> to be interpreted as a property of <bar>baz. Since "bar" was not
> registered, the full
> token "bar=baz" is interpreted as the name of a target which is why
> you get the error
> message "Don't know how to make bar=baz"
Many thanks,
Stefan
>
> HTH,
> Aaron
-- ...ich hab' noch einen Koffer in Berlin...
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk