简体   繁体   中英

How do I check if my clangd compilation database is valid?

I generate a compilation database in a project built by autotools using compiledb in WSL environment. Then I copy resultant compile_commands.json to another directory and run clangd in Windows environment. I convert all the Unix paths to their Windows equivalents. And now I want to check if I converted it correctly and clangd finds all the files in the json.

When I use CLion as a front-end I can't see if the processing of some entries failed.

Does clang toolchain have some utilities for validation compile_commands.json ?

You can run clangd with following options:

clangd --compile-commands-dir path/to/directory/containing/compile_commands.json --check=path/to/file.cpp

If the compile_commands.json is valid, it prints following output:

I[11:16:53.056] Loading compilation database...
I[11:16:53.056] Loaded compilation database from /full/path/to/directory/containing/compile_commands.json

If it is invalid, it prints following output (in this example I changed directory to directoryuuuuu in the compile_commands.json file):

I[11:14:26.396] Loading compilation database...
E[11:14:26.396] Failed to load compilation database from /full/path/to/directory/containing/compile_commands.json: Unknown key: ""directoryuuuuu""
I[11:14:26.396] Failed to find compilation database for /full/path/to/file.cpp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM