-
Notifications
You must be signed in to change notification settings - Fork 2
/
llvm-symlinks.sh
executable file
·62 lines (51 loc) · 1.47 KB
/
llvm-symlinks.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
#!/bin/bash
read -r -d '' USAGE << EOM
Usage:
llvm-symlinks.sh <version>
Symlink llvm and clang programs in /usr/bin/ for the given version.
Example:
llvm-symlinks.sh 11
It will symlink in /usr/bin/ the following programs:
/usr/lib/llvm-11/bin/* (except scan-build and scan-view)
/usr/lib/llvm-11/lib/clang/11.*/bin/hwasan_symbolize
/usr/lib/llvm-11/share/clang/*.py
/usr/share/clang/scan-build-11/bin/scan-build
/usr/share/clang/scan-build-py-11/bin/scan-build-py
/usr/share/clang/scan-view-11/bin/scan-view
EOM
if [ $# -ne 1 ]; then
echo "$USAGE"
exit 1
fi
ver="$1"
if [[ $ver == "-h" || $ver == "--help" ]]; then
echo "$USAGE"
exit 1
fi
cd /usr/bin
for fp in $(find /usr/lib/llvm-$ver/bin -maxdepth 1 -perm -u=x -a -not -type l -a -not -type d); do
fn="${fp##*/}"
if [[ $fn == "scan-view" || $fn == "scan-build" ]]; then
continue
fi
if [[ ! -f $fn || -L $fn ]]; then
sudo /bin/rm -f $fn
sudo ln -s $fp .
fi
done
for fp in /usr/lib/llvm-$ver/lib/clang/$ver.*/bin/hwasan_symbolize \
/usr/lib/llvm-$ver/share/clang/*.py /usr/share/clang/scan-build-$ver/bin/scan-build \
/usr/share/clang/scan-build-py-$ver/bin/scan-build-py \
/usr/share/clang/scan-view-$ver/bin/scan-view ; do
fn="${fp##*/}"
if [[ ! -f $fn || -L $fn ]]; then
sudo /bin/rm -f $fn
sudo ln -s $fp .
fi
done
#special case:
fn=scan-build-py
if [[ ! -f $fn || -L $fn ]]; then
sudo /bin/rm -f $fn
sudo ln -s /usr/share/clang/scan-build-py-$ver/bin/scan-build $fn
fi