aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xbuild.sh21
2 files changed, 22 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 6c2d3bd..3192d43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ amalgam
test
libamalgam.so
**/*.z
+compile_commands.json
diff --git a/build.sh b/build.sh
index 87e18a6..6911ee0 100755
--- a/build.sh
+++ b/build.sh
@@ -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"