-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.sh
executable file
·111 lines (90 loc) · 2.67 KB
/
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
#!/bin/bash
set -euxo
source config.sh
# verify build requirements are present
if ! command -v cmake &> /dev/null; then
echo "cmake not found. Try: brew install cmake"
exit 1
fi
if ! command -v ninja &> /dev/null; then
echo "ninja not found. Try: brew install ninja"
exit 1
fi
if ! command -v openssl &> /dev/null; then
echo "openssl not found. Try: brew install openssl"
exit 1
fi
# setup openssl environment
set +x
# default lookup directory prior to 2022.06
export OPENSSL_DIR='/usr/local/opt/openssl'
export OPENSSL_STATIC=1
if [ ! -d "$OPENSSL_DIR" ]; then
printf "OpenSSL not found at expected location (%s). Trying another location...\n" "${OPENSSL_DIR}"
# location where brew installs the latest openssl version (in 2022.06)
export OPENSSL_DIR='/opt/homebrew/opt/openssl@3'
if [ ! -d "$OPENSSL_DIR" ]; then
printf "OpenSSL not found at expected location (%s). Trying another location...\n" "${OPENSSL_DIR}"
# location where macports installs the latest openssl version (in 2022.06)
export OPENSSL_DIR='/opt/local/libexec/openssl3'
if [ ! -d "$OPENSSL_DIR" ]; then
printf "OpenSSL not found at expected location (%s). Try: brew install openssl\n" "${OPENSSL_DIR}"
exit 1
fi
fi
fi
echo "OPENSSL_DIR=${OPENSSL_DIR}"
echo "OPENSSL_STATIC=${OPENSSL_STATIC}"
# setup work directory
set -x
WORKING_DIR="$(pwd)/build"
mkdir -p "$WORKING_DIR"
cd "$WORKING_DIR"
if [ ! -d "llvm-project" ]; then
git clone \
--shallow-since="1 year" --no-single-branch \
https://github.com/apple/llvm-project.git \
;
fi
(cd "llvm-project"
git reset --hard
git clean -f
git checkout "$LLVM_BRANCH"
git apply ../../patches/llvm-system-libs.patch
)
# setup llvm build directory
mkdir -p llvm-build
(cd llvm-build
cmake \
"$WORKING_DIR/llvm-project/llvm" \
-DCMAKE_INSTALL_PREFIX="$WORKING_DIR/llvm-root" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64' \
-G Ninja \
;
ninja
ninja install
)
# clone rust repo
if [ ! -d "rust" ]; then
git clone https://github.com/rust-lang/rust.git
fi
(cd rust
git reset --hard
git clean -f
git checkout "$RUST_BRANCH"
)
# setup rust build directory
mkdir -p rust-build
(cd rust-build
../rust/configure \
--llvm-config="$WORKING_DIR/llvm-root/bin/llvm-config" \
--target=aarch64-apple-ios \
--enable-extended \
--tools=cargo \
--release-channel=nightly \
;
CFLAGS_aarch64_apple_ios=-fembed-bitcode \
python "$WORKING_DIR/rust/x.py" build --stage 2
)