Skip to content

Commit 149d686

Browse files
committed
Build and test wasm on MacOS in CI
The default clang installation provided in MacOS does not work. We fixed this locally by installing clang via llvm through brew and setting the CC and AR env variables to point at the new clang installation.The CI MacOS image seems to already have llvm installed so we did not need to install llvm on the CI. See rust-bitcoin/rust-secp256k1#254 for more details
1 parent 5e21a5f commit 149d686

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

.github/workflows/rust.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,29 @@ jobs:
2929
DO_BENCH: true
3030
run: ./contrib/test.sh
3131

32-
wasm_pack:
32+
wasm:
3333
name: Stable - Docs / WebAssembly Build
34-
runs-on: ubuntu-latest
3534
strategy:
3635
matrix:
37-
rust:
38-
- stable
36+
target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin ]
37+
include:
38+
- target: x86_64-unknown-linux-gnu
39+
os: ubuntu-latest
40+
cc: clang-12
41+
ar: ar
42+
- target: x86_64-apple-darwin
43+
os: macos-latest
44+
cc: /usr/local/opt/llvm/bin/clang
45+
ar: /usr/local/opt/llvm/bin/llvm-ar
46+
runs-on: ${{ matrix.os }}
3947
steps:
4048
- name: Checkout Crate
4149
uses: actions/checkout@v2
4250
- name: Checkout Toolchain
4351
uses: actions-rs/toolchain@v1
4452
with:
4553
profile: minimal
46-
toolchain: ${{ matrix.rust }}
54+
toolchain: stable
4755
override: true
4856
- name: Building docs
4957
env:
@@ -54,18 +62,10 @@ jobs:
5462
- name: Running WASM build
5563
env:
5664
DO_WASM: true
65+
CC: ${{ matrix.cc }}
66+
AR: ${{ matrix.ar }}
5767
run: ./contrib/test.sh
5868

59-
build_wasm:
60-
runs-on: ubuntu-latest
61-
steps:
62-
- uses: actions/checkout@v2
63-
- uses: actions-rs/toolchain@v1
64-
with:
65-
toolchain: stable
66-
target: wasm32-unknown-unknown
67-
- run: cargo build --target wasm32-unknown-unknown --features global-context,use-serde,use-rand
68-
6969
Tests:
7070
name: Tests
7171
strategy:

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ bitcoin_hashes = "0.9"
4545
[target.wasm32-unknown-unknown.dev-dependencies]
4646
wasm-bindgen-test = "0.3"
4747
rand = { version = "0.6", features = ["wasm-bindgen"] }
48+
49+
[lib]
50+
crate-type = ["cdylib", "rlib"]

contrib/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ fi
5353
# Webassembly stuff
5454
if [ "$DO_WASM" = true ]; then
5555
clang --version &&
56-
CC=clang-9 wasm-pack build &&
57-
CC=clang-9 wasm-pack test --node;
56+
wasm-pack build &&
57+
wasm-pack test --node;
5858
fi
5959

6060
# Address Sanitizer

0 commit comments

Comments
 (0)