mason icon indicating copy to clipboard operation
mason copied to clipboard

another take on guessing BOOST_TOOLSET

Open lightmare opened this issue 6 years ago • 0 comments

Follow-up to #692. I was still getting basename errors from mason install boost ... and mason link boost .... The culprit was that I didn't set CC and CXX, and so basename complained about missing operand. install/link action finished successfully despite the errors. I think it's ok for the toolset variables to remain empty if CC/CXX are empty, and not complain about it right at the start, when it's not known whether they'll be needed.

This PR actually fixes #515, the previous one didn't. Below is the commit message:

guess_compiler_name $CXX

Function guess_compiler_name prints the "basename" of its first argument (or second argument if the first is ccache). Passing non-quoted $CXX takes care of word splitting.

The "basename" is extracted with simple shell parameter expansion. It differs from how POSIX basename command works, but in good ways:

guess_compiler_name x/  # prints ''
command basename x/     # prints 'x'

guess_compiler_name ''  # prints ''
command basename ''     # ??

POSIX leaves unspecified whether the resulting string is '.' or ''.

guess_compiler_name     # prints ''
command basename        # error: missing operand

Parameter expansion just works, with basename command we would need to check that the compiler variable is set and non-null.

lightmare avatar Aug 17 '19 21:08 lightmare