Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building with cargo-wasi #2

Open
Ethan-Arrowood opened this issue Dec 14, 2022 · 2 comments
Open

Building with cargo-wasi #2

Ethan-Arrowood opened this issue Dec 14, 2022 · 2 comments

Comments

@Ethan-Arrowood
Copy link

Hello, I'm trying to use cargo-wasi to build a rust app that uses rusty_jsc, but I'm seeing this error when I run cargo wasi build:

❯ cargo wasi run 
   Compiling rusty_jsc_sys v0.0.2
   Compiling anyhow v1.0.66
   Compiling rusty_jsc_sys v0.0.3
error: library kind `framework` is only supported on Apple targets

error: could not compile `rusty_jsc_sys` due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `rusty_jsc_sys` due to previous error

My Cargo.toml is simple:

[package]
name = "project"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rusty_jsc = "0.0.2"
rusty_jsc_macros = "0.0.3"
rusty_jsc_sys = "0.0.3"

And the main.rs is just one of your examples:

use rusty_jsc::JSContext;

fn main() {
    let mut context = JSContext::default();
    let value = context.evaluate_script("'hello, world'", 1);
    if let Some(value) = value {
        println!("{}", value.to_string(&context));
    }
}

Any ideas? I'm new to the world of WASI so hopefully its something I just don't understand

@penberg
Copy link
Contributor

penberg commented Dec 15, 2022

The problem you have is that the JavaScriptCore framework that rusty_jsc provides bindings for is a native library. So you can't build rusty_jsc for a WebAssembly target with cargo wasi build.

Not sure what you are building, but if you really need to run JavaScriptCore on top of a WebAssembly runtime, there's https://github.com/mbbill/JSC.js that might work for you.

@Ethan-Arrowood
Copy link
Author

Oh so the native library would also need some kind of way to build down to WASI?

And yeah the target isn't just WASM, but WASI. I'm poking around seeing if its possible to build a rust based JS Runtime that can compile down to WASI. Thank you for the recommendation, ill look into that library too!

syrusakbary pushed a commit that referenced this issue Aug 10, 2023
Promise and protected object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants