forked from firedancer-io/firedancer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathactivate
More file actions
executable file
·85 lines (72 loc) · 2.08 KB
/
Copy pathactivate
File metadata and controls
executable file
·85 lines (72 loc) · 2.08 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
for arg in "$@"; do
case "$arg" in
help|--help)
echo "Usage: source activate [CC=clang] [EXTRAS=...] [MACHINE=...] [BUILDDIR=...]"
exit 0
;;
esac
done
# Ignore variables set in existing environment.
unset BUILDDIR1
unset BUILDDIR
unset OBJDIR
unset MACHINE
unset EXTRAS
unset CC
# Auto-derive environment variables from the above 5 input variables.
_fd_env_make_env=$(make env "$@") || return
eval "$_fd_env_make_env"
unset _fd_env_make_env
if [ -z "${OBJDIR+x}" ] || [ -z "$OBJDIR" ]; then
printf '%s\n' 'activate: OBJDIR is not set' >&2
return
fi
# Re-export, so future `make` invocations match.
echo "Firedancer build directory is $OBJDIR"
export OBJDIR
export MACHINE
export EXTRAS
export CC
BUILDDIR1="$BUILDDIR"
export BUILDDIR1
# Update PATH to exclude stale build dirs,
# and include OBJDIR bin, unit-test, and fuzz-test
_fd_env_script=${BASH_SOURCE[0]:-$0}
_fd_env_script_dir=$(CDPATH= cd -- "$(dirname -- "$_fd_env_script")" 2>/dev/null && pwd -P)
_fd_env_root=$_fd_env_script_dir
_fd_env_old_path=${PATH-}
_fd_env_new_path=
while [ -n "$_fd_env_old_path" ]; do
case $_fd_env_old_path in
*:*)
_fd_env_path_entry=${_fd_env_old_path%%:*}
_fd_env_old_path=${_fd_env_old_path#*:}
;;
*)
_fd_env_path_entry=$_fd_env_old_path
_fd_env_old_path=
;;
esac
case $_fd_env_path_entry in
/*) _fd_env_path_match=$_fd_env_path_entry ;;
*) _fd_env_path_match=$PWD/$_fd_env_path_entry ;;
esac
if [ -d "$_fd_env_path_match" ]; then
_fd_env_path_match=$(CDPATH= cd -- "$_fd_env_path_match" 2>/dev/null && pwd -P)
fi
case $_fd_env_path_match in
"$_fd_env_root"| "$_fd_env_root"/*) continue ;;
esac
if [ -z "$_fd_env_new_path" ]; then
_fd_env_new_path=$_fd_env_path_entry
else
_fd_env_new_path=$_fd_env_new_path:$_fd_env_path_entry
fi
done
PATH=$OBJDIR/bin:$OBJDIR/fuzz-test:$OBJDIR/unit-test
if [ -n "$_fd_env_new_path" ]; then
PATH=$PATH:$_fd_env_new_path
fi
export PATH
unset _fd_env_old_path _fd_env_new_path _fd_env_path_entry
unset _fd_env_path_match _fd_env_root _fd_env_script _fd_env_script_dir