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

Shuffle around the wiggle crates #1414

Merged
merged 4 commits into from
Mar 26, 2020
Merged
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
17 changes: 8 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions crates/wasi-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion crates/wasi-common/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-common/src/snapshots/wasi_snapshot_preview1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
12 changes: 6 additions & 6 deletions crates/wasi-common/src/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions crates/wasi-common/wig/src/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 _)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ wasi-common = { path = "../wasi-common", version = "0.13.0" }
wasmtime = { path = "../api", version = "0.13.0", default-features = false }
wasmtime-runtime = { path = "../runtime", version = "0.13.0" }
wig = { path = "../wasi-common/wig", version = "0.13.0" }
wiggle-runtime = { path = "../wiggle/crates/runtime", version = "0.13.0" }
wiggle = { path = "../wiggle", version = "0.13.0" }

[badges]
maintenance = { status = "actively-developed" }
22 changes: 10 additions & 12 deletions crates/wiggle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
name = "wiggle"
version = "0.13.0"
authors = ["Pat Hickey <phickey@fastly.com>", "Jakub Konka <kubkonk@jakubkonka.com>", "Alex Crichton <alex@alexcrichton.com>"]
license = "Apache-2.0 WITH LLVM-exception"
edition = "2018"
description = "Wiggle code generator"
license = "Apache-2.0 WITH LLVM-exception"
description = "Runtime components of wiggle code generator"
categories = ["wasm"]
keywords = ["webassembly", "wasm"]
repository = "https://github.com/bytecodealliance/wasmtime"
readme = "README.md"
include = ["src/**/*", "LICENSE"]

[lib]
proc-macro = true

[dependencies]
wiggle-generate = { path = "crates/generate", version = "0.13.0" }
wiggle-runtime = { path = "crates/runtime", version = "0.13.0" }
witx = { path = "../wasi-common/wig/WASI/tools/witx", version = "0.8.4" }
syn = { version = "1.0", features = ["full"] }
thiserror = "1"
witx = { path = "../wasi-common/wig/WASI/tools/witx", version = "0.8.4", optional = true }
wiggle-macro = { path = "macro", version = "0.13.0" }

[badges]
maintenance = { status = "actively-developed" }

[dev-dependencies]
wiggle-test = { path = "crates/test", version = "0.13.0" }
wiggle-test = { path = "test-helpers", version = "0.13.0" }
proptest = "0.9"

[features]
Expand All @@ -31,7 +29,7 @@ proptest = "0.9"
# by the `wiggle_metadata` feature flag. We use this feature flag so that
# users of wiggle are not forced to take a direct dependency on the `witx`
# crate unless they want it.
wiggle_metadata = ["wiggle-runtime/wiggle_metadata"]
wiggle_metadata = ['witx', "wiggle-macro/wiggle_metadata"]
# In order to test that the contents of this metadata module meet
# expectations, we must have this feature enabled for the crate by default.
default = ["wiggle_metadata"]
Loading