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

Fix issues #1

Open
wants to merge 1 commit into
base: workspace-features-resolution
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 13 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# [package]
# name = "swc-workspace"
# version = "0.1.0"

[workspace]
members = [
"host_runner",
"host_runner_native",
"wasm_guest_binary",
"runner_base"
]
]
resolver = "2"

# [dependencies]
# host_runner = { version = "=0.1.0", path = "host_runner", default-features = false }
# host_runner_native = { version = "=0.1.0", path = "host_runner", host_runner_native = false }

# [features]
# default = []
2 changes: 2 additions & 0 deletions build-native.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
cargo build -p host_runner_native --features=base
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
cargo build -p wasm_guest_binary --target wasm32-unknown-unknown
wasm-pack build ./host_runner --debug --scope host -t nodejs
wasm-pack build ./host_runner --debug --scope host -t nodejs
7 changes: 5 additions & 2 deletions host_runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ crate-type = ["cdylib"]
wasm-bindgen = {version = "0.2.79", features = ["serde-serialize"]}
runner_base = { version="*", path = "../runner_base" }
rkyv = "0.7.35"
wasmer = {version = "2.2.0", default-features = false, features = ["js-default", "wat", "wasm-types-polyfill"]}
wasmer-wasi = {version = "2.2.0", default-features = false, features = ["js-default"]}
parking_lot = "0.12.0"
wasmer = {version = "2.2.0", default-features = false }
wasmer-wasi = {version = "2.2.0", default-features = false }

[features]
default = ["wasmer/js-default", "wasmer/wat", "wasmer/wasm-types-polyfill", "wasmer-wasi/js-default"]
14 changes: 7 additions & 7 deletions host_runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ fn write_bytes_into_guest(instance: &Instance, bytes: &AlignedVec) -> (i32, i32)
let ptr_start = alloc.call(bytes_len.try_into().unwrap()).unwrap();

let view = memory.uint8view();

view.subarray(
ptr_start.try_into().unwrap(),
ptr_start as u32 + bytes_len as u32,
)
.copy_from(bytes);

unsafe {
view.subarray(
ptr_start.try_into().unwrap(),
ptr_start as u32 + bytes_len as u32,
)
.copy_from(bytes);
}
(ptr_start, bytes_len.try_into().unwrap())
}

Expand Down
11 changes: 8 additions & 3 deletions host_runner_native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ edition = "2021"
[dependencies]
runner_base = { version="*", path = "../runner_base" }
rkyv = "0.7.35"
wasmer = {version = "2.2.0", features = ["sys-default"]}
wasmer-wasi = {version = "2.2.0", features = ["sys-default"]}
parking_lot = "0.12.0"
wasmer = {version = "2.2.0", default-features = false }
wasmer-wasi = {version = "2.2.0", default-features = false }

[features]
base = ["wasmer/sys-default", "wasmer-wasi/sys-default", "wasmer-wasi/host-fs"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
wasmer-cache = "2.2.0"
parking_lot = "0.12.0"
4 changes: 3 additions & 1 deletion host_runner_native/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ fn load_plugin() -> Result<(Instance, Arc<Mutex<Vec<u8>>>), std::fmt::Error> {
Err(err) => panic!("should not be here"),
}
}

pub fn main() {

}
pub fn test_success() {
let input = SharedStruct {
name: "input".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion runner_base/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#[derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct SharedStruct {
pub name: String,
pub list: Vec<String>,
Expand Down