rename everything c2 related to the "real" names
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "wasi-c2"
|
||||
name = "wasi-common"
|
||||
version = "0.22.0"
|
||||
authors = ["The Wasmtime Project Developers"]
|
||||
description = "WASI implementation in Rust"
|
||||
@@ -14,9 +14,9 @@ build = "build.rs"
|
||||
publish = false
|
||||
|
||||
# This doesn't actually link to a native library, but it allows us to set env
|
||||
# vars like `DEP_WASI_C2_19_*` for crates that have build scripts and depend
|
||||
# vars like `DEP_WASI_COMMON_19_*` for crates that have build scripts and depend
|
||||
# on this crate, allowing other crates to use the same witx files.
|
||||
links = "wasi-c2-19"
|
||||
links = "wasi-common-19"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
fn main() {
|
||||
let cwd = std::env::current_dir().unwrap();
|
||||
let wasi = cwd.join("..").join("wasi-common").join("WASI");
|
||||
// this will be available to dependent crates via the DEP_WASI_C2_19_WASI env var:
|
||||
// this will be available to dependent crates via the DEP_WASI_COMMON_19_WASI env var:
|
||||
println!("cargo:wasi={}", wasi.display());
|
||||
// and available to our own crate as WASI_ROOT:
|
||||
println!("cargo:rustc-env=WASI_ROOT={}", wasi.display());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "wasi-c2-cap-std-sync"
|
||||
name = "wasi-cap-std-sync"
|
||||
version = "0.22.0"
|
||||
authors = ["The Wasmtime Project Developers"]
|
||||
description = "WASI implementation in Rust"
|
||||
@@ -13,7 +13,7 @@ include = ["src/**/*", "LICENSE" ]
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
wasi-c2 = { path = "../" }
|
||||
wasi-common = { path = "../", version = "0.22.0" }
|
||||
anyhow = "1.0"
|
||||
cap-std = "0.11"
|
||||
cap-fs-ext = "0.11"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use cap_std::time::{Duration, Instant, SystemTime};
|
||||
use cap_time_ext::{MonotonicClockExt, SystemClockExt};
|
||||
use wasi_c2::clocks::{WasiClocks, WasiMonotonicClock, WasiSystemClock};
|
||||
use wasi_common::clocks::{WasiClocks, WasiMonotonicClock, WasiSystemClock};
|
||||
|
||||
pub struct SystemClock(cap_std::time::SystemClock);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use cap_fs_ext::{DirExt, MetadataExt, SystemTimeSpec};
|
||||
use std::any::Any;
|
||||
use std::convert::TryInto;
|
||||
use std::path::{Path, PathBuf};
|
||||
use wasi_c2::{
|
||||
use wasi_common::{
|
||||
dir::{ReaddirCursor, ReaddirEntity, WasiDir},
|
||||
file::{FdFlags, FileCaps, FileType, Filestat, OFlags, WasiFile},
|
||||
Error, ErrorExt,
|
||||
@@ -219,8 +219,8 @@ impl WasiDir for Dir {
|
||||
fn set_times(
|
||||
&self,
|
||||
path: &str,
|
||||
atime: Option<wasi_c2::SystemTimeSpec>,
|
||||
mtime: Option<wasi_c2::SystemTimeSpec>,
|
||||
atime: Option<wasi_common::SystemTimeSpec>,
|
||||
mtime: Option<wasi_common::SystemTimeSpec>,
|
||||
follow_symlinks: bool,
|
||||
) -> Result<(), Error> {
|
||||
if follow_symlinks {
|
||||
@@ -240,10 +240,10 @@ impl WasiDir for Dir {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_systimespec(t: Option<wasi_c2::SystemTimeSpec>) -> Option<SystemTimeSpec> {
|
||||
fn convert_systimespec(t: Option<wasi_common::SystemTimeSpec>) -> Option<SystemTimeSpec> {
|
||||
match t {
|
||||
Some(wasi_c2::SystemTimeSpec::Absolute(t)) => Some(SystemTimeSpec::Absolute(t)),
|
||||
Some(wasi_c2::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow),
|
||||
Some(wasi_common::SystemTimeSpec::Absolute(t)) => Some(SystemTimeSpec::Absolute(t)),
|
||||
Some(wasi_common::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use system_interface::{
|
||||
fs::{Advice, FileIoExt, GetSetFdFlags},
|
||||
io::ReadReady,
|
||||
};
|
||||
use wasi_c2::{
|
||||
use wasi_common::{
|
||||
file::{FdFlags, FileType, Filestat, WasiFile},
|
||||
Error,
|
||||
};
|
||||
@@ -70,8 +70,8 @@ impl WasiFile for File {
|
||||
}
|
||||
fn set_times(
|
||||
&self,
|
||||
atime: Option<wasi_c2::SystemTimeSpec>,
|
||||
mtime: Option<wasi_c2::SystemTimeSpec>,
|
||||
atime: Option<wasi_common::SystemTimeSpec>,
|
||||
mtime: Option<wasi_common::SystemTimeSpec>,
|
||||
) -> Result<(), Error> {
|
||||
self.0
|
||||
.set_times(convert_systimespec(atime), convert_systimespec(mtime))?;
|
||||
@@ -145,49 +145,51 @@ impl AsRawFd for File {
|
||||
self.0.as_raw_fd()
|
||||
}
|
||||
}
|
||||
pub fn convert_systimespec(t: Option<wasi_c2::SystemTimeSpec>) -> Option<SystemTimeSpec> {
|
||||
pub fn convert_systimespec(t: Option<wasi_common::SystemTimeSpec>) -> Option<SystemTimeSpec> {
|
||||
match t {
|
||||
Some(wasi_c2::SystemTimeSpec::Absolute(t)) => Some(SystemTimeSpec::Absolute(t.into_std())),
|
||||
Some(wasi_c2::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow),
|
||||
Some(wasi_common::SystemTimeSpec::Absolute(t)) => {
|
||||
Some(SystemTimeSpec::Absolute(t.into_std()))
|
||||
}
|
||||
Some(wasi_common::SystemTimeSpec::SymbolicNow) => Some(SystemTimeSpec::SymbolicNow),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_sysif_fdflags(f: wasi_c2::file::FdFlags) -> system_interface::fs::FdFlags {
|
||||
pub fn to_sysif_fdflags(f: wasi_common::file::FdFlags) -> system_interface::fs::FdFlags {
|
||||
let mut out = system_interface::fs::FdFlags::empty();
|
||||
if f.contains(wasi_c2::file::FdFlags::APPEND) {
|
||||
if f.contains(wasi_common::file::FdFlags::APPEND) {
|
||||
out |= system_interface::fs::FdFlags::APPEND;
|
||||
}
|
||||
if f.contains(wasi_c2::file::FdFlags::DSYNC) {
|
||||
if f.contains(wasi_common::file::FdFlags::DSYNC) {
|
||||
out |= system_interface::fs::FdFlags::DSYNC;
|
||||
}
|
||||
if f.contains(wasi_c2::file::FdFlags::NONBLOCK) {
|
||||
if f.contains(wasi_common::file::FdFlags::NONBLOCK) {
|
||||
out |= system_interface::fs::FdFlags::NONBLOCK;
|
||||
}
|
||||
if f.contains(wasi_c2::file::FdFlags::RSYNC) {
|
||||
if f.contains(wasi_common::file::FdFlags::RSYNC) {
|
||||
out |= system_interface::fs::FdFlags::RSYNC;
|
||||
}
|
||||
if f.contains(wasi_c2::file::FdFlags::SYNC) {
|
||||
if f.contains(wasi_common::file::FdFlags::SYNC) {
|
||||
out |= system_interface::fs::FdFlags::SYNC;
|
||||
}
|
||||
out
|
||||
}
|
||||
pub fn from_sysif_fdflags(f: system_interface::fs::FdFlags) -> wasi_c2::file::FdFlags {
|
||||
let mut out = wasi_c2::file::FdFlags::empty();
|
||||
pub fn from_sysif_fdflags(f: system_interface::fs::FdFlags) -> wasi_common::file::FdFlags {
|
||||
let mut out = wasi_common::file::FdFlags::empty();
|
||||
if f.contains(system_interface::fs::FdFlags::APPEND) {
|
||||
out |= wasi_c2::file::FdFlags::APPEND;
|
||||
out |= wasi_common::file::FdFlags::APPEND;
|
||||
}
|
||||
if f.contains(system_interface::fs::FdFlags::DSYNC) {
|
||||
out |= wasi_c2::file::FdFlags::DSYNC;
|
||||
out |= wasi_common::file::FdFlags::DSYNC;
|
||||
}
|
||||
if f.contains(system_interface::fs::FdFlags::NONBLOCK) {
|
||||
out |= wasi_c2::file::FdFlags::NONBLOCK;
|
||||
out |= wasi_common::file::FdFlags::NONBLOCK;
|
||||
}
|
||||
if f.contains(system_interface::fs::FdFlags::RSYNC) {
|
||||
out |= wasi_c2::file::FdFlags::RSYNC;
|
||||
out |= wasi_common::file::FdFlags::RSYNC;
|
||||
}
|
||||
if f.contains(system_interface::fs::FdFlags::SYNC) {
|
||||
out |= wasi_c2::file::FdFlags::SYNC;
|
||||
out |= wasi_common::file::FdFlags::SYNC;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ use cap_rand::RngCore;
|
||||
use std::cell::RefCell;
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
use wasi_c2::{table::Table, Error, WasiCtx, WasiFile};
|
||||
use wasi_common::{table::Table, Error, WasiCtx, WasiFile};
|
||||
|
||||
pub struct WasiCtxBuilder(wasi_c2::WasiCtxBuilder);
|
||||
pub struct WasiCtxBuilder(wasi_common::WasiCtxBuilder);
|
||||
|
||||
impl WasiCtxBuilder {
|
||||
pub fn new() -> Self {
|
||||
@@ -21,11 +21,18 @@ impl WasiCtxBuilder {
|
||||
Rc::new(RefCell::new(Table::new())),
|
||||
))
|
||||
}
|
||||
pub fn env(self, var: &str, value: &str) -> Result<Self, wasi_c2::StringArrayError> {
|
||||
pub fn env(self, var: &str, value: &str) -> Result<Self, wasi_common::StringArrayError> {
|
||||
let s = self.0.env(var, value)?;
|
||||
Ok(WasiCtxBuilder(s))
|
||||
}
|
||||
pub fn arg(self, arg: &str) -> Result<Self, wasi_c2::StringArrayError> {
|
||||
pub fn inherit_env(self) -> Result<Self, wasi_common::StringArrayError> {
|
||||
let mut s = self.0;
|
||||
for (key, value) in std::env::vars() {
|
||||
s = s.env(&key, &value)?;
|
||||
}
|
||||
Ok(WasiCtxBuilder(s))
|
||||
}
|
||||
pub fn arg(self, arg: &str) -> Result<Self, wasi_common::StringArrayError> {
|
||||
let s = self.0.arg(arg)?;
|
||||
Ok(WasiCtxBuilder(s))
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use cap_std::time::Duration;
|
||||
use std::convert::TryInto;
|
||||
use std::ops::Deref;
|
||||
use std::os::unix::io::{AsRawFd, RawFd};
|
||||
use wasi_c2::{
|
||||
use wasi_common::{
|
||||
file::WasiFile,
|
||||
sched::{
|
||||
subscription::{RwEventFlags, Subscription},
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender, TryRecvError};
|
||||
use std::sync::Mutex;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use wasi_c2::{
|
||||
use wasi_common::{
|
||||
file::WasiFile,
|
||||
sched::{
|
||||
subscription::{RwEventFlags, Subscription},
|
||||
|
||||
@@ -11,7 +11,7 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::io::{AsRawHandle, RawHandle};
|
||||
use unsafe_io::AsUnsafeFile;
|
||||
use wasi_c2::{
|
||||
use wasi_common::{
|
||||
file::{FdFlags, FileType, Filestat, WasiFile},
|
||||
Error, ErrorExt,
|
||||
};
|
||||
@@ -84,8 +84,8 @@ impl WasiFile for Stdin {
|
||||
}
|
||||
fn set_times(
|
||||
&self,
|
||||
atime: Option<wasi_c2::SystemTimeSpec>,
|
||||
mtime: Option<wasi_c2::SystemTimeSpec>,
|
||||
atime: Option<wasi_common::SystemTimeSpec>,
|
||||
mtime: Option<wasi_common::SystemTimeSpec>,
|
||||
) -> Result<(), Error> {
|
||||
self.0
|
||||
.set_times(convert_systimespec(atime), convert_systimespec(mtime))?;
|
||||
@@ -176,8 +176,8 @@ macro_rules! wasi_file_write_impl {
|
||||
}
|
||||
fn set_times(
|
||||
&self,
|
||||
atime: Option<wasi_c2::SystemTimeSpec>,
|
||||
mtime: Option<wasi_c2::SystemTimeSpec>,
|
||||
atime: Option<wasi_common::SystemTimeSpec>,
|
||||
mtime: Option<wasi_common::SystemTimeSpec>,
|
||||
) -> Result<(), Error> {
|
||||
self.0
|
||||
.set_times(convert_systimespec(atime), convert_systimespec(mtime))?;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
[package]
|
||||
name = "wasi-c2-wasmtime"
|
||||
version = "0.22.0"
|
||||
authors = ["The Wasmtime Project Developers"]
|
||||
description = "WASI implementation in Rust"
|
||||
license = "Apache-2.0 WITH LLVM-exception"
|
||||
categories = ["wasm"]
|
||||
keywords = ["webassembly", "wasm"]
|
||||
repository = "https://github.com/bytecodealliance/wasmtime"
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
include = ["src/**/*", "LICENSE", "build.rs"]
|
||||
build = "build.rs"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
wasi-c2 = { path = "../" }
|
||||
wiggle = { path = "../../wiggle", default-features = false, version = "0.22.0" }
|
||||
wasmtime-wiggle = { path = "../../wiggle/wasmtime", default-features = false, version = "0.22.0" }
|
||||
wasmtime = { path = "../../wasmtime" }
|
||||
anyhow = "1.0"
|
||||
@@ -1,6 +0,0 @@
|
||||
fn main() {
|
||||
// wasi-c2's links & build.rs ensure this variable points to the wasi root:
|
||||
let wasi_root = std::env::var("DEP_WASI_C2_19_WASI").unwrap();
|
||||
// Make it available as WASI_ROOT:
|
||||
println!("cargo:rustc-env=WASI_ROOT={}", wasi_root);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
pub use wasi_c2::{
|
||||
Error, FdFlags, FileCaps, Filestat, OFlags, ReaddirCursor, ReaddirEntity, SystemTimeSpec,
|
||||
WasiCtx, WasiCtxBuilder, WasiDir, WasiFile,
|
||||
};
|
||||
|
||||
// Defines a `struct Wasi` with member fields and appropriate APIs for dealing
|
||||
// with all the various WASI exports.
|
||||
wasmtime_wiggle::wasmtime_integration!({
|
||||
// The wiggle code to integrate with lives here:
|
||||
target: wasi_c2::snapshots::preview_1,
|
||||
// This must be the same witx document as used above. This should be ensured by
|
||||
// the `WASI_ROOT` env variable, which is set in wasi-common's `build.rs`.
|
||||
witx: ["$WASI_ROOT/phases/snapshot/witx/wasi_snapshot_preview1.witx"],
|
||||
// This must be the same ctx type as used for the target:
|
||||
ctx: WasiCtx,
|
||||
// This macro will emit a struct to represent the instance,
|
||||
// with this name and docs:
|
||||
modules: { wasi_snapshot_preview1 =>
|
||||
{ name: Wasi,
|
||||
docs: "An instantiated instance of the wasi exports.
|
||||
|
||||
This represents a wasi module which can be used to instantiate other wasm
|
||||
modules. This structure exports all that various fields of the wasi instance
|
||||
as fields which can be used to implement your own instantiation logic, if
|
||||
necessary. Additionally [`Wasi::get_export`] can be used to do name-based
|
||||
resolution.",
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user