-
Notifications
You must be signed in to change notification settings - Fork 0
/
find-tool.sh
executable file
·65 lines (58 loc) · 1.24 KB
/
find-tool.sh
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
#!/bin/bash
#
# Find both clang and llvm-ar with the same version.
#
# Tries first without an explicit version, then down from
# 14 to 6.
set -euo pipefail
if [ -z "$@" ]; then
echo "ERROR: find-tool.sh needs an argument: --cc, --ar, or --debug" 2>&1
exit 1
fi
debug=false
AR_TOOLS="llvm-ar llvm-ar-14 llvm-ar-13 llvm-ar-12 llvm-ar-11 llvm-ar-10 \
gcc-ar gcc-ar-12 gcc-ar-11 gcc-ar-10 gcc-ar-9 \
ar"
CC_TOOLS="clang clang-14 clang-13 clang-12 clang-11 clang-10 \
gcc gcc-12 gcc-11 gcc-10 gcc-9 \
cc"
list_path() {
IFS=:
for dir in $PATH; do
echo "---"
echo "PATH: $dir"
ls -C $dir || true
done
}
find_tool() {
for tool in $@; do
if $tool --version &> /dev/null; then
if $debug; then
echo "Found: $tool"
else
echo $tool
fi
return
else
if $debug; then
echo "Not found: $tool"
fi
continue
fi
done
}
case $1 in
--debug)
debug=true
find_tool $AR_TOOLS
find_tool $CC_TOOLS
list_path
exit
;;
--ar)
find_tool $AR_TOOLS
;;
--cc)
find_tool $CC_TOOLS
;;
esac