diff --git a/Cargo.lock b/Cargo.lock index 2414ad9a..5dc7750c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -373,17 +373,15 @@ dependencies = [ "wasmer-runtime", "wasmer-runtime-core", "wasmer-wasi", + "wit_parser", ] [[package]] name = "fce_wit_interfaces" version = "0.1.0" dependencies = [ - "anyhow", "multimap", - "walrus", "wasmer-interface-types", - "wasmer-runtime-core", ] [[package]] @@ -516,6 +514,7 @@ name = "ipfs_node" version = "0.1.0" dependencies = [ "fce", + "toml", ] [[package]] @@ -936,6 +935,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "toml" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +dependencies = [ + "serde", +] + [[package]] name = "typenum" version = "1.12.0" @@ -1229,5 +1237,16 @@ dependencies = [ "clap", "exitfailure", "failure", - "fce_wit_interfaces", + "wit_parser", +] + +[[package]] +name = "wit_parser" +version = "0.1.0" +dependencies = [ + "anyhow", + "fce_wit_interfaces", + "walrus", + "wasmer-interface-types", + "wasmer-runtime-core", ] diff --git a/Cargo.toml b/Cargo.toml index d5ceb0fd..81306b37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "crates/fce_wit_interfaces", + "crates/wit_parser", "examples/ipfs_node", "examples/ipfs_node/wasm/ipfs_node", "examples/ipfs_node/wasm/ipfs_rpc", diff --git a/crates/fce_wit_interfaces/Cargo.toml b/crates/fce_wit_interfaces/Cargo.toml index 4c7aca48..3d3f2286 100644 --- a/crates/fce_wit_interfaces/Cargo.toml +++ b/crates/fce_wit_interfaces/Cargo.toml @@ -9,9 +9,5 @@ name = "fce_wit_interfaces" path = "src/lib.rs" [dependencies] -walrus = "0.17.0" -wasmer-core = { package = "wasmer-runtime-core", version = "0.17.0", features = ["dynamicfunc-fat-closures"] } wasmer-wit = { package = "wasmer-interface-types", git = "https://github.com/fluencelabs/interface-types", branch = "master"} - multimap = "0.8.1" -anyhow = "1.0.31" diff --git a/crates/fce_wit_interfaces/src/interfaces/errors.rs b/crates/fce_wit_interfaces/src/errors.rs similarity index 100% rename from crates/fce_wit_interfaces/src/interfaces/errors.rs rename to crates/fce_wit_interfaces/src/errors.rs diff --git a/crates/fce_wit_interfaces/src/interfaces/fce_wit_interfaces.rs b/crates/fce_wit_interfaces/src/fce_wit_interfaces.rs similarity index 100% rename from crates/fce_wit_interfaces/src/interfaces/fce_wit_interfaces.rs rename to crates/fce_wit_interfaces/src/fce_wit_interfaces.rs diff --git a/crates/fce_wit_interfaces/src/interfaces/mod.rs b/crates/fce_wit_interfaces/src/interfaces/mod.rs deleted file mode 100644 index 1d2e1e72..00000000 --- a/crates/fce_wit_interfaces/src/interfaces/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2020 Fluence Labs Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -mod errors; -mod fce_wit_interfaces; - -pub use fce_wit_interfaces::*; -pub use errors::*; diff --git a/crates/fce_wit_interfaces/src/lib.rs b/crates/fce_wit_interfaces/src/lib.rs index 7baca15b..3d468792 100644 --- a/crates/fce_wit_interfaces/src/lib.rs +++ b/crates/fce_wit_interfaces/src/lib.rs @@ -24,8 +24,8 @@ unreachable_patterns )] -mod interfaces; -mod wit_parser; +mod errors; +mod fce_wit_interfaces; -pub use crate::wit_parser::*; -pub use crate::interfaces::*; +pub use errors::*; +pub use fce_wit_interfaces::*; diff --git a/crates/wit_parser/Cargo.toml b/crates/wit_parser/Cargo.toml new file mode 100644 index 00000000..ecc01550 --- /dev/null +++ b/crates/wit_parser/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "wit_parser" +version = "0.1.0" +authors = ["Fluence Labs"] +edition = "2018" + +[lib] +name = "wit_parser" +path = "src/lib.rs" + +[dependencies] +walrus = "0.17.0" +wasmer-core = { package = "wasmer-runtime-core", version = "0.17.0"} +wasmer-wit = { package = "wasmer-interface-types", git = "https://github.com/fluencelabs/interface-types", branch = "master" } +fce_wit_interfaces = { path = "../fce_wit_interfaces" } + +anyhow = "1.0.31" diff --git a/crates/fce_wit_interfaces/src/wit_parser/custom.rs b/crates/wit_parser/src/custom.rs similarity index 100% rename from crates/fce_wit_interfaces/src/wit_parser/custom.rs rename to crates/wit_parser/src/custom.rs diff --git a/crates/fce_wit_interfaces/src/wit_parser/deleter.rs b/crates/wit_parser/src/deleter.rs similarity index 100% rename from crates/fce_wit_interfaces/src/wit_parser/deleter.rs rename to crates/wit_parser/src/deleter.rs diff --git a/crates/fce_wit_interfaces/src/wit_parser/embedder.rs b/crates/wit_parser/src/embedder.rs similarity index 100% rename from crates/fce_wit_interfaces/src/wit_parser/embedder.rs rename to crates/wit_parser/src/embedder.rs diff --git a/crates/fce_wit_interfaces/src/wit_parser/errors.rs b/crates/wit_parser/src/errors.rs similarity index 100% rename from crates/fce_wit_interfaces/src/wit_parser/errors.rs rename to crates/wit_parser/src/errors.rs diff --git a/crates/fce_wit_interfaces/src/wit_parser/extractor.rs b/crates/wit_parser/src/extractor.rs similarity index 98% rename from crates/fce_wit_interfaces/src/wit_parser/extractor.rs rename to crates/wit_parser/src/extractor.rs index 98aabb3b..d3aa4828 100644 --- a/crates/fce_wit_interfaces/src/wit_parser/extractor.rs +++ b/crates/wit_parser/src/extractor.rs @@ -16,8 +16,8 @@ use super::custom::WIT_SECTION_NAME; use super::errors::WITParserError; -use crate::interfaces::FCEWITInterfaces; +use fce_wit_interfaces::FCEWITInterfaces; use walrus::{IdsToIndices, ModuleConfig}; use wasmer_wit::ast::Interfaces; use wasmer_core::Module as WasmerModule; diff --git a/crates/fce_wit_interfaces/src/wit_parser/mod.rs b/crates/wit_parser/src/lib.rs similarity index 82% rename from crates/fce_wit_interfaces/src/wit_parser/mod.rs rename to crates/wit_parser/src/lib.rs index 5b409670..99874dc4 100644 --- a/crates/fce_wit_interfaces/src/wit_parser/mod.rs +++ b/crates/wit_parser/src/lib.rs @@ -13,12 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#![warn(rust_2018_idioms)] +#![deny( + dead_code, + nonstandard_style, + unused_imports, + unused_mut, + unused_variables, + unused_unsafe, + unreachable_patterns +)] mod custom; +mod deleter; +mod embedder; mod errors; mod extractor; -mod embedder; -mod deleter; pub use errors::WITParserError; diff --git a/examples/ipfs_node/Cargo.toml b/examples/ipfs_node/Cargo.toml index 08a6e6a6..77a626d1 100644 --- a/examples/ipfs_node/Cargo.toml +++ b/examples/ipfs_node/Cargo.toml @@ -6,3 +6,4 @@ edition = "2018" [dependencies] fce = { path = "../../fce" } +toml = "0.5.6" diff --git a/examples/ipfs_node/Config.toml b/examples/ipfs_node/Config.toml new file mode 100644 index 00000000..977287f2 --- /dev/null +++ b/examples/ipfs_node/Config.toml @@ -0,0 +1,6 @@ +[ipfs_node] + [imports] + ipfs = "/usr/bin/ipfs" + + [wasi] + preopened_dir = ["/tmp"] diff --git a/fce/Cargo.toml b/fce/Cargo.toml index 100a8c27..c4b75d89 100644 --- a/fce/Cargo.toml +++ b/fce/Cargo.toml @@ -6,6 +6,7 @@ edition = "2018" [dependencies] fce_wit_interfaces = { path = "../crates/fce_wit_interfaces" } +wit_parser = { path = "../crates/wit_parser" } wasmer-runtime = "0.17.0" # dynamicfunc-fat-closures allows using state inside DynamicFunc diff --git a/fce/src/vm/errors.rs b/fce/src/vm/errors.rs index 0278dacb..3538252b 100644 --- a/fce/src/vm/errors.rs +++ b/fce/src/vm/errors.rs @@ -14,8 +14,8 @@ * limitations under the License. */ -use fce_wit_interfaces::WITParserError; use fce_wit_interfaces::FCEWITInterfacesError; +use wit_parser::WITParserError; use wasmer_wit::errors::InstructionError; use wasmer_runtime::error::{ diff --git a/fce/src/vm/instance/fce_module.rs b/fce/src/vm/instance/fce_module.rs index d7290ed7..87874d66 100644 --- a/fce/src/vm/instance/fce_module.rs +++ b/fce/src/vm/instance/fce_module.rs @@ -17,12 +17,12 @@ use super::wit_prelude::*; use super::{IType, IValue, WValue}; -use fce_wit_interfaces::extract_fce_wit; use fce_wit_interfaces::FCEWITInterfaces; use wasmer_wit::interpreter::Interpreter; use wasmer_runtime::{compile, ImportObject}; use wasmer_core::Instance as WasmerInstance; use wasmer_core::import::Namespace; +use wit_parser::extract_fce_wit; use std::collections::HashMap; use std::convert::TryInto; diff --git a/tools/wit_embedder/Cargo.toml b/tools/wit_embedder/Cargo.toml index bcfa4c79..d8a6df46 100644 --- a/tools/wit_embedder/Cargo.toml +++ b/tools/wit_embedder/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Fluence Labs"] edition = "2018" [dependencies] -fce_wit_interfaces = { path = "../../crates/fce_wit_interfaces" } +wit_parser = { path = "../../crates/wit_parser" } clap = "2.33.1" exitfailure = "0.5.1" failure = "0.1.5" diff --git a/tools/wit_embedder/src/main.rs b/tools/wit_embedder/src/main.rs index dde15a86..e90e9b9b 100644 --- a/tools/wit_embedder/src/main.rs +++ b/tools/wit_embedder/src/main.rs @@ -28,9 +28,9 @@ mod args; use args::*; -use fce_wit_interfaces::embed_text_wit; -use fce_wit_interfaces::extract_text_wit; -use fce_wit_interfaces::delete_wit_section; +use wit_parser::embed_text_wit; +use wit_parser::extract_text_wit; +use wit_parser::delete_wit_section; use clap::{App, AppSettings}; use std::path::PathBuf;