Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
profile: default
toolchain: stable
target: wasm32-wasi
target: wasm32-wasip1
default: true

- name: Setup Go
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
profile: default
toolchain: stable
target: wasm32-wasi
target: wasm32-wasip1
default: true

- name: Get wasm-opt
Expand All @@ -35,13 +35,13 @@ jobs:
run: make core

- name: Opt core
run: wasm-opt --enable-reference-types --enable-bulk-memory --strip -O3 target/wasm32-wasi/release/js_pdk_core.wasm -o target/wasm32-wasi/release/js_pdk_core.wasm
run: wasm-opt --enable-reference-types --enable-bulk-memory --strip -O3 target/wasm32-wasip1/release/js_pdk_core.wasm -o target/wasm32-wasip1/release/js_pdk_core.wasm

- name: Upload core binary to artifacts
uses: actions/upload-artifact@v4
with:
name: engine
path: target/wasm32-wasi/release/js_pdk_core.wasm
path: target/wasm32-wasip1/release/js_pdk_core.wasm

compile_cli:
name: Compile CLI
Expand Down
44 changes: 27 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ core:
&& npm run build \
&& npx -y -p typescript tsc src/index.ts --lib es2020 --declaration --emitDeclarationOnly --outDir dist \
&& cd ../.. \
&& cargo build --release --target=wasm32-wasi \
&& wasm-opt --enable-reference-types --enable-bulk-memory --strip -O3 ../../target/wasm32-wasi/release/js_pdk_core.wasm -o ../../target/wasm32-wasi/release/js_pdk_core.wasm \
&& cargo build --release --target=wasm32-wasip1 \
&& wasm-opt --enable-reference-types --enable-bulk-memory --strip -O3 ../../target/wasm32-wasip1/release/js_pdk_core.wasm -o ../../target/wasm32-wasip1/release/js_pdk_core.wasm \
&& cd -

fmt: fmt-core fmt-cli

fmt-core:
cd crates/core/ \
&& cargo fmt -- --check \
&& cargo clippy --target=wasm32-wasi -- -D warnings \
&& cargo clippy --target=wasm32-wasip1 -- -D warnings \
&& cd -

fmt-cli:
Expand All @@ -50,30 +50,40 @@ clean-wasi-sdk:
test: compile-examples
@extism call examples/simple_js.wasm greet --wasi --input="Benjamin"
@extism call examples/bundled.wasm greet --wasi --input="Benjamin" --allow-host "example.com"
ifeq ($(OS),Windows_NT)
@python3 -m venv ./.venv && \
./.venv/Scripts/activate.bat && \
pip install -r examples/host_funcs/requirements.txt && \
python examples/host_funcs/host.py examples/host_funcs.wasm && \
./.venv/Scripts/deactivate.bat
else
@python3 -m venv ./.venv && \
. ./.venv/bin/activate && \
pip install -r examples/host_funcs/requirements.txt && \
python3 examples/host_funcs/host.py examples/host_funcs.wasm && \
deactivate
endif
# ifeq ($(OS),Windows_NT)
# @python3 -m venv ./.venv && \
# ./.venv/Scripts/activate.bat && \
# pip install -r examples/host_funcs/requirements.txt && \
# python examples/host_funcs/host.py examples/host_funcs.wasm && \
# ./.venv/Scripts/deactivate.bat
# else
# @python3 -m venv ./.venv && \
# . ./.venv/bin/activate && \
# pip install -r examples/host_funcs/requirements.txt && \
# python3 examples/host_funcs/host.py examples/host_funcs.wasm && \
# deactivate
# endif
Comment on lines +54 to +66
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna leave this uncommented and merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisdickinson no rush, but could you chime in as to how to fix this or when another sdk release will happen? i don't recall we had a definitive reason why we were still getting the failure to import here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to replicate the extism_sys issue on my machine – I ran into a similar issue with extism-cli but I solved it by upgrading my virtualenv. I think it could be a virtualenv issue – looking back at the error you posted, it doesn't look like you had the target virtualenv active when you uninstalled extism_sys and installed a newer version. The CI looks like it was failing for a different reason, though?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must have been some kind of caching issue, the tests are passing now: #116

@extism call examples/react.wasm render --wasi
@extism call examples/react.wasm setState --input='{"action": "SET_SETTING", "payload": { "backgroundColor": "tomato" }}' --wasi
#@extism call examples/exception.wasm greet --wasi --input="Benjamin"
@error_msg=$$(extism call examples/exception.wasm greet --wasi --input="Benjamin" 2>&1); \
if echo "$$error_msg" | grep -q "shibboleth"; then \
echo "Test passed - found expected error"; \
else \
echo "Test failed - did not find expected error message"; \
echo "Got: $$error_msg"; \
exit 1; \
fi

compile-examples: cli
cd examples/react && npm install && npm run build && cd ../..
./target/release/extism-js examples/simple_js/script.js -i examples/simple_js/script.d.ts -o examples/simple_js.wasm
cd examples/bundled && npm install && npm run build && cd ../..
./target/release/extism-js examples/host_funcs/script.js -i examples/host_funcs/script.d.ts -o examples/host_funcs.wasm
./target/release/extism-js examples/exports/script.js -i examples/exports/script.d.ts -o examples/exports.wasm
./target/release/extism-js examples/exception/script.js -i examples/exception/script.d.ts -o examples/exception.wasm

kitchen:
cd examples/kitchen-sink && npm install && npm run build && cd ../..
./target/release/extism-js examples/kitchen-sink/dist/index.js -i examples/kitchen-sink/src/index.d.ts -o examples/kitchen-sink.wasm
@extism call examples/kitchen-sink.wasm greet --input "Steve" --wasi --allow-host "*" --config "last_name=Manuel"
@extism call examples/kitchen-sink.wasm greet --input "Steve" --wasi --allow-host "*" --config "last_name=Manuel"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ Before compiling the compiler, you need to install prerequisites.

1. Install Rust using [rustup](https://rustup.rs)
2. Install the WASI target platform via
`rustup target add --toolchain stable wasm32-wasi`
`rustup target add --toolchain stable wasm32-wasip1`
3. Install the wasi sdk using the makefile command: `make download-wasi-sdk`
4. Install [CMake](https://cmake.org/install/) (on macOS with homebrew,
`brew install cmake`)
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn copy_engine_binary() {
if !is_override {
engine_path.pop();
engine_path.pop();
engine_path = engine_path.join("target/wasm32-wasi/release/js_pdk_core.wasm");
engine_path = engine_path.join("target/wasm32-wasip1/release/js_pdk_core.wasm");
}

println!("cargo:rerun-if-changed={}", engine_path.to_str().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ once_cell = "1.16"
anyhow = { workspace = true }
quickjs-wasm-rs = "3"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
rquickjs = { version = "0.6.2", features = ["array-buffer"]}
rquickjs = { version = "0.8", features = ["array-buffer", "bindgen"]}
base64 = "0.22.1"

[lib]
Expand Down
Loading
Loading