Skip to content

Commit

Permalink
Merge pull request #178 from lvignoli/wasm-support
Browse files Browse the repository at this point in the history
WASM support
  • Loading branch information
tgross35 authored Oct 13, 2024
2 parents 390cec4 + c8a5a0c commit 449a1a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: actions/setup-node@v4
- uses: mymindstorm/setup-emsdk@v14
with:
node-version: 20
- name: Get npm cache directory
Expand All @@ -66,3 +67,5 @@ jobs:
run: just --verbose test
- name: Check if generated files are up to date (warn only)
run: just --verbose ci-validate-generated-files 0
- name: Test WASM build
run: just --verbose build-wasm
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ gen *extra-args:
clang-format -i src/parser.c || \
echo "skipping clang-format"

build-wasm: gen
npx tree-sitter build --wasm

alias t := test

# Run tests that are built into tree-sitter, as well as integration and Cargo tests
Expand Down
6 changes: 6 additions & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#define unused_attr
#endif

#ifdef __wasm__
#define assertf(...) (void)0;
#else

#ifndef fprintf_s
#define fprintf_s fprintf // NOLINT
#endif
Expand Down Expand Up @@ -55,6 +59,8 @@
#define __builtin_expect(a, b) a
#endif

#endif

#define SBYTES sizeof(Scanner)

enum TokenType {
Expand Down

0 comments on commit 449a1a5

Please sign in to comment.