-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_ios_vcpkg.sh
More file actions
executable file
·161 lines (138 loc) · 4.76 KB
/
Copy pathsetup_ios_vcpkg.sh
File metadata and controls
executable file
·161 lines (138 loc) · 4.76 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd -- "$SCRIPT_DIR/.." && pwd)"
CLIPP_CACHE_DIR="${CLIPP_CACHE_DIR:-$HOME/Library/Caches/clipp}"
VCPKG_ROOT="${VCPKG_ROOT:-$CLIPP_CACHE_DIR/vcpkg}"
VCPKG_DEFAULT_BINARY_CACHE="${VCPKG_DEFAULT_BINARY_CACHE:-$CLIPP_CACHE_DIR/vcpkg-binary-cache}"
VCPKG_INSTALLED_DIR="$REPO_ROOT/vcpkg-installed"
VCPKG_STAGING_INSTALLED_DIR="$CLIPP_CACHE_DIR/vcpkg-ios-installed"
OVERLAY_TRIPLETS="$REPO_ROOT/src/vcpkg-triplets"
IOS_DEVICE_TRIPLET="arm64-ios"
IOS_SIMULATOR_TRIPLET="arm64-ios-simulator"
export VCPKG_ROOT
export VCPKG_DEFAULT_BINARY_CACHE
export VCPKG_BINARY_SOURCES="${VCPKG_BINARY_SOURCES:-clear;files,$VCPKG_DEFAULT_BINARY_CACHE,readwrite}"
usage() {
cat <<EOF
Usage: $(basename "$0") [--device-only] [--simulator-only] [--triplet TRIPLET] [--clean]
Installs iOS vcpkg dependencies into:
$VCPKG_INSTALLED_DIR
Uses per-triplet staging roots under:
$VCPKG_STAGING_INSTALLED_DIR
Default triplets:
device: $IOS_DEVICE_TRIPLET
simulator: $IOS_SIMULATOR_TRIPLET
EOF
}
install_device=1
install_simulator=1
custom_triplets=()
clean=0
while [[ $# -gt 0 ]]; do
case "$1" in
--device-only)
install_device=1
install_simulator=0
shift
;;
--simulator-only)
install_device=0
install_simulator=1
shift
;;
--triplet)
[[ $# -ge 2 ]] || { echo "[!] --triplet requires a value." >&2; exit 2; }
custom_triplets+=("$2")
shift 2
;;
--clean)
clean=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "[!] Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
done
need_tool() {
command -v "$1" >/dev/null 2>&1 || {
echo "[!] Fatal: $1 is required but was not found in PATH." >&2
return 1
}
}
need_tool git
need_tool xcrun
need_tool ditto
if ! command -v autoconf >/dev/null 2>&1 \
|| ! command -v automake >/dev/null 2>&1 \
|| ! command -v autoreconf >/dev/null 2>&1 \
|| { ! command -v libtoolize >/dev/null 2>&1 && ! command -v glibtoolize >/dev/null 2>&1; }; then
cat >&2 <<'EOF'
[!] Missing autotools required by libsodium's vcpkg port.
With MacPorts:
sudo port install autoconf autoconf-archive automake libtool
With Homebrew:
brew install autoconf autoconf-archive automake libtool
EOF
exit 1
fi
xcrun --sdk iphoneos --show-sdk-path >/dev/null
xcrun --sdk iphonesimulator --show-sdk-path >/dev/null
if [[ "$clean" == "1" ]]; then
echo "[*] Cleaning iOS vcpkg install root: $VCPKG_INSTALLED_DIR"
rm -rf "$VCPKG_INSTALLED_DIR"
echo "[*] Cleaning iOS vcpkg staging root: $VCPKG_STAGING_INSTALLED_DIR"
rm -rf "$VCPKG_STAGING_INSTALLED_DIR"
fi
mkdir -p "$(dirname "$VCPKG_ROOT")" "$VCPKG_DEFAULT_BINARY_CACHE" "$VCPKG_INSTALLED_DIR" "$VCPKG_STAGING_INSTALLED_DIR"
TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
if [[ ! -f "$TOOLCHAIN_FILE" ]]; then
if [[ ! -e "$VCPKG_ROOT" || -z "$(ls -A "$VCPKG_ROOT" 2>/dev/null)" ]]; then
echo "[*] Cloning vcpkg into $VCPKG_ROOT..."
git clone https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT"
else
echo "[!] Fatal: $VCPKG_ROOT exists but does not look like a vcpkg checkout." >&2
exit 1
fi
fi
if [[ ! -x "$VCPKG_ROOT/vcpkg" ]]; then
echo "[*] Bootstrapping vcpkg..."
"$VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics
fi
triplets=()
if [[ "${#custom_triplets[@]}" -gt 0 ]]; then
triplets=("${custom_triplets[@]}")
else
[[ "$install_device" == "1" ]] && triplets+=("$IOS_DEVICE_TRIPLET")
[[ "$install_simulator" == "1" ]] && triplets+=("$IOS_SIMULATOR_TRIPLET")
fi
extra_options=(--clean-buildtrees-after-build --clean-packages-after-build)
for triplet in "${triplets[@]}"; do
echo "[*] Installing vcpkg manifest for $triplet..."
triplet_install_root="$VCPKG_STAGING_INSTALLED_DIR/$triplet"
(
cd "$REPO_ROOT/src"
"$VCPKG_ROOT/vcpkg" install \
--triplet "$triplet" \
--overlay-triplets "$OVERLAY_TRIPLETS" \
--x-install-root="$triplet_install_root" \
"${extra_options[@]}"
)
triplet_source_dir="$triplet_install_root/$triplet"
triplet_target_dir="$VCPKG_INSTALLED_DIR/$triplet"
[[ -d "$triplet_source_dir" ]] || {
echo "[!] Fatal: expected vcpkg output was not created: $triplet_source_dir" >&2
exit 1
}
echo "[*] Publishing $triplet to $triplet_target_dir..."
rm -rf "$triplet_target_dir"
ditto "$triplet_source_dir" "$triplet_target_dir"
done
echo "[*] iOS vcpkg dependencies are ready under $VCPKG_INSTALLED_DIR"