Skip to content

Commit 0b4e60b

Browse files
committed
CI: install a version on Binaryen with stack-switching support
1 parent 85a9891 commit 0b4e60b

File tree

3 files changed

+100
-6
lines changed

3 files changed

+100
-6
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Install Binaryen
2+
3+
inputs:
4+
repository:
5+
description: 'Repository name with owner. For example, actions/checkout'
6+
default: WebAssembly/binaryen
7+
ref:
8+
description: >
9+
The branch, tag or SHA to checkout. When checking out the repository that
10+
triggered a workflow, this defaults to the reference or SHA for that
11+
event. Otherwise, uses the default branch.
12+
default: latest
13+
build:
14+
description: Whether we should build from source
15+
default: false
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Restore cached binaryen
20+
if: ${{ inputs.build && inputs.build != 'false' }}
21+
id: cache-binaryen
22+
uses: actions/cache/restore@v4
23+
with:
24+
path: binaryen
25+
key: ${{ runner.os }}-binaryen-${{ inputs.ref }}
26+
27+
- name: Checkout binaryen
28+
if: ${{ inputs.build && inputs.build != 'false' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
29+
uses: actions/checkout@v4
30+
with:
31+
repository: ${{ inputs.repository }}
32+
path: binaryen
33+
submodules: true
34+
ref: ${{ inputs.ref == 'latest' && 'main' || inputs.ref }}
35+
36+
- name: Install ninja (Linux)
37+
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Linux' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
38+
shell: bash
39+
run: sudo apt-get install ninja-build
40+
41+
- name: Install ninja (MacOS)
42+
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'macOS' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
43+
shell: bash
44+
run: brew install ninja
45+
46+
- name: Build binaryen
47+
if: ${{ inputs.build && inputs.build != 'false' && runner.os != 'Windows' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
48+
working-directory: ./binaryen
49+
shell: bash
50+
run: |
51+
cmake -G Ninja .
52+
ninja
53+
54+
- name: Install binaryen build dependencies (Windows)
55+
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Windows' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
56+
working-directory: ./binaryen
57+
shell: bash
58+
run: opam install conf-cmake conf-c++
59+
60+
- name: Build binaryen (Windows)
61+
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Windows' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
62+
working-directory: ./binaryen
63+
shell: bash
64+
run: |
65+
opam exec -- cmake . -DBUILD_STATIC_LIB=ON -DBUILD_TESTS=off -DINSTALL_LIBS=off -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc
66+
make -j 4
67+
68+
- name: Cache binaryen
69+
if: ${{ inputs.build && inputs.build != 'false' && steps.cache-binaryen.outputs.cache-hit != 'true' }}
70+
uses: actions/cache/save@v4
71+
with:
72+
path: binaryen
73+
key: ${{ runner.os }}-binaryen-${{ inputs.ref }}
74+
75+
- name: Set binaryen's path
76+
if: ${{ inputs.build && inputs.build != 'false' && runner.os != 'Windows' }}
77+
shell: bash
78+
run: echo "$GITHUB_WORKSPACE/binaryen/bin" >> $GITHUB_PATH
79+
80+
- name: Copy binaryen's tools (Windows)
81+
if: ${{ inputs.build && inputs.build != 'false' && runner.os == 'Windows' }}
82+
shell: bash
83+
run: cp $GITHUB_WORKSPACE/binaryen/bin/wasm-{merge,opt}.exe _opam/bin
84+
85+
- name: Download Binaryen
86+
if: ${{ ! inputs.build || inputs.build == 'false' }}
87+
uses: Aandreba/[email protected]
88+
with:
89+
token: ${{ github.token }}
90+
version: ${{ inputs.ref }}

.github/workflows/build-wasm_of_ocaml.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ jobs:
152152
with:
153153
ocaml-compiler: ${{ matrix.ocaml-compiler }}
154154

155-
- name: Set-up Binaryen
156-
uses: Aandreba/setup-binaryen@v1.0.0
155+
- name: Install Binaryen
156+
uses: ./wasm_of_ocaml/.github/actions/install-binaryen
157157
with:
158-
token: ${{ github.token }}
158+
build: true
159+
repository: vouillon/binaryen
160+
ref: stack-switching-fixes
159161

160162
- name: Pin faked binaryen-bin package
161163
# It's faster to use a cached version

.github/workflows/build.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ jobs:
127127
- run: opam install conf-pkg-config conf-mingw-w64-g++-i686 conf-mingw-w64-g++-x86_64
128128
if: runner.os == 'Windows'
129129

130-
- name: Set-up Binaryen
131-
uses: Aandreba/setup-binaryen@v1.0.0
130+
- name: Install Binaryen
131+
uses: ./.github/actions/install-binaryen
132132
with:
133-
token: ${{ github.token }}
133+
build: true
134+
repository: vouillon/binaryen
135+
ref: stack-switching-fixes
134136

135137
- name: Install faked binaryen-bin package
136138
# It's faster to use a cached version

0 commit comments

Comments
 (0)