[cfe-dev] Tooling command-line conventions

Kim Gräsman kim.grasman at gmail.com
Tue Aug 13 12:34:03 PDT 2013


On Mon, Aug 12, 2013 at 9:47 PM, I wrote:
>
> I'm looking into porting a pre-Tooling tool to Tooling to allow use of
> compilation databases.
>
> But our tool was built to be invoked from the build system, and
> exposes the same command-line interface as Clang, with some additional
> prefixed switches (e.g. tool -Xtool --toolswitch=value -I . foo.cpp).
>
> It seems Tooling and LLVM's CommandLine library instead separates tool
> switches and Clang switches with a double dash (e.g. tool
> -toolswitch=value -- -I . foo.cpp)
>
> Is there a clean way to combine Tooling's handling of compilation
> databases with prefixed switches to get the benefits of both modes?

I've studied the Tooling code a bit more closely, and it seems
FixedCompilationDatabase is in charge of the "--" form.

That means, unless I'm mistaken, that I should be able to build my
command-line parser to handle the prefixed "-Xtool" and produce a
FixedCompilationDatabase. Would such an implementation be of general
interest?

So I won't be able to lean on CommonOptionsParser, but that's a
sacrifice I'm willing to make :-)

- Kim



More information about the cfe-dev mailing list