-
Notifications
You must be signed in to change notification settings - Fork 9
/
.mac-setup.sh
executable file
·111 lines (91 loc) · 4.17 KB
/
.mac-setup.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
#!/usr/bin/env bash
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
# Formatting
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
GREEN=$(tput setaf 2)
WHITE=$(tput setaf 15)
NC=$(tput sgr0)
# Environment
EMSDK_VERSION=${EMSDK_VERSION:-latest}
UNIFFI_BINDGEN_CPP_VERSION=${UNIFFI_BINDGEN_CPP_VERSION:-"v0.6.3+v0.25.0"}
die() { printf %s "${@+$@$'\n'}" 1>&2 ; exit 1; }
check_for() {
local -r app=$1
local install_url=$2
if [[ -n "${install_url}" ]]; then
install_url=", ${YELLOW}please install it first${NC}: ${install_url}"
fi
echo "Checking for ${GREEN}${app}${NC} ..."
if ! which "${app}" &>/dev/null; then
echo "${RED}=>${NC} Could not find ${app}${install_url}"
local -r instructions=$3
if [[ -n "$instructions" ]]; then
echo "${instructions}"
fi
exit 1
fi
}
check_for xcodebuild
check_for brew "https://brew.sh"
check_for rustup "https://rustup.rs" "\
1. Choose the ${GREEN}default${NC} installation option
2. Either logout & login after the installation, or execute: ${YELLOW}source \"\$HOME/.cargo/env\""
echo "Installing v1.4.1 of Meson..."
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/2f89922685ce82af272fe045178f63bfb3bc7289/Formula/m/meson.rb > meson.rb
brew install meson.rb
echo "Installing brew package(s) ..."
brew install android-ndk \
cmake \
nasm \
ninja \
pkg-config \
ktlint \
swiftformat \
conan
rustup component add rust-src
echo
echo "Installing rust target(s) ..."
rustup target add aarch64-linux-android \
armv7-linux-androideabi \
x86_64-linux-android \
i686-linux-android \
aarch64-apple-darwin \
x86_64-apple-darwin \
aarch64-apple-ios \
x86_64-apple-ios \
aarch64-apple-ios-sim \
wasm32-unknown-emscripten
echo "Installing nightly toolchain"
rustup install nightly
rustup component add rust-src --toolchain nightly
rustup target add wasm32-unknown-emscripten --toolchain nightly
echo
echo "Installing cargo dependencies"
cargo install uniffi-bindgen-cpp \
--git https://github.com/NordSecurity/uniffi-bindgen-cpp \
--tag "${UNIFFI_BINDGEN_CPP_VERSION}"
echo
echo "Setting up project ..."
make deps
echo
echo "Setting up emsdk"
cd "${SCRIPT_DIR}/deps/modules/emsdk" || die "Could not find Emscripten SDK under ${RED}deps/modules/emsdk${NC}!"
./emsdk install "${EMSDK_VERSION}"
./emsdk activate "${EMSDK_VERSION}"
cd "${SCRIPT_DIR}/deps/modules/emsdk/upstream/emscripten" || die "Could not find Emscripten under ${RED}deps/modules/emsdk/upstream/emscripten${NC}!"
npm install
echo
echo "Disabling unneeded webp features"
cd "${SCRIPT_DIR}/deps/modules/libwebp" || die "Could not find libwebp under ${RED}deps/modules/libwep${NC}!"
file_path="${SCRIPT_DIR}/deps/modules/libwebp/CMakeLists.txt"
# Use sed to replace the specified lines
sed -i -e 's/option(WEBP_BUILD_ANIM_UTILS "Build animation utilities." ON)/option(WEBP_BUILD_ANIM_UTILS "Build animation utilities." OFF)/' "$file_path"
sed -i -e 's/option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." ON)/option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." OFF)/' "$file_path"
echo
echo "${WHITE}Setup completed!${NC}"
echo " 1. If your ${GREEN}ANDROID_NDK_HOME${NC} was not installed to ${YELLOW}/opt/homebrew/share/android-ndk${NC}, export it's location in your shell profile"
echo " 2. You can now run ${YELLOW}make${NC} to see information on available build targets, or ${YELLOW}make all${NC} to build everything"
echo " 3. After building everything, all following calls to ${YELLOW}make all${NC} will be incremental, i.e. it will reuse things that have already been built"
echo " 4. If you don't define ${GREEN}APPLE_XCODE_APP_NAME${NC} under the format ${YELLOW}Xcode_[version].app${NC}, it will default to Xcode_13.3.1.app which might not be present on your system in: /Applications/. To use the latest version of Xcode on your system, set to: \"Xcode.app\"."
echo " 5. If you don't define ${GREEN}APPLE_MACOSX_SDK${NC} under the format ${YELLOW}MacOSX[version]${NC}, it will default to MacOSX12.3 which might not be present on your system under: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/. To use the latest version of Xcode on your system, set to: \"MacOSX\"."