can`t not use compile_commands.json with relative path
Observed behavior
when we use build system link ninja and the ninja generator compile database with relative path, and ccls just can`t use this json as input
{
"directory": "/data00/home/panxueqian/development/ccls/build/clang-ninja",
"command": "/usr/bin/clang++-9 -I../../src -isystem ../../third_party -isystem /usr/lib/llvm-8/include -isystem ../../third_party/rapidjson/include -O3 -DNDEBUG -Wall -Wno-sign-compare -pthread -std=c++17 -o CMakeFiles/ccls.dir/src/messages/workspace.cc.o -c /data00/home/panxueqian/development/ccls/src/messages/workspace.cc",
"file": "/data00/home/panxueqian/development/ccls/src/messages/workspace.cc"
}
Steps to reproduce
for example, cmake generator with ninja
CMAKE_PREFIX_PATH=/usr/lib/llvm-7/lib/cmake/clang cmake -H. -Bbuild/clang-ninja -DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja
the key is -G Ninja
and set compilationDatabaseDirector as ./build/clang-ninja
and ccls can`t find system include
it happen both in debain and macos, i think it should be easy to recurrent
System information
- ccls version (
0.20190823.5-17-g41e7d6a7): # just master - OS: mac / linux
- Editor: vim / vscode
- Language client (and version): coc.nvim/vscode-ccls
src/project.cc Project::loadDirectory:
if (g_config->compilationDatabaseCommand.empty()) {
cdbDir = root;
if (g_config->compilationDatabaseDirectory.size()) {
if (sys::path::is_absolute(g_config->compilationDatabaseDirectory))
cdbDir = g_config->compilationDatabaseDirectory;
else
////////////// relative compilationDatabaseDirectory is supported
sys::path::append(cdbDir, g_config->compilationDatabaseDirectory);
}
sys::path::append(path, cdbDir, "compile_commands.json");
I found it happend when the first arg in compile_commmans.json is not clang++
In mac the first arg is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++, if we replace with /usr/local/opt/llvm/bin/clang++, the -I../ arg will work
Having the same issue but I am working in a nix environment where I don't have clang installed since I use gcc. Is there any way I can get ccls working since it prints errors for every header and type used ,which isn't helpful and inhibits all the features and funtionality of ccls .I have clang in my system environment thou.
:smile: for my case it so happens that there was an issue with my path. So to however has a similar issue check and make sure that there are no errors in your include path