[cfe-dev] Can someone tell me what I'm doing wrong?

Bill White bill.white at griggsinst.com
Wed Oct 24 14:30:39 PDT 2012


I'm trying to understand how to make a compile database.  I can't switch to
cmake because my very large project uses gmake.  So I've made a python
program to create a compile_commands.json file.  It seems to have the right
information.  For one file, named "x/y.cpp", when I cut the "command" value
out of the compile_commands.json file for "x/y.cpp" and execute it in a shell,
the command executes as I expect it to.  However, when I try to run
"clang-check"
I get various odd errors.  Here's the complete situation:

1.) The compile_commands.json file is in /a/b/c/compile_commands.json.  I
    Think that makes "/a/b/c" the build directory in clang Tooling terms.
2.) The source file is in /a/b/c/x/y.cpp.
3.) The entry in compile_comands.json is:
        {"directory": "/a/b/c", "command": "clang++ x/y.cpp ... stuff
...", "file": "/a/b/c/x/y.cpp"}
    And of course there are many entries.  This is just one of hundreds.

When I run clang-check, as the documentation seems to imply, using -p to name
the build directory, I get this:

% cd /a/b/c
% clang-check -p . x/y.cpp
Processing: /a/b/c/x/y.cpp.
error: no input files
error: unable to handle compilation, expected exactly one compiler job in ''
Error while processing /a/b/c/x/y.cpp.

Note: I get the same behavior putting the full path name for ".", when eliminate
      the "-p build_dir" completely.  I also get the same behavior
when I cd into
      x and run the experiments (with y.cpp in place of x/y.cpp, of course).

Why am I being so dense about this?  What am I missing?  This seems very
unintuitive.  I'm trying to build a tool which extracts dependence
information, but
I'm stymied right at the beginning.



More information about the cfe-dev mailing list