File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,20 @@ cmake . -DLLVM_CONFIG_EXECUTABLE=/usr/local/Cellar/llvm/<your_llvm_version>/bin/
7272make
7373```
7474
75+ compile_commands.json
76+ =====================
77+ We need a compile_commands.json file to know how your project is usually compiled.
78+ There are multiple ways to get this file:
79+
80+ * For cmake, pass -DCMAKE_EXPORT_COMPILE_COMMANDS=ON as a cmake parameter
81+ * For qmake, configure/autoconf and others, follow the instructions in scripts/fake_compiler.sh or scripts/woboq_cc.js.
82+ These are fake compilers that append the compiler invocation to the json file and forward to the real compiler.
83+ Your real compiler is overriden using the CC/CXX environment variables
84+ Make sure to have the json file properly terminated.
85+ * There is also a project called Build EAR (Bear) that achieves a similar thing as our fake compilers
86+ but is using LD_PRELOAD to inject itself into the build process to catch how the compiler is invoked.
87+ https://github.com/rizsotto/Bear
88+
7589
7690Using the generator
7791===================
Original file line number Diff line number Diff line change 22
33#
44# This script can be used to generate the compile_commands.json file.
5- # Configure this script as the compiler.
5+ # Configure this script as the compiler, e.g. with the CC/CXX environment variables .
66# Export the $COMPILATION_COMMANDS environement variable to the full path of the compile_commands.json file.
77# set $FORWARD_COMPILER to the path of the actual compiler to perform the actual compilation.
88#
9- # Example:
9+ # Example using configure (similar when using qmake) :
1010#
1111# export COMPILATION_COMMANDS=/path/to/compile_commands.json
1212# export FORWARD_COMPILER=g++
13- # CXX=/path/to/fake_compiler.sh ./configure
13+ # CC=/path/to/fake_compiler.sh CXX=/path/to/fake_compiler.sh ./configure
1414# echo "[" > $COMPILATION_COMMANDS
1515# make -j1
1616# echo " { \"directory\": \".\", \"command\": \"true\", \"file\": \"/dev/null\" } ]" >> $COMPILATION_COMMANDS
You can’t perform that action at this time.
0 commit comments