@@ -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+
161+ - name : Cache binaryen
162+ if : steps.cache-binaryen.outputs.cache-hit != 'true'
163+ uses : actions/cache/save@v4
164+ with :
165+ path : binaryen
166+ key : ${{ runner.os }}-binaryen-version_118
167+
168+ - name : Set binaryen's path
169+ shell : bash
170+ run : echo "$GITHUB_WORKSPACE/binaryen/bin" >> $GITHUB_PATH
171+
172+ - name : Copy binaryen's tools (Windows)
173+ if : matrix.os == 'windows-latest'
174+ shell : bash
175+ # Somehow, setting the path above does not work
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