Boost logo

Boost-Build :

Subject: Re: [Boost-build] string manipulation
From: Stefan Seefeld (stefan_at_[hidden])
Date: 2016-10-13 16:40:11


On 13.10.2016 16:30, aaron_at_[hidden] wrote:
> > Thanks, that works. How can I capture errors using the SHELL command,
> > i.e. handle cases where `path/to/tool.py`either returns an error or
> > writes to stderr (or both) ?
>
> There isn't a way to get the stderr, but you can have the exit code
> returned by passing
> "exit-status" as an optional parameter. This will return a list of two
> items: the stdout and
> the error code
>
> local result = [ SHELL path/to/tool.py : strip-eol exit-status ] ;
> local output = $(result[1]) ;
> local status = $(result[2]) ;

If I can't capture stderr, can I at least suppress it ? Right now my
command prints out the error message straight to the terminal (which I
invoked the `b2` command from), which isn't helpful.

To make this more concrete: I'm trying to figure out whether the
configured python interpreter has NumPy installed. If it does, I want to
extract the include path from it. So my command is `python -c "import
numpy; print(numpy.get_include())" `
If that command fails, I want to disable NumPy for the current build, if
not, I want to enable it and set some `python.numpy-include` variable to
hold the returned path.
Any suggestion on how to achieve that using BB ? (I don't want to
generate any error message. At best I'd simply indicate "NumPy
configured...yes" or "NumPy configured...no" depending on the result of
the check.)

>
> This option is documented here:
> http://www.boost.org/build/doc/html/jam/language.html#jam.language.rules.builtins.utility._shell__

Thanks !

        Stefan

-- 
      ...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