Skip to content

Commit b6d9cce

Browse files
committed
Allow cloning llvm and rust separately
1 parent 8f0d8b9 commit b6d9cce

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

common.sh

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ git_clone_sha() {
4949
local dir=${1##*/}
5050
mkdir "$dir"
5151
cd "$dir"
52-
git init
52+
git init -q
5353
git remote add origin $1
5454
git fetch --depth 1 origin $2
5555
git reset --hard FETCH_HEAD
@@ -60,17 +60,13 @@ git_clone_branch() {
6060
git clone --single-branch --depth 1 --branch $2 $1
6161
}
6262

63-
clone() {
64-
git_clone_branch https://github.com/rust-lang/rust $RUST_VERSION
65-
cd rust
66-
for p in ../patches/*.patch; do
67-
patch -p1 < $p
68-
done
69-
# Skip rust llvm
70-
sed 's:\[submodule "src/llvm-project"\]:&\n\tupdate = none:' .gitmodules > .gitmodules.p
63+
skip_submodule() {
64+
sed "s:.*submodule.*$1.*:&\n\tupdate = none:" .gitmodules > .gitmodules.p
7165
mv .gitmodules.p .gitmodules
72-
git submodule update --init --depth=1
73-
cd ../
66+
}
67+
68+
clone_llvm() {
69+
rm -rf llvm-project llvm_android toolchain-utils
7470

7571
git_clone_sha https://android.googlesource.com/toolchain/llvm-project $LLVM_VERSION
7672
git_clone_sha https://android.googlesource.com/toolchain/llvm_android $LLVM_ANDROID_VERSION
@@ -81,10 +77,33 @@ clone() {
8177
--svn_version $LLVM_SVN \
8278
--patch_metadata_file llvm_android/patches/PATCHES.json \
8379
--src_path llvm-project
80+
}
8481

85-
# Move the NDK LLVM into Rust's source
86-
rm -rf rust/src/llvm-project
87-
mv llvm-project rust/src/llvm-project
82+
clone_rust() {
83+
rm -rf rust
84+
85+
git_clone_branch https://github.com/rust-lang/rust $RUST_VERSION
86+
cd rust
87+
88+
# Skip unused submodules
89+
skip_submodule llvm-project
90+
skip_submodule enzyme
91+
skip_submodule gcc
92+
skip_submodule doc
93+
94+
# Clone submodules
95+
git submodule update --init --depth=1
96+
97+
# Apply patches
98+
for p in ../patches/*.patch; do
99+
patch -p1 < $p
100+
done
101+
102+
# Link NDK LLVM into Rust's source
103+
rm -rf src/llvm-project
104+
ln -s ../../llvm-project src/llvm-project
105+
106+
cd ../
88107
}
89108

90109
update_dir() {
@@ -129,8 +148,14 @@ dist() {
129148
run_cmd() {
130149
case $1 in
131150
clone)
132-
rm -rf rust llvm-project llvm_android toolchain-utils
133-
clone
151+
clone_llvm
152+
clone_rust
153+
;;
154+
clone-llvm)
155+
clone_llvm
156+
;;
157+
clone-rust)
158+
clone_rust
134159
;;
135160
build)
136161
rm -rf rust-out

0 commit comments

Comments
 (0)