Fixed the JS dependency issues

This commit is contained in:
John Sharratt's Shared Account
2022-11-14 17:24:55 +11:00
parent 3c6114c225
commit e28ce96c63
11 changed files with 52 additions and 43 deletions

1
Cargo.lock generated
View File

@@ -4672,6 +4672,7 @@ dependencies = [
name = "wasmer-wasi-types"
version = "3.0.0-rc.2"
dependencies = [
"bitflags",
"byteorder",
"num_enum",
"pretty_assertions",

View File

@@ -36,7 +36,7 @@ tracing = { version = "0.1", optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# - Mandatory dependencies for `sys`.
wasmer-vm = { path = "../vm", version = "=3.0.0-rc.2" }
wasmer-compiler = { path = "../compiler", version = "=3.0.0-rc.2" }
wasmer-compiler = { path = "../compiler", version = "=3.0.0-rc.2", optional = true }
wasmer-derive = { path = "../derive", version = "=3.0.0-rc.2" }
wasmer-types = { path = "../types", version = "=3.0.0-rc.2" }
target-lexicon = { version = "0.12.2", default-features = false }
@@ -97,13 +97,14 @@ core = ["hashbrown"]
# Features for `sys`.
sys = [
"compiler",
"wasmer-compiler/translator",
"wasmer-compiler/compiler",
]
sys-default = ["sys", "wat", "cranelift"]
# - Compilers.
compiler = [
"sys",
"wasmer-compiler"
]
singlepass = ["compiler", "wasmer-compiler-singlepass"]
cranelift = ["compiler", "wasmer-compiler-cranelift"]

View File

@@ -2,7 +2,6 @@ use crate::sys::exports::{ExportError, Exportable};
use crate::sys::externals::Extern;
use crate::sys::store::{AsStoreMut, AsStoreRef};
use crate::sys::FunctionType;
use crate::sys::RuntimeError;
use crate::sys::TypedFunction;
use crate::FunctionEnv;
@@ -10,10 +9,13 @@ use crate::FunctionEnv;
use {
crate::{
FunctionEnvMut, Value,
sys::store::{
sys::{
RuntimeError,
store::{
StoreInner, StoreMut
},
},
},
inner::StaticFunction,
std::{
cell::UnsafeCell,

View File

@@ -4,6 +4,7 @@ use crate::sys::store::{AsStoreMut, AsStoreRef};
use crate::sys::value::Value;
use crate::sys::GlobalType;
use crate::sys::Mutability;
#[cfg(feature = "compiler")]
use crate::sys::RuntimeError;
use wasmer_vm::{InternalStoreHandle, StoreHandle, VMExtern, VMGlobal};

View File

@@ -1,13 +1,13 @@
use crate::sys::exports::{ExportError, Exportable};
use crate::sys::externals::Extern;
use crate::sys::store::{AsStoreMut, AsStoreRef};
use crate::sys::RuntimeError;
use crate::sys::TableType;
use crate::Value;
use wasmer_vm::{InternalStoreHandle, StoreHandle, TableElement, VMExtern, VMTable};
#[cfg(feature = "compiler")]
use crate::{
ExternRef, Function
ExternRef, Function,
sys::RuntimeError
};
/// A WebAssembly `table` instance.

View File

@@ -1,5 +1,6 @@
use crate::sys::exports::Exports;
use crate::sys::module::Module;
#[cfg(feature = "compiler")]
use crate::sys::{LinkError, RuntimeError};
use std::fmt;
use thiserror::Error;

View File

@@ -1,15 +1,15 @@
use std::fmt;
use std::io;
#[cfg(feature = "compiler")]
use std::path::Path;
#[cfg(feature = "compiler")]
use wasmer_compiler::ArtifactCreate;
use std::sync::Arc;
use thiserror::Error;
use bytes::Bytes;
use wasmer_compiler::Artifact;
use wasmer_compiler::ArtifactCreate;
#[cfg(feature = "wat")]
use wasmer_types::WasmError;
use wasmer_types::{
CompileError, ExportsIterator, ImportsIterator, ModuleInfo, SerializeError,
CompileError, ExportsIterator, ImportsIterator, ModuleInfo,
};
use wasmer_types::{ExportType, ImportType};
@@ -21,8 +21,6 @@ use crate::{
IntoBytes
};
#[cfg(feature = "compiler")]
use wasmer_types::DeserializeError;
#[cfg(feature = "compiler")]
use wasmer_vm::InstanceHandle;
#[derive(Error, Debug)]
@@ -59,7 +57,8 @@ pub struct Module {
//
// In the future, this code should be refactored to properly describe the
// ownership of the code and its metadata.
artifact: Arc<Artifact>,
#[cfg(feature = "compiler")]
artifact: Arc<wasmer_compiler::Artifact>,
module_info: Arc<ModuleInfo>,
}
@@ -136,7 +135,7 @@ impl Module {
e
)))
})?;
bytes = Bytes::from(parsed_bytes.to_vec());
bytes = bytes::Bytes::from(parsed_bytes.to_vec());
}
Self::from_binary(store, bytes.as_ref())
}
@@ -210,6 +209,7 @@ impl Module {
/// Serializes a module into a binary representation that the `Engine`
/// can later process via
#[cfg(feature = "enable-rkyv")]
#[cfg_attr(feature = "compiler", doc = "[`Module::deserialize`].")]
#[cfg_attr(not(feature = "compiler"), doc = "`Module::deserialize`.")]
///
@@ -224,12 +224,13 @@ impl Module {
/// # Ok(())
/// # }
/// ```
pub fn serialize(&self) -> Result<Bytes, SerializeError> {
pub fn serialize(&self) -> Result<bytes::Bytes, wasmer_types::SerializeError> {
self.artifact.serialize().map(|bytes| bytes.into())
}
/// Serializes a module into a file that the `Engine`
/// can later process via
#[cfg(feature = "enable-rkyv")]
#[cfg_attr(feature = "compiler", doc = "[`Module::deserialize_from_file`].")]
#[cfg_attr(not(feature = "compiler"), doc = "`Module::deserialize_from_file`.")]
///
@@ -244,10 +245,11 @@ impl Module {
/// # Ok(())
/// # }
/// ```
pub fn serialize_to_file(&self, path: impl AsRef<Path>) -> Result<(), SerializeError> {
pub fn serialize_to_file(&self, path: impl AsRef<Path>) -> Result<(), wasmer_types::SerializeError> {
self.artifact.serialize_to_file(path.as_ref())
}
#[cfg(feature = "enable-rkyv")]
#[cfg(feature = "compiler")]
/// Deserializes a serialized Module binary into a `Module`.
/// > Note: the module has to be serialized before with the `serialize` method.
@@ -275,12 +277,13 @@ impl Module {
pub unsafe fn deserialize(
store: &impl AsStoreRef,
bytes: impl IntoBytes,
) -> Result<Self, DeserializeError> {
) -> Result<Self, wasmer_types::DeserializeError> {
let bytes = bytes.into_bytes();
let artifact = store.as_store_ref().engine().deserialize(&bytes)?;
Ok(Self::from_artifact(artifact))
}
#[cfg(feature = "enable-rkyv")]
#[cfg(feature = "compiler")]
/// Deserializes a a serialized Module located in a `Path` into a `Module`.
/// > Note: the module has to be serialized before with the `serialize` method.
@@ -302,7 +305,7 @@ impl Module {
pub unsafe fn deserialize_from_file(
store: &impl AsStoreRef,
path: impl AsRef<Path>,
) -> Result<Self, DeserializeError> {
) -> Result<Self, wasmer_types::DeserializeError> {
let artifact = store
.as_store_ref()
.engine()
@@ -311,7 +314,7 @@ impl Module {
}
#[cfg(feature = "compiler")]
fn from_artifact(artifact: Arc<Artifact>) -> Self {
fn from_artifact(artifact: Arc<wasmer_compiler::Artifact>) -> Self {
Self {
module_info: Arc::new(artifact.create_module_info()),
artifact,

View File

@@ -14,26 +14,27 @@ edition = "2018"
[dependencies]
wit-bindgen-rust = { package = "wasmer-wit-bindgen-rust", version = "0.1.1", optional = true }
wit-bindgen-rust-wasm = { package = "wasmer-wit-bindgen-gen-rust-wasm", version = "0.1.1", optional = true }
wit-bindgen-rust-wasm = { package = "wasmer-wit-bindgen-gen-rust-wasm", version = "0.1.1" }
wit-bindgen-core = { package = "wasmer-wit-bindgen-gen-core", version = "0.1.1" }
wit-parser = { package = "wasmer-wit-parser", version = "0.1.1" }
wasmer-types = { path = "../types", version = "=3.0.0-rc.2" }
wasmer-types = { path = "../types", version = "=3.0.0-rc.2", default_features = false }
wasmer-derive = { path = "../derive", version = "=3.0.0-rc.2" }
serde = { version = "1.0", features = ["derive"], optional = true }
byteorder = "1.3"
time = "0.2"
num_enum = "0.5.7"
bitflags = "1.3.2"
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasmer = { default-features = false, path = "../api", version = "3.0.0-beta", features = ["js"] }
wasmer = { default-features = false, path = "../api", version = "3.0.0-beta" }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
wasmer = { default-features = false, path = "../api", version = "3.0.0-beta", features = ["sys"] }
wasmer = { default-features = false, path = "../api", version = "3.0.0-beta" }
[dev-dependencies.pretty_assertions]
version = "1.3.0"
[features]
enable-serde = ["serde", "wasmer-types/serde"]
js = ["wasmer/js", "wit-bindgen-rust-wasm" ]
sys = ["wasmer/sys", "wit-bindgen-rust" ]
js = ["wasmer/js", "wasmer/std" ]
sys = ["wasmer/sys" ]

View File

@@ -544,7 +544,7 @@ pub mod output {
}
impl std::error::Error for BusErrno{}
wit_bindgen_rust::bitflags::bitflags! {
bitflags! {
/// File descriptor rights, determining which actions may be performed.
pub struct Rights: u64 {
/// The right to invoke `fd_datasync`.
@@ -780,7 +780,7 @@ pub mod output {
}
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// File descriptor flags.
pub struct Fdflags: u8 {
/// Append mode: Data written to the file is always appended to the file's end.
@@ -822,7 +822,7 @@ pub mod output {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Fdstat").field("fs-filetype", &self.fs_filetype).field("fs-flags", &self.fs_flags).field("fs-rights-base", &self.fs_rights_base).field("fs-rights-inheriting", &self.fs_rights_inheriting).finish()}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Which file time attributes to adjust.
/// TODO: wit appears to not have support for flags repr
/// (@witx repr u16)
@@ -844,7 +844,7 @@ pub mod output {
Self { bits }
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Flags determining the method of how paths are resolved.
/// TODO: wit appears to not have support for flags repr
/// (@witx repr u32)
@@ -860,7 +860,7 @@ pub mod output {
Self { bits }
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Open flags used by `path_open`.
/// TODO: wit appears to not have support for flags repr
/// (@witx repr u16)
@@ -914,7 +914,7 @@ pub mod output {
}
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Flags determining how to interpret the timestamp provided in
/// `subscription-clock::timeout`.
pub struct Subclockflags: u8 {
@@ -987,7 +987,7 @@ pub mod output {
}
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// The state of the file descriptor subscribed to with
/// `eventtype::fd_read` or `eventtype::fd_write`.
pub struct Eventrwflags: u8 {

View File

@@ -617,7 +617,7 @@ impl core::fmt::Display for BusErrno {
}
impl std::error::Error for BusErrno {}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// File descriptor rights, determining which actions may be performed.
pub struct Rights: u64 {
/// The right to invoke `fd_datasync`.
@@ -835,7 +835,7 @@ impl core::fmt::Debug for Advice {
}
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// File descriptor flags.
pub struct Fdflags: u16 {
/// Append mode: Data written to the file is always appended to the file's end.
@@ -883,7 +883,7 @@ impl core::fmt::Debug for Fdstat {
.finish()
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Which file time attributes to adjust.
/// TODO: wit appears to not have support for flags repr
/// (@witx repr u16)
@@ -905,7 +905,7 @@ impl Fstflags {
Self { bits }
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Flags determining the method of how paths are resolved.
/// TODO: wit appears to not have support for flags repr
/// (@witx repr u32)
@@ -921,7 +921,7 @@ impl Lookup {
Self { bits }
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Open flags used by `path_open`.
/// TODO: wit appears to not have support for flags repr
/// (@witx repr u16)
@@ -969,7 +969,7 @@ impl core::fmt::Debug for Eventtype {
}
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// Flags determining how to interpret the timestamp provided in
/// `subscription-clock::timeout`.
pub struct Subclockflags: u16 {
@@ -1053,7 +1053,7 @@ impl core::fmt::Debug for Preopentype {
}
}
}
wit_bindgen_rust::bitflags::bitflags! {
bitflags::bitflags! {
/// The state of the file descriptor subscribed to with
/// `eventtype::fd_read` or `eventtype::fd_write`.
pub struct Eventrwflags: u16 {

View File

@@ -17,8 +17,7 @@ generational-arena = { version = "0.2" }
tracing = "0.1"
getrandom = "0.2"
wasmer-wasi-types = { path = "../wasi-types", version = "=3.0.0-rc.2" }
# FIXME: evaluate if needed
wasmer-types = { path = "../types", version = "=3.0.0-rc.2" }
wasmer-types = { path = "../types", version = "=3.0.0-rc.2", default-features = false }
wasmer = { path = "../api", version = "=3.0.0-rc.2", default-features = false }
wasmer-vfs = { path = "../vfs", version = "=3.0.0-rc.2", default-features = false, features = ["mem-fs"] }
wasmer-vbus = { path = "../vbus", version = "=3.0.0-rc.2", default-features = false }
@@ -46,7 +45,7 @@ futures = { version = "0.3" }
async-trait = { version = "^0.1", optional = true }
urlencoding = { version = "^2", optional = true }
# FIXME: proper dependency!
webc-vfs = { version = "0.1", path = "../../../pirita/crates/webc-vfs", optional = true }
webc-vfs = { version = "0.1", path = "../../../pirita/crates/webc-vfs", default_features = false, optional = true }
serde_derive = { version = "^1", optional = true }
serde_json = { version = "^1", optional = true }
serde_yaml = { version = "^0.8", optional = true }