Skip to content

Commit 191107c

Browse files
authored
Fix binaryen build (#114)
1 parent 4f9fec6 commit 191107c

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

.github/workflows/build.yml

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@ on:
99
pull_request:
1010
env:
1111
BINARYEN_TOOLS: wasm-shell wasm-opt wasm-metadce wasm2js wasm-as wasm-dis wasm-ctor-eval wasm-reduce wasm-merge
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
1215
jobs:
1316
build:
1417
name: "Build with Emsdk:${{ matrix.emsdk }}"
1518
runs-on: ubuntu-latest
1619
if: github.event_name == 'schedule' || !contains(github.event.head_commit.message, '[ci skip]')
20+
permissions:
21+
id-token: write
22+
contents: write
1723
env:
18-
MAKE_FLAGS: "-j2"
1924
CMAKE_EXE_LINKER_FLAGS: "-sMAXIMUM_MEMORY=4294967296 -sSINGLE_FILE"
2025
strategy:
2126
matrix:
2227
emsdk: [ "tot", "latest" ]
2328
fail-fast: false
2429
steps:
25-
- uses: actions/setup-node@v2
30+
- uses: actions/setup-node@v6
2631
with:
27-
node-version: '20'
32+
node-version: '22'
2833
- name: "Set up Emsdk"
2934
run: |
3035
mkdir $HOME/emsdk
@@ -34,14 +39,14 @@ jobs:
3439
$HOME/emsdk/emsdk activate ${{ matrix.emsdk }}
3540
echo "$HOME/emsdk" >> $GITHUB_PATH
3641
- name: "Set up CMake"
37-
run: |
38-
mkdir $HOME/cmake
39-
wget -qO- https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4-Linux-x86_64.tar.gz | tar -xzC $HOME/cmake --strip-components 1
40-
echo "$HOME/cmake/bin" >> $GITHUB_PATH
42+
uses: lukka/get-cmake@latest
43+
with:
44+
cmakeVersion: 3.31.11
45+
ninjaVersion: latest
4146
- name: "Check out repository"
42-
uses: actions/checkout@v1
47+
uses: actions/checkout@v4
4348
with:
44-
submodules: false
49+
submodules: true
4550
- name: "Set up repository"
4651
env:
4752
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -54,7 +59,7 @@ jobs:
5459
# If not a PR, undo detached head
5560
git checkout "${GITHUB_REF:11}"
5661
fi
57-
git submodule update --init --remote --merge --recursive
62+
git submodule update --init --remote --recursive --depth 1
5863
cd ./binaryen
5964
git log -n1
6065
cd ..
@@ -69,7 +74,6 @@ jobs:
6974
echo "Resetting to $TAG ..."
7075
cd ./binaryen
7176
git reset --hard "$TAG"
72-
git clean -f
7377
git log -n1
7478
cd ..
7579
echo "RELEASE=1" >> $GITHUB_ENV
@@ -79,12 +83,19 @@ jobs:
7983
fi
8084
- name: "Build binaryen.js"
8185
run: |
82-
mkdir ./binaryen/build
86+
mkdir -p ./binaryen/build
8387
cd ./binaryen/build
8488
source $HOME/emsdk/emsdk_env.sh
8589
emcc --version
86-
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" -DENABLE_WERROR=OFF
87-
emmake make $MAKE_FLAGS binaryen_wasm
90+
emcmake cmake .. -G Ninja \
91+
-DCMAKE_BUILD_TYPE=Release \
92+
-DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" \
93+
-DENABLE_WERROR=OFF \
94+
-DBUILD_TOOLS=ON \
95+
-DBUILD_STATIC_LIB=OFF \
96+
-DBUILD_TESTS=OFF \
97+
-DBUILD_FUZZTEST=OFF
98+
emmake ninja
8899
cd ../..
89100
npm run bundle
90101
- name: "Test binaryen.js"
@@ -94,15 +105,16 @@ jobs:
94105
run: |
95106
mkdir -p ./bin
96107
cd ./binaryen/build
97-
source $HOME/emsdk/emsdk_env.sh
98-
emcc --version
99108
for tool in ${{ env.BINARYEN_TOOLS }}; do
100-
emmake make $MAKE_FLAGS "$tool"
109+
if [ ! -f "./bin/$tool.js" ]; then
110+
echo "Missing tool: $tool"
111+
exit 1
112+
fi
101113
echo '#!/usr/bin/env node' > "../../bin/$tool"
102114
cat "./bin/$tool.js" >> "../../bin/$tool"
115+
chmod +x "../../bin/$tool"
103116
done
104117
cd ../..
105-
chmod +x ./bin/*
106118
- name: "Test tools"
107119
run: |
108120
for tool in ${{ env.BINARYEN_TOOLS }}; do
@@ -127,11 +139,7 @@ jobs:
127139
git push -u origin "v$VERSION"
128140
- name: "Publish to npm"
129141
if: github.event_name == 'schedule' && matrix.emsdk == 'tot'
130-
env:
131-
NPM_REGISTRY: "registry.npmjs.org"
132-
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
133142
run: |
134-
npm config set "//${NPM_REGISTRY}/:_authToken=${NPM_AUTH_TOKEN}"
135143
if [ $RELEASE ]; then
136144
echo "Publishing release ..."
137145
npm publish

0 commit comments

Comments
 (0)