diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-06-28 01:26:19 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | abd74f22fd0c58b30f951da9cec1d1799e9b5072 (patch) | |
tree | 47b71e6fa6e0ba01ad67e69c95f00634a3701280 | |
parent | 33223c7d9a80e821bccce25960f7e48ab425d975 (diff) |
Generate compile_commands.json
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | build.sh | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -6,3 +6,4 @@ amalgam test libamalgam.so **/*.z +compile_commands.json @@ -33,8 +33,29 @@ if [ ! -z "$SCAN_BUILD" ]; then scan-build $CC $BUILD_ARGS fi set +x + if [ -z "$NO_TEST" ]; then source_files_tests=$(readlink -f $(find "$this_script_dir/tests" -name "*.c")) set -x time $CC $source_files_tests $CFLAGS $LIBS -o test "$this_script_dir/libamalgam.so" fi + +set +x +compile_commands=$( +first=0 +echo "[" +for source_file in $source_files $source_files_tests; do + if [ $first == 1 ]; then + echo "," + fi + first=1 + o_file="${source_file}.o" + echo " {" + echo " \"file\": \"$source_file\"," + echo " \"directory\": \"$this_script_dir\"," + echo " \"command\": \"$CC -o $o_file $CFLAGS $LIBS -c $source_file\"," + echo " \"output\": \"$o_file\"" + echo " }" +done +echo "]") +echo "$compile_commands" > "$this_script_dir/compile_commands.json" |