@@ -115,6 +115,77 @@ 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 : Clean-up (Windows)
162+ if : matrix.os == 'windows-latest' && steps.cache-binaryen.outputs.cache-hit != 'true'
163+ working-directory : ./binaryen
164+ shell : bash
165+ # Restoring a cache with lots of files is slow under Windows
166+ run : rm -r src test third_party CMakeFiles scripts
167+
168+ - name : Cache binaryen
169+ if : steps.cache-binaryen.outputs.cache-hit != 'true'
170+ uses : actions/cache/save@v4
171+ with :
172+ path : binaryen
173+ key : ${{ runner.os }}-binaryen-version_118
174+
175+ - name : Set binaryen's path
176+ shell : bash
177+ run : echo "$GITHUB_WORKSPACE/binaryen/bin" >> $GITHUB_PATH
178+
179+ - name : Copy binaryen's tools (Windows)
180+ if : matrix.os == 'windows-latest'
181+ shell : bash
182+ # Somehow, setting the path above does not work
183+ run : cp $GITHUB_WORKSPACE/binaryen/bin/wasm-{merge,opt}.exe _opam/bin
184+
185+ - name : Install faked binaryen-bin package
186+ # It's faster to use a cached version
187+ run : opam install --fake binaryen-bin
188+
118189 - run : opam install . --best-effort
119190 if : ${{ matrix.skip-test }}
120191
0 commit comments