murarth / ketos

Lisp dialect scripting and extension language for Rust programs
Apache License 2.0
751 stars 45 forks source link

WebAssembly support #69

Open brassy-endomorph opened 3 years ago

brassy-endomorph commented 3 years ago

Adds conditional compilation for the wasm32 target to enable wasm support. Tested with a small program on Firefox 88.0.1 and it works well enough. It requires a nightly compiler to access std::time::Instant in a way that doesn't panic. Possibly as a result of using the nightly compiler, it errors on test execution with the following:

$ cargo test --target wasm32-unknown-unknown --no-default-features
...
    Finished test [unoptimized + debuginfo] target(s) in 0.02s
     Running unittests (target/wasm32-unknown-unknown/debug/deps/ketos-951c6b0f1e1fa322.wasm)
/home/user/code/misc/ketos/target/wasm32-unknown-unknown/debug/deps/ketos-951c6b0f1e1fa322.wasm: 1: /home/user/code/misc/ketos/target/wasm32-unknown-unknown/debug/deps/ketos-951c6b0f1e1fa322.wasm: Syntax error: end of file unexpected