diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-01-31 17:35:51 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-01-31 17:36:10 +0530 |
| commit | 7224fce49e4fa8c0b966dcc8d4f9b1d12b02f66a (patch) | |
| tree | b85f49881f843f1765f2ec0a3899cdb1b5253e3b /setup_compiledb.sh | |
| download | daft-watch-7224fce49e4fa8c0b966dcc8d4f9b1d12b02f66a.tar.gz daft-watch-7224fce49e4fa8c0b966dcc8d4f9b1d12b02f66a.zip | |
Init commit with blink shit
Diffstat (limited to '')
| -rwxr-xr-x | setup_compiledb.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/setup_compiledb.sh b/setup_compiledb.sh new file mode 100755 index 0000000..9233bb1 --- /dev/null +++ b/setup_compiledb.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +export COMPILATIONDB_INCLUDE_TOOLCHAIN=true + +# Compile the project +pio run -t compiledb + +# Clean up existing define files +rm -f _compiler_defines.h compiler_defines.h clang_defines.h + +# Generate defines for clang +gcc -dM -xc++ /dev/null -c -v -E 2>/dev/null | sed "s/\([^[:space:]]\+[[:space:]]\+[^[:space:]]\+\)\(.*\)/\1/;s/#define/#undef/" >clang_defines.h + +# Iterate through compile_commands.json and extract compiler defines +for comp in $(cat compile_commands.json | grep -E "\"command\": \"[^[:space:]]* -o" | sed 's:"command"\: "::g; s:-o.*::g' | sort | uniq); do + set -x + $comp -dM -E -xc++ /dev/null >>_compiler_defines.h + set +x +done + +# Combine defines from clang and extracted defines +cat clang_defines.h > compiler_defines.h +cat _compiler_defines.h | sort | uniq >> compiler_defines.h + +# Clean up temporary define files +rm -f _compiler_defines.h clang_defines.h + +# Update compile_commands.json with additional include flags +sed -i "s:.cpp\",:.cpp -include $${PWD}/compiler_defines.h\",:" compile_commands.json +sed -i "s:.c\",:.c -include $${PWD}/compiler_defines.h\",:" compile_commands.json |
