Skip to content

Commit

Permalink
Fixed script bugs and added GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanharg committed Mar 5, 2024
1 parent 5650497 commit bc29d19
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and upload to PyPI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- ci-build-wheel
release:
types:
- published

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-13, macos-14]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5

- uses: actions/upload-artifact@v4
with:
name: binaryen-py-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,20 @@ packages = ["binaryen", "binaryen.type"]
build = "cp312-*"
skip = "pp*"
environment = { BINARYEN_VERSION = "117" }
before-all = ["bash ./scripts/build_libbinaryen.sh"]

[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"]
before-all = ["bash ./scripts/build_libbinaryen.sh"]

[tool.cibuildwheel.windows]
archs = ["AMD64"]

[tool.cibuildwheel.linux]
# archs = ["x86_64", "aarch64"]
before-all = ["yum install wget -y"]
before-build = ["cd {package}", "bash ./scripts/build_libbinaryen.sh"]
archs = ["x86_64"]
before-all = ["yum install wget -y", "bash ./scripts/build_libbinaryen.sh"]

[tool.cibuildwheel.windows]
archs = ["AMD64"]
# before-build = ["bash scripts/build_libbinaryen.sh"]

[[tool.cibuildwheel.overrides]]
select = "*-musllinux*"
before-all = "apk add wget"
before-all = ["apk add wget", "bash ./scripts/build_libbinaryen.sh"]
16 changes: 6 additions & 10 deletions scripts/build_libbinaryen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Linux*)

CYGWIN* | MINGW* | MINGW32* | MSYS*)
platform='windows'
if [[ "$arch" == "amd-64"]]
then
if [[ "$arch" == "amd-64" ]]; then
arch="x86_64"
fi
;;
Expand All @@ -26,28 +25,25 @@ CYGWIN* | MINGW* | MINGW32* | MSYS*)
;;
esac

if [ -z ${BINARYEN_VERSION+x} ]
then
if [ -z ${BINARYEN_VERSION+x} ]; then
echo "\$BINARYVEN_VERSION not set"
exit 1
fi

wildcards="--wildcards"

if [[ "$platform" == "macos" ]]
then
if [[ "$platform" == "macos" ]]; then
wildcards=""
fi

lib_path="./binaryen/libbinaryen/$arch-$platform/"
mkdir -p $lib_path

if [[ "$platform" == "macos" ]]
then
if [[ "$platform" == "macos" ]]; then
mkdir -p "./binaryen/libbinaryen/src/"
file="version_$BINARYEN_VERSION.tar.gz"
url="https://github.com/WebAssembly/binaryen/archive/refs/tags/$file"
wget -nc --no-check-certificate --content-disposition $url -P "./binaryen/libbinaryen"
wget -q -nc --no-check-certificate --content-disposition $url -P "./binaryen/libbinaryen"
tar -xzvf "./binaryen/libbinaryen/binaryen-$file" -C "./binaryen/libbinaryen/src" --strip-components=1
cmake -S "./binaryen/libbinaryen/src" -B "./binaryen/libbinaryen/build/" -G Ninja \
-DCMAKE_INSTALL_PREFIX="$lib_path" -DCMAKE_OSX_ARCHITECTURES=$arch \
Expand All @@ -57,7 +53,7 @@ then
else
file="binaryen-version_$BINARYEN_VERSION-$arch-$platform.tar.gz"
url="https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYEN_VERSION/$file"
wget -nc --no-check-certificate --content-disposition $url -P $lib_path
wget -q -nc --no-check-certificate --content-disposition $url -P $lib_path
tar -xzvf $lib_path$file -C $lib_path --strip-components=1 $wildcards \
"binaryen-version_$BINARYEN_VERSION/include/binaryen-c.h" \
"binaryen-version_$BINARYEN_VERSION/include/wasm-delegations.def" \
Expand Down

0 comments on commit bc29d19

Please sign in to comment.