Skip to content

Commit 85fe5b4

Browse files
committed
CI: cache binaryen
1 parent d45715c commit 85fe5b4

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,70 @@ jobs:
115115
- run: opam install conf-pkg-config
116116
if: runner.os == 'Windows'
117117

118+
- name: Restore cached binaryen
119+
id: cache-binaryen
120+
uses: actions/cache/restore@v4
121+
with:
122+
path: binaryen
123+
key: ${{ runner.os }}-binaryen-version_118
124+
125+
- name: Checkout binaryen
126+
if: steps.cache-binaryen.outputs.cache-hit != 'true'
127+
uses: actions/checkout@v4
128+
with:
129+
repository: WebAssembly/binaryen
130+
path: binaryen
131+
submodules: true
132+
ref: version_118
133+
134+
- name: Install ninja (Ubuntu)
135+
if: matrix.os == 'ubuntu-latest' && steps.cache-binaryen.outputs.cache-hit != 'true'
136+
run: sudo apt-get install ninja-build
137+
138+
- name: Install ninja (MacOS)
139+
if: matrix.os == 'macos-latest' && steps.cache-binaryen.outputs.cache-hit != 'true'
140+
run: brew install ninja
141+
142+
- name: Build binaryen
143+
if: matrix.os != 'windows-latest' && steps.cache-binaryen.outputs.cache-hit != 'true'
144+
working-directory: ./binaryen
145+
run: |
146+
cmake -G Ninja .
147+
ninja
148+
149+
- name: Install binaryen build dependencies (Windows)
150+
if: matrix.os == 'windows-latest' && steps.cache-binaryen.outputs.cache-hit != 'true'
151+
working-directory: ./binaryen
152+
run: opam install conf-cmake conf-c++
153+
154+
- name: Build binaryen (Windows)
155+
if: matrix.os == 'windows-latest' && steps.cache-binaryen.outputs.cache-hit != 'true'
156+
working-directory: ./binaryen
157+
run: |
158+
opam exec -- cmake . -DBUILD_STATIC_LIB=ON -DBUILD_TESTS=off -DINSTALL_LIBS=off -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc
159+
make -j 4
160+
rm -r src
161+
162+
- name: Cache binaryen
163+
if: steps.cache-binaryen.outputs.cache-hit != 'true'
164+
uses: actions/cache/save@v4
165+
with:
166+
path: binaryen
167+
key: ${{ runner.os }}-binaryen-version_118
168+
169+
- name: Set binaryen's path
170+
shell: bash
171+
run: echo "$GITHUB_WORKSPACE/binaryen/bin" >> $GITHUB_PATH
172+
173+
- name: Copy binaryen's tools (Windows)
174+
if: matrix.os == 'windows-latest'
175+
shell: bash
176+
run: cp $GITHUB_WORKSPACE/binaryen/bin/wasm-{merge,opt}.exe _opam/bin
177+
178+
- name: Install faked binaryen-bin package
179+
# It's faster to use a cached version
180+
run: opam install --fake binaryen-bin
181+
118182
- run: opam install . --best-effort
119183
if: ${{ matrix.skip-test }}
120184

0 commit comments

Comments
 (0)