forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
path_fix.sh
executable file
·23 lines (22 loc) · 1007 Bytes
/
path_fix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# This script can be used to run bazel commands. It will attempt to translate paths in compiler
# error messages to real system paths (vs. bazel symbolic links) which may be necessary for some
# IDEs to properly associate error messages to files.
# To invoke, do something like:
# tools/path_fix.sh bazel build //test/...
#
# NOTE: This implementation is far from perfect and will need to be refined to cover all cases.
$* 2>&1 |
while IFS= read -r LINE
do
if [[ "${LINE}" =~ [[:space:]]*([^:[:space:]]+):[[:digit:]]+:[[:digit:]]+: ]]; then
REAL_PATH=$(readlink -f "${BASH_REMATCH[1]}")
# Bazel now appears to sometimes spit out paths that don't actually exist on disk at all. I
# have no idea why this is happening (sigh). This check makes it so that if readlink fails we
# don't attempt to fix the path and just print out what we got.
if [[ $? == 0 ]]; then
LINE=${LINE//${BASH_REMATCH[1]}/${REAL_PATH}}
fi
fi
echo "${LINE}"
done