Skip to content

Commit 2b7895b

Browse files
committed
improve hack for includes from workspace
1 parent 4f7563e commit 2b7895b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gen_compile_commands.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ set -e
66
JSON_OUT="$(pwd)/compile_commands.json"
77
BAZEL_ROOT="$(bazel info execution_root 2>/dev/null)"
88
WORKSPACE="$(bazel info workspace 2>/dev/null)"
9+
OUTPUT_BASE="$(bazel info output_base 2>/dev/null)"
910
echo "Generating compile_commands.json..."
1011
find "$BAZEL_ROOT" -name '*.compile_command.json' -print0 | while read -r -d '' fname; do
1112
# dirty hack: what if we have 'external' dir in workspace?
12-
sed -e "s|@BAZEL_ROOT@|$BAZEL_ROOT|g" < "$fname" | perl -pe "s#-isystem (?!bazel-out|external)#-isystem $WORKSPACE/#g" >> $JSON_OUT
13+
perl -pe 'if (/"file":"external/){$p="'$OUTPUT_BASE'";}else{$p="'$WORKSPACE'";}; s/\@BAZEL_ROOT\@/$p/; s#-i(system|quote) external/#-i$1 '$OUTPUT_BASE'/external/#g' < "$fname" >> $JSON_OUT
1314
echo "" >> $JSON_OUT
1415
done
1516

0 commit comments

Comments
 (0)