[cfe-dev] LibTooling with NMake Makefiles (Windows)

Manuel Klimek klimek at google.com
Sun Oct 21 23:11:25 PDT 2012


On Fri, Oct 19, 2012 at 11:33 PM, Jay Mattis <jaymattis at gmail.com> wrote:

> Hi everyone,
>
> I'm VERY new to all of the LibTooling stuff. I just thought I'd check
> it out yesterday and I found the following issue. I don't know if this
> is me doing something wrong or what, but...
>
> I wanted to use LibTooling on Windows with a generic project. I
> created a single directory as a test that just had input_test.cpp
> which basically contained only an empty main function. Then, I created
> a CMakeLists.txt file for it. I understand that the next step is
> creating the .json file (this is the part where I suspect maybe
> there's a better way?), so I tried using
> -DCMAKE_EXPORT_COMPILE_COMMANDS=ON. This didn't export any json since
> it was building a Visual Studio project. So, I used -g "NMake
> Makefiles". This seemed to successfully export the .json file.
> However, I got all kinds of errors when trying to use LibTooling on
> it. The reason is that it generated a json file that looked like this:
>
> [
> {
>   "directory": "C:/path/to/project",
>   "command": "C:\\PROGRA~2\\MICROS~2.0\\VC\\bin\\cl.exe  @<<
>  /nologo -g -Wall /MD /O2 /Ob2 /D NDEBUG
> -IC:\\path\\to\\project\\$(INPUTTEST_SOURCE_DIR)     /TP
> /FoCMakeFiles\\inputtest.dir\\inputtest.obj
> /FdC:\\path\\to\\project\\inputtest.pdb -c
> C:\\path\\to\\project\\inputtest.cpp
> <<",
>   "file": "C:/path/to/project/inputtest.cpp"
> }
> ]
>
> When I modified the .json file manually to look this, it worked:
>
> [
> {
>   "directory": "C:/path/to/project",
>   "command": "C:/PROGRA~2/MICROS~2.0/VC/bin/cl.exe /nologo -g -Wall
> /MD /O2 /Ob2 /D NDEBUG -IC:/path/to/project/$(INPUTTEST_SOURCE_DIR)
>  /TP /FoCMakeFiles/inputtest.dir/inputtest.obj
> /FdC:/path/to/project/inputtest.pdb -c
> C:/path/to/project/inputtest.cpp",
>   "file": "C:/path/to/project/inputtest.cpp"
> }
> ]
>
> I don't know what the whole multi-line @<< stuff is about but that
> seems to be what's causing the issue. Does anyone else have any
> experience with this or a better way for me to set this up?
>

Hi Jay,

unfortunately, you stepped over the bleeding edge :(

Nobody has put work into getting libtooling to function on Windows yet. I'd
imagine that there are more bumps one would hit before getting it to run.

The first thing we'd need is, as your example nicely shows, a function to
translate MSVC++ command line options into clang options in the tooling
layer (we need something similar for gcc anyway). In case you want to help,
patches very very welcome :)

Cheers,
/Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121022/a66d507c/attachment.html>


More information about the cfe-dev mailing list