Skip to content

Commit e5d48f9

Browse files
[ci] unify install-dependencies for each platform
1 parent e8f33db commit e5d48f9

File tree

4 files changed

+68
-107
lines changed

4 files changed

+68
-107
lines changed

utils/webassembly/ci.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ UTILS_PATH=$SWIFT_PATH/utils/webassembly
88

99
case $(uname -s) in
1010
Darwin)
11-
DEPENDENCIES_SCRIPT=$UTILS_PATH/macos/install-dependencies.sh
1211
HOST_SUFFIX=macosx-$(uname -m)
1312
;;
1413
Linux)
15-
DEPENDENCIES_SCRIPT=$UTILS_PATH/linux/install-dependencies.sh
1614
HOST_SUFFIX=linux-$(uname -m)
1715
;;
1816
*)
@@ -28,7 +26,7 @@ BUILD_SDK_PATH="$SOURCE_PATH/build-sdk"
2826

2927
export WASMER_DIR="$BUILD_SDK_PATH/wasmer"
3028

31-
$DEPENDENCIES_SCRIPT "$BUILD_SDK_PATH"
29+
$UTILS_PATH/install-dependencies.sh "$BUILD_SDK_PATH"
3230
$UTILS_PATH/install-build-sdk.sh
3331

3432
export PATH="$BUILD_SDK_PATH/bin:$PATH"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

utils/webassembly/linux/install-dependencies.sh

Lines changed: 0 additions & 85 deletions
This file was deleted.

utils/webassembly/macos/install-dependencies.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)