-
Notifications
You must be signed in to change notification settings - Fork 2
/
archlinux_build.sh
118 lines (107 loc) · 4.3 KB
/
archlinux_build.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#/l!/bin/bash
pacman -S --noconfirm clang llvm lld libc++ --overwrite '*'
#link toolchains
if ! ls /usr/bin/clang;then
cd /usr/bin
for i in $(ls *-12)
do
ln -s $i $(echo $i|sed 's/-12//g')
done
fi
# some tool we need
pacman -S --noconfirm expat bison python git rsync curl wget make tar go python3 cmake --overwrite '*'
curl https://storage.googleapis.com/git-repo-downloads/repo > /bin/repo
chmod a+x /bin/repo
git config --global user.email "[email protected]"
git config --global user.name "Saint-Theana"
cd
mkdir llvm-toolchain
cd llvm-toolchain
#this process might stuck at a configuration choice.
repo init -u https://android.googlesource.com/platform/manifest -b llvm-toolchain
#and there is something we dont need to download,so patch it
origin="$(cat .repo/manifests/default.xml)"
deleteline(){
origin="$(echo "$origin"|grep -v "$1")"
}
deleteline "prebuilts/clang"
deleteline "prebuilts/python"
deleteline "prebuilts/go"
deleteline "prebuilts/cmake"
deleteline "prebuilts/gcc"
deleteline "toolchain/prebuilts/ndk/r23"
echo "$origin" >.repo/manifests/default.xml
#sync the repo
repo sync -cj4
#download ndk prebuilt files
mkdir -p toolchain/prebuilts/ndk/
cd toolchain/prebuilts/ndk/
wget -c https://github.com/Saint-Theana/ndk-aarch64-linux/releases/download/r23/android-ndk-r23-linux-aarch64-bionic-ubuntu.1.tar.gz
if ! ls r23;then
tar xvf android-ndk-r23-linux-aarch64-bionic-ubuntu.1.tar.gz
mv android-ndk-r23 r23
fi
#patch build files
cd
cd llvm-toolchain
cd toolchain
git clone https://github.com/Saint-Theana/llvm_android_aarch64_patch
cp -r llvm_android llvm_android_origin
cd llvm_android
for i in $(ls ../llvm_android_aarch64_patch/archlinux_build)
do
patch -p1 <../llvm_android_aarch64_patch/archlinux_build/$i
done
cd
cd llvm-toolchain
#build shader-tools
cd
mkdir shader-tools
cd shader-tools
git clone --depth=1 https://github.com/google/shaderc
cd shaderc/third_party
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers.git spirv-tools/external/spirv-headers
git clone --depth=1 https://github.com/google/googletest.git
git clone --depth=1 https://github.com/google/effcee.git
git clone --depth=1 https://github.com/google/re2.git
git clone --depth=1 https://github.com/KhronosGroup/glslang.git
# start building shaderc...
if ! cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake;then
sed -i '1i\include(CheckCXXCompilerFlag)' ./CMakeLists.txt
mkdir build && cd build
# setting android ndk toolchain
cmake -G "Unix Makefiles" \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_SYSROOT=/ \
-DCMAKE_BUILD_TYPE=Release \
-DEFFCEE_BUILD_TESTING=off \
-DCMAKE_INSTALL_PREFIX=~/llvm-toolchain/toolchain/prebuilts/ndk/r23/shader-tools/linux-aarch64 \
..
make -j8
make install -j8
fi
cd
cd llvm-toolchain
python3 toolchain/llvm_android/build.py --no-build windows
cd
cd llvm-toolchain
rm -r toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/lib64
rm -r toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/lib
rm -r toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/share
rm -r toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/test
rm -r toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/prebuilt_include
rm -r toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/AndroidVersion.txt
for i in $(ls toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/bin)
do
if ! echo $i|grep linux-android;then
rm toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/bin/$i
fi
done
cp -r out/install/linux-x86/clang-dev/bin/* toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/bin
cp -r out/install/linux-x86/clang-dev/lib toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/
cp -r out/install/linux-x86/clang-dev/lib64 toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/
cp -r out/install/linux-x86/clang-dev/share toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/
cp -r out/install/linux-x86/clang-dev/test toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/
cp -r out/install/linux-x86/clang-dev/prebuilt_include toolchain/prebuilts/ndk/r23/toolchains/llvm/prebuilt/linux-aarch64/