|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -ex |
| 4 | + |
| 5 | +install_wasmer() { |
| 6 | + if [ "$(uname -m)" != "aarch64" ]; then |
| 7 | + export WASMER_DIR="${WASMER_DIR:-$HOME/.wasmer}" |
| 8 | + if [ ! -e "$WASMER_DIR" ]; then |
| 9 | + curl https://get.wasmer.io -sSfL | sh -s "2.1.1" |
| 10 | + ln -sf "$WASMER_DIR/bin/wasmer" "$DESTDIR/bin/wasmer" |
| 11 | + fi |
| 12 | + else |
| 13 | + echo "FIXME: Wasmer doesn't support linux-aarch64, consider using a different WASI-compatible runtime." |
| 14 | + fi |
| 15 | +} |
| 16 | + |
| 17 | +install_linux_cmake() { |
| 18 | + local version="3.22.1" |
| 19 | + local workdir="$(mktemp -d)" |
| 20 | + curl -L -o "$workdir/install_cmake.sh" "https://github.com/Kitware/CMake/releases/download/v$version/cmake-$version-linux-$(uname -m).sh" |
| 21 | + chmod +x "$workdir/install_cmake.sh" |
| 22 | + mkdir -p "$DESTDIR/cmake" |
| 23 | + "$workdir/install_cmake.sh" --skip-license --prefix="$DESTDIR/cmake" |
| 24 | + ln -sf "$DESTDIR/cmake/bin"/* "$DESTDIR/bin" |
| 25 | +} |
| 26 | + |
| 27 | +install_linux_sccache() { |
| 28 | + local version="v0.3.0" |
| 29 | + mkdir "$DESTDIR/sccache" |
| 30 | + ( |
| 31 | + cd "$DESTDIR/sccache" && \ |
| 32 | + curl -L "https://github.com/mozilla/sccache/releases/download/$version/sccache-$version-$(uname -m)-unknown-linux-musl.tar.gz" | \ |
| 33 | + tar xz --strip-components 1 |
| 34 | + ) |
| 35 | + chmod +x "$DESTDIR/sccache/sccache" |
| 36 | + ln -sf "$DESTDIR/sccache/sccache" "$DESTDIR/bin/sccache" |
| 37 | +} |
| 38 | + |
| 39 | +DESTDIR="$1" |
| 40 | +mkdir -p "$DESTDIR" |
| 41 | +mkdir -p "$DESTDIR/bin" |
| 42 | + |
| 43 | +SOURCE_PATH="$(cd "$(dirname $0)/../../.." && pwd)" |
| 44 | +SWIFT_PATH=$SOURCE_PATH/swift |
| 45 | +cd $SWIFT_PATH |
| 46 | + |
| 47 | +case $(uname -s) in |
| 48 | + Darwin) |
| 49 | + brew bundle |
| 50 | + ;; |
| 51 | + Linux) |
| 52 | + if [ ! -e "$DESTDIR/bin/cmake" ]; then |
| 53 | + install_linux_cmake |
| 54 | + fi |
| 55 | + if [ ! -e "$DESTDIR/bin/sccache" ]; then |
| 56 | + install_linux_sccache |
| 57 | + fi |
| 58 | + ;; |
| 59 | + *) |
| 60 | + echo "Unrecognised platform $(uname -s)" |
| 61 | + exit 1 |
| 62 | + ;; |
| 63 | +esac |
| 64 | +install_wasmer |
| 65 | + |
| 66 | +cd $SWIFT_PATH |
| 67 | +./utils/update-checkout --clone --scheme wasm --skip-repository swift |
0 commit comments