From 7641acb0f160c72b70fcb6b0f2199da9fe68c8f0 Mon Sep 17 00:00:00 2001 From: Veykril Date: Sun, 26 Jan 2020 20:44:45 +0100 Subject: [PATCH] enable wasi linking --- Cargo.toml | 4 ++++ src/module.rs | 5 ++--- wasm3-sys/Cargo.toml | 3 +++ wasm3-sys/build.rs | 10 +++++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5cdb929..46aa164 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,10 @@ authors = ["Lukas Tobias Wirth "] edition = "2018" license = "MIT" +[features] +wasi = ["ffi/wasi"] +default = ["wasi"] + [dependencies.ffi] path = "wasm3-sys" package = "wasm3-sys" diff --git a/src/module.rs b/src/module.rs index 80bfde3..88fc1ab 100644 --- a/src/module.rs +++ b/src/module.rs @@ -115,11 +115,10 @@ impl<'env, 'rt> Module<'env, 'rt> { } } - /*requires defines + #[cfg(feature = "wasi")] pub fn link_wasi(&mut self) { - unsafe { ffi::m3_LinkWASI(self.0) }; + unsafe { ffi::m3_LinkWASI(self.raw) }; } - */ pub fn link_libc(&mut self) { unsafe { ffi::m3_LinkLibC(self.raw) }; diff --git a/wasm3-sys/Cargo.toml b/wasm3-sys/Cargo.toml index 7736111..9ffc424 100644 --- a/wasm3-sys/Cargo.toml +++ b/wasm3-sys/Cargo.toml @@ -6,6 +6,9 @@ edition = "2018" license = "MIT" links = "wasm3" +[features] +wasi = [] + [build-dependencies] bindgen = "0.52" cc = "1" \ No newline at end of file diff --git a/wasm3-sys/build.rs b/wasm3-sys/build.rs index 057626b..678bce6 100644 --- a/wasm3-sys/build.rs +++ b/wasm3-sys/build.rs @@ -54,11 +54,15 @@ fn main() -> io::Result<()> { cfg.flag("/Zo"); cfg.flag("/arch:AVX2"); } - cfg.warnings(false) + let cfg = cfg + .warnings(false) .cpp(false) .define("d_m3LogOutput", Some("0")) .extra_warnings(false) - .include("wasm3/source") - .compile("wasm3"); + .include("wasm3/source"); + if cfg!(feature = "wasi") { + cfg.define("d_m3HasWASI", None); + } + cfg.compile("wasm3"); Ok(()) }