forked from bazelbuild/rules_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_wrapper.sh
More file actions
executable file
·47 lines (42 loc) · 1.2 KB
/
process_wrapper.sh
File metadata and controls
executable file
·47 lines (42 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
set -eu
# Skip the first argument which is expected to be `--`
shift
# Derive output_base and exec_root so we can expand their placeholders
# in rustc flags (e.g. --remap-path-prefix, -oso_prefix). This mirrors
# the logic in options.rs used by the real process wrapper.
phys_pwd=$(cd -P . && pwd)
if [ -d "external" ]; then
output_base=$(cd -P external/.. && pwd)
else
output_base="${phys_pwd%/*}"
output_base="${output_base%/*}"
fi
workspace_name="${phys_pwd##*/}"
exec_root="${output_base}/execroot/${workspace_name}"
for arg in "$@"; do
case "$arg" in
*'${pwd}'*)
prefix="${arg%%\$\{pwd\}*}"
suffix="${arg#*\$\{pwd\}}"
arg="${prefix}${phys_pwd}${suffix}"
;;
esac
case "$arg" in
*'${output_base}'*)
prefix="${arg%%\$\{output_base\}*}"
suffix="${arg#*\$\{output_base\}}"
arg="${prefix}${output_base}${suffix}"
;;
esac
case "$arg" in
*'${exec_root}'*)
prefix="${arg%%\$\{exec_root\}*}"
suffix="${arg#*\$\{exec_root\}}"
arg="${prefix}${exec_root}${suffix}"
;;
esac
set -- "$@" "$arg"
shift
done
exec "$@"