Shuffle around the wiggle crates (#1414)
* Shuffle around the wiggle crates This commit reorganizes the wiggle crates slightly by performing the following transforms: * The `crates/wiggle` crate, previously named `wiggle`, was moved to `crates/wiggle/crates/macro` and is renamed to `wiggle-macro`. * The `crates/wiggle/crates/runtime` crate, previously named `wiggle-runtime`, was moved to `crates/wiggle` and is renamed to `wiggle`. * The new `wiggle` crate depends on `wiggle-macro` and reexports the macro. The goal here is that consumers only deal with the `wiggle` crate itself. No more crates depend on `wiggle-runtime` and all dependencies are entirely on just the `wiggle` crate. * Remove the `crates/wiggle/crates` directory Move everything into `crates/wiggle` directly, like `wasi-common` * Add wiggle-macro to test-all script * Fixup a test
This commit is contained in:
@@ -21,8 +21,7 @@ filetime = "0.2.7"
|
||||
lazy_static = "1.4.0"
|
||||
num = { version = "0.2.0", default-features = false }
|
||||
wig = { path = "wig", version = "0.13.0" }
|
||||
wiggle = { path = "../wiggle", default-features = false }
|
||||
wiggle-runtime = { path = "../wiggle/crates/runtime" }
|
||||
wiggle = { path = "../wiggle", default-features = false, version = "0.13.0" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
yanix = { path = "yanix", version = "0.13.0" }
|
||||
@@ -38,4 +37,4 @@ maintenance = { status = "actively-developed" }
|
||||
[features]
|
||||
# Need to make the wiggle_metadata feature available to consumers of this
|
||||
# crate if they want the snapshots to have metadata available.
|
||||
wiggle_metadata = ["wiggle/wiggle_metadata", "wiggle-runtime/wiggle_metadata"]
|
||||
wiggle_metadata = ["wiggle/wiggle_metadata"]
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::wasi::{types, Errno, Result};
|
||||
use crate::{entry::Descriptor, entry::Entry};
|
||||
use std::path::{Component, Path};
|
||||
use std::str;
|
||||
use wiggle_runtime::{GuestBorrows, GuestPtr};
|
||||
use wiggle::{GuestBorrows, GuestPtr};
|
||||
|
||||
pub(crate) use sys::path::*;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::cell::Ref;
|
||||
use std::convert::TryInto;
|
||||
use std::fs::File;
|
||||
use std::io::{self, Read, Seek, SeekFrom, Write};
|
||||
use wiggle_runtime::{GuestBorrows, GuestPtr};
|
||||
use wiggle::{GuestBorrows, GuestPtr};
|
||||
|
||||
impl<'a> WasiSnapshotPreview1 for WasiCtx {
|
||||
fn args_get<'b>(
|
||||
|
||||
@@ -11,23 +11,23 @@ wiggle::from_witx!({
|
||||
pub use types::Errno;
|
||||
pub type Result<T> = std::result::Result<T, Errno>;
|
||||
|
||||
impl<'a> wiggle_runtime::GuestErrorType<'a> for Errno {
|
||||
impl<'a> wiggle::GuestErrorType<'a> for Errno {
|
||||
type Context = WasiCtx;
|
||||
|
||||
fn success() -> Self {
|
||||
Self::Success
|
||||
}
|
||||
|
||||
fn from_error(e: wiggle_runtime::GuestError, _ctx: &Self::Context) -> Self {
|
||||
fn from_error(e: wiggle::GuestError, _ctx: &Self::Context) -> Self {
|
||||
eprintln!("Guest error: {:?}", e);
|
||||
// TODO proper error mapping
|
||||
Self::Inval
|
||||
}
|
||||
}
|
||||
|
||||
impl From<wiggle_runtime::GuestError> for Errno {
|
||||
fn from(err: wiggle_runtime::GuestError) -> Self {
|
||||
use wiggle_runtime::GuestError::*;
|
||||
impl From<wiggle::GuestError> for Errno {
|
||||
fn from(err: wiggle::GuestError) -> Self {
|
||||
use wiggle::GuestError::*;
|
||||
match err {
|
||||
InvalidFlagValue { .. } => Self::Inval,
|
||||
InvalidEnumValue { .. } => Self::Inval,
|
||||
@@ -83,7 +83,7 @@ pub(crate) trait AsBytes {
|
||||
impl AsBytes for types::Dirent {
|
||||
fn as_bytes(&self) -> Result<Vec<u8>> {
|
||||
use std::convert::TryInto;
|
||||
use wiggle_runtime::GuestType;
|
||||
use wiggle::GuestType;
|
||||
|
||||
assert_eq!(
|
||||
Self::guest_size(),
|
||||
|
||||
@@ -464,7 +464,7 @@ pub fn define_struct_for_wiggle(args: TokenStream) -> TokenStream {
|
||||
|
||||
quote! {
|
||||
/// Lightweight `wasmtime::Memory` wrapper so that we can
|
||||
/// implement `wiggle_runtime::GuestMemory` trait on it which is
|
||||
/// implement `wiggle::GuestMemory` trait on it which is
|
||||
/// now required to interface with `wasi-common`.
|
||||
struct WasiMemory(wasmtime::Memory);
|
||||
|
||||
@@ -474,7 +474,7 @@ pub fn define_struct_for_wiggle(args: TokenStream) -> TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl wiggle_runtime::GuestMemory for WasiMemory {
|
||||
unsafe impl wiggle::GuestMemory for WasiMemory {
|
||||
fn base(&self) -> (*mut u8, u32) {
|
||||
(self.0.data_ptr(), self.0.data_size() as _)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user