Skip to content

Commit f14e320

Browse files
committed
Install Binaryen for wasm_of_ocaml
Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent 578d356 commit f14e320

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,35 @@ LABEL org.opencontainers.image.description="Docker image for ReScript developmen
44

55
RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \
66
&& apt-get -y install --no-install-recommends \
7+
binaryen \
78
cmake \
89
musl-tools \
910
ninja-build \
1011
&& rm -rf /var/lib/apt/lists/*
1112

13+
# wasm_of_ocaml requires Binaryen 119 or newer.
14+
ARG BINARYEN_VERSION=131
15+
RUN case "$(dpkg --print-architecture)" in \
16+
amd64) \
17+
binaryen_platform=x86_64-linux; \
18+
binaryen_checksum=b5bf1f0eaf17c63ee588ff7a5954dc8f6ce2c26989051c66f24dfe9ece3e46db \
19+
;; \
20+
arm64) \
21+
binaryen_platform=aarch64-linux; \
22+
binaryen_checksum=ba991f677edd9a21d2bc96c0144bc8ac5b112d4d98a3eb266e075e22e557df2a \
23+
;; \
24+
*) echo "Unsupported Binaryen architecture" >&2; exit 1 ;; \
25+
esac \
26+
&& binaryen_archive="binaryen-version_${BINARYEN_VERSION}-${binaryen_platform}.tar.gz" \
27+
&& curl -fsSL \
28+
"https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/${binaryen_archive}" \
29+
-o "/tmp/${binaryen_archive}" \
30+
&& echo "${binaryen_checksum} /tmp/${binaryen_archive}" | sha256sum --check \
31+
&& sudo mkdir -p /opt/binaryen \
32+
&& sudo tar -xzf "/tmp/${binaryen_archive}" --strip-components=1 -C /opt/binaryen \
33+
&& rm "/tmp/${binaryen_archive}"
34+
ENV PATH="/opt/binaryen/bin:${PATH}"
35+
1236
# Install OPAM
1337
ARG OPAM_VERSION=2.5.0
1438
RUN printf '\n\n' | bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version $OPAM_VERSION"

.github/actions/setup-ocaml/action.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,51 @@ outputs:
2323
runs:
2424
using: composite
2525
steps:
26+
- name: Install Binaryen
27+
if: runner.os != 'Windows'
28+
shell: bash
29+
env:
30+
BINARYEN_VERSION: "131"
31+
run: |
32+
case "$RUNNER_OS-$RUNNER_ARCH" in
33+
Linux-X64)
34+
platform=x86_64-linux
35+
checksum=b5bf1f0eaf17c63ee588ff7a5954dc8f6ce2c26989051c66f24dfe9ece3e46db
36+
;;
37+
Linux-ARM64)
38+
platform=aarch64-linux
39+
checksum=ba991f677edd9a21d2bc96c0144bc8ac5b112d4d98a3eb266e075e22e557df2a
40+
;;
41+
macOS-X64)
42+
platform=x86_64-macos
43+
checksum=d209fadd8a894bdaf3bd3612a23c32a0af184d2f4a979b8c789e6e4f6a4de883
44+
;;
45+
macOS-ARM64)
46+
platform=arm64-macos
47+
checksum=e441b48dc22163d209b4f05e44dc7210909b01237642b6c9ae48fd710a3ef83e
48+
;;
49+
*)
50+
echo "Unsupported Binaryen platform: $RUNNER_OS-$RUNNER_ARCH" >&2
51+
exit 1
52+
;;
53+
esac
54+
55+
archive="binaryen-version_${BINARYEN_VERSION}-${platform}.tar.gz"
56+
install_dir="$RUNNER_TOOL_CACHE/binaryen/$BINARYEN_VERSION/$RUNNER_ARCH"
57+
curl -fsSL \
58+
"https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/${archive}" \
59+
-o "$RUNNER_TEMP/$archive"
60+
61+
if [[ "$RUNNER_OS" == "macOS" ]]; then
62+
echo "$checksum $RUNNER_TEMP/$archive" | shasum -a 256 --check
63+
else
64+
echo "$checksum $RUNNER_TEMP/$archive" | sha256sum --check
65+
fi
66+
67+
mkdir -p "$install_dir"
68+
tar -xzf "$RUNNER_TEMP/$archive" --strip-components=1 -C "$install_dir"
69+
echo "$install_dir/bin" >> "$GITHUB_PATH"
70+
2671
- name: Get OPAM cache key
2772
id: cache-key
2873
shell: bash

0 commit comments

Comments
 (0)