Skip to content

Commit cf8aa38

Browse files
authored
Merge pull request #5621 from hardfist/wasi-common
feat: support sys-minimal feature for WASIX, allowing users to selectively enable features they need when running natively
2 parents 1487ac4 + 40e98b1 commit cf8aa38

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

lib/wasix/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ webc_runner_rt_dproxy = [
205205
"tower-http",
206206
"journal",
207207
]
208-
208+
# the minimal sys implementation
209+
sys-minimal = ["wasmer/sys", "sys-thread", "tokio/fs"]
209210
sys = [
210211
"webc/mmap",
211212
"time",

lib/wasix/src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@
1414
//! [WASI plugin example](https://github.com/wasmerio/wasmer/blob/main/examples/plugin.rs)
1515
//! for an example of how to extend WASI using the WASI FS API.
1616
17-
#[cfg(all(not(feature = "sys"), not(feature = "js")))]
18-
compile_error!("At least the `sys` or the `js` feature must be enabled. Please, pick one.");
17+
#[cfg(all(
18+
not(feature = "sys"),
19+
not(feature = "js"),
20+
not(feature = "sys-minimal")
21+
))]
22+
compile_error!(
23+
"At least the `sys` or the `js` or `sys-minimal` feature must be enabled. Please, pick one."
24+
);
1925

20-
#[cfg(all(feature = "sys", feature = "js"))]
26+
#[cfg(any(
27+
all(feature = "js", feature = "sys"),
28+
all(feature = "js", feature = "sys-minimal")
29+
))]
2130
compile_error!(
22-
"Cannot have both `sys` and `js` features enabled at the same time. Please, pick one."
31+
"Cannot have both `sys` and `js` or `sys-minimal` and `sys` features enabled at the same time. Please, pick one."
2332
);
2433

2534
#[cfg(all(feature = "sys", target_arch = "wasm32"))]

lib/wasix/src/state/handles/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod global;
22
mod thread_local;
33

4-
#[cfg(feature = "sys")]
4+
#[cfg(any(feature = "sys", feature = "sys-minimal"))]
55
pub(crate) use global::*;
66
#[cfg(feature = "js")]
77
pub(crate) use thread_local::*;

lib/wasix/src/state/handles/thread_local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(feature = "sys", allow(unused))]
1+
#![cfg_attr(any(feature = "sys", feature = "sys-minimal"), allow(unused))]
22
use std::cell::{Ref, RefCell, RefMut};
33
use std::ops::{Deref, DerefMut};
44
use std::{

0 commit comments

Comments
 (0)