Skip to content

Commit

Permalink
fix: support WASM/webR builds
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi authored Jan 11, 2025
1 parent a4c2e28 commit b900d63
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 429 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build WASM
on:
pull_request:
branches:
- main
paths:
- src/**
- configure*
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build wasm package
uses: r-wasm/actions/build-rwasm@main
with:
packages: |
local::.
7 changes: 7 additions & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ PKG_LIBS = -L$(LIBDIR) -lr_polars

CARGO_BUILD_ARGS = --lib --profile $(PROFILE) --manifest-path=./rust/Cargo.toml --target-dir $(TARGET_DIR)

# Some features should be removed when building for WASM, as like Python Polars
# <https://github.com/pola-rs/polars/blob/93ceaccdac6f05c9b07a5117f3a4a90c238dbd29/.github/workflows/test-pyodide.yml#L40-L45>
WASM_INCOMPATIBLE_FEATURES = parquet|async|json|extract_jsonpath|cloud|polars_cloud|tokio|clipboard|decompress|new_streaming

all: C_clean

$(SHLIB): $(STATLIB)
Expand All @@ -22,6 +26,9 @@ $(STATLIB):
if [ "$(TARGET)" != "wasm32-unknown-emscripten" ]; then \
cargo build $(CARGO_BUILD_ARGS); \
else \
sed -E -i \
-e "/^\s*\"($(WASM_INCOMPATIBLE_FEATURES))\",$$/d" \
./rust/Cargo.toml && \
export CC="$(CC)" && \
export CFLAGS="$(CFLAGS)" && \
export CARGO_PROFILE_DEV_PANIC="abort" && \
Expand Down
Loading

0 comments on commit b900d63

Please sign in to comment.