diff --git a/Cargo.lock b/Cargo.lock index a2b97ad28..71a71b8ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2753,6 +2753,7 @@ dependencies = [ "generate-emscripten-tests", "generate-wasi-tests", "glob 0.3.0", + "libc", "log", "rustc_version", "serde", @@ -2761,7 +2762,6 @@ dependencies = [ "wabt", "wasmer", "wasmer-clif-backend", - "wasmer-dev-utils", "wasmer-emscripten", "wasmer-kernel-loader", "wasmer-llvm-backend", @@ -2824,13 +2824,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "wasmer-dev-utils" -version = "0.16.2" -dependencies = [ - "libc", -] - [[package]] name = "wasmer-emscripten" version = "0.16.2" diff --git a/Cargo.toml b/Cargo.toml index 501485164..310138723 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,6 @@ wasmer-emscripten = { path = "lib/emscripten" } wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } wasmer-wasi = { path = "lib/wasi", optional = true } wasmer-kernel-loader = { path = "lib/kernel-loader", optional = true } -wasmer-dev-utils = { path = "lib/dev-utils", optional = true } wasmer-wasi-experimental-io-devices = { path = "lib/wasi-experimental-io-devices", optional = true } [workspace] @@ -55,7 +54,6 @@ members = [ "lib/middleware-common", "lib/kernel-loader", "lib/kernel-net", - "lib/dev-utils", "lib/wasi-experimental-io-devices", "lib/interface-types", "examples/parallel", @@ -75,10 +73,10 @@ rustc_version = "0.2" [dev-dependencies] criterion = "0.3" glob = "0.3" +libc = "0.2.60" # for `tests/dev-utils`'s Stdout capturing serde = { version = "1", features = ["derive"] } # used by the plugin example typetag = "0.1" # used by the plugin example wabt = "0.9.1" -wasmer-dev-utils = { path = "lib/dev-utils" } [features] default = ["fast-tests", "wasi", "backend-cranelift", "wabt"] diff --git a/Makefile b/Makefile index 70c77e40a..a357cdf50 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,6 @@ test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-ems capi-test: test-capi test-rest: - cargo test --release -p wasmer-dev-utils cargo test --release -p wasmer-interface-types cargo test --release -p wasmer-kernel-loader cargo test --release -p kernel-net @@ -210,7 +209,7 @@ check-bench: check-bench-singlepass check-bench-llvm # TODO: We wanted `--workspace --exclude wasmer-runtime`, but can't due # to https://github.com/rust-lang/cargo/issues/6745 . -NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-dev-utils -p wasmer-interface-types +NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-interface-types RUNTIME_CHECK = cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features check: check-bench cargo check $(NOT_RUNTIME_CRATES) @@ -348,7 +347,7 @@ publish-release: # cargo install cargo-deps # must install graphviz for `dot` dep-graph: - cargo deps --optional-deps --filter wasmer-wasi wasmer-kernel-loader wasmer-dev-utils wasmer-llvm-backend wasmer-emscripten wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png + cargo deps --optional-deps --filter wasmer-wasi wasmer-kernel-loader wasmer-llvm-backend wasmer-emscripten wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png docs-capi: cd lib/runtime-c-api/ && doxygen doxyfile diff --git a/lib/dev-utils/Cargo.toml b/lib/dev-utils/Cargo.toml deleted file mode 100644 index 07800ed61..000000000 --- a/lib/dev-utils/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "wasmer-dev-utils" -version = "0.16.2" -description = "Wasmer runtime core library" -license = "MIT" -authors = ["The Wasmer Engineering Team "] -edition = "2018" -repository = "https://github.com/wasmerio/wasmer" -publish = false - -[dependencies] -libc = "0.2.60" diff --git a/lib/dev-utils/README.md b/lib/dev-utils/README.md deleted file mode 100644 index d198eaa70..000000000 --- a/lib/dev-utils/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Dev Utils - -This is shared code between the modules for testing and development only. Code in this crate will not be shipped. diff --git a/lib/dev-utils/src/lib.rs b/lib/dev-utils/src/lib.rs deleted file mode 100644 index 2a470bba4..000000000 --- a/lib/dev-utils/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![doc(html_favicon_url = "https://wasmer.io/static/icons/favicon.ico")] -#![doc(html_logo_url = "https://avatars3.githubusercontent.com/u/44205449?s=200&v=4")] - -pub mod file_descriptor; -pub mod stdio; diff --git a/src/commands/run.rs b/src/commands/run.rs index cab0d6fa8..cc851e743 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -1,9 +1,11 @@ use crate::common::{get_cache_dir, PrestandardFeatures}; use crate::utils::read_file_contents; use std::collections::HashMap; -use std::fs::read_to_string; -use std::fs::File; -use std::io::{Read, Write}; +use std::fs; +#[cfg(feature = "managed")] +use std::io::Read; +#[cfg(any(feature = "backend-llvm", feature = "managed"))] +use std::io::Write; use std::path::PathBuf; use std::process::exit; use std::str::FromStr; @@ -363,7 +365,7 @@ fn execute_wasi( module.info(), &_wasm_binary, if let Some(ref path) = options.resume { - let mut f = File::open(path).unwrap(); + let mut f = fs::File::open(path).unwrap(); let mut out: Vec = vec![]; f.read_to_end(&mut out).unwrap(); wasmer_runtime_core::state::InstanceImage::from_bytes(&out) @@ -461,7 +463,7 @@ impl LLVMCallbacks for LLVMCLIOptions { fn obj_memory_buffer_callback(&mut self, memory_buffer: &InkwellMemoryBuffer) { if let Some(filename) = &self.obj_file { let mem_buf_slice = memory_buffer.as_slice(); - let mut file = File::create(filename).unwrap(); + let mut file = fs::File::create(filename).unwrap(); let mut pos = 0; while pos < mem_buf_slice.len() { pos += file.write(&mem_buf_slice[pos..]).unwrap(); @@ -493,7 +495,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { })?; let em_symbol_map = if let Some(em_symbol_map_path) = options.em_symbol_map.clone() { - let em_symbol_map_content: String = read_to_string(&em_symbol_map_path) + let em_symbol_map_content: String = fs::read_to_string(&em_symbol_map_path) .map_err(|err| { format!( "Can't read symbol map file {}: {}", @@ -860,7 +862,7 @@ fn interactive_shell(mut ctx: InteractiveShellContext) -> ShellExitOperation { if let Some(ref image) = ctx.image { let buf = image.to_bytes(); - let mut f = match File::create(path) { + let mut f = match fs::File::create(path) { Ok(x) => x, Err(e) => { println!("Cannot open output file at {}: {:?}", path, e); diff --git a/lib/dev-utils/src/file_descriptor.rs b/tests/dev_utils/file_descriptor.rs similarity index 100% rename from lib/dev-utils/src/file_descriptor.rs rename to tests/dev_utils/file_descriptor.rs diff --git a/tests/dev_utils/mod.rs b/tests/dev_utils/mod.rs new file mode 100644 index 000000000..76ae6804f --- /dev/null +++ b/tests/dev_utils/mod.rs @@ -0,0 +1,2 @@ +pub mod file_descriptor; +pub mod stdio; diff --git a/lib/dev-utils/src/stdio.rs b/tests/dev_utils/stdio.rs similarity index 100% rename from lib/dev-utils/src/stdio.rs rename to tests/dev_utils/stdio.rs diff --git a/tests/emtest.rs b/tests/emtest.rs index d8a255bce..ae941d3c8 100644 --- a/tests/emtest.rs +++ b/tests/emtest.rs @@ -1 +1,2 @@ +pub mod dev_utils; mod emtests; diff --git a/tests/emtests/_common.rs b/tests/emtests/_common.rs index 236e264c6..8808e704a 100644 --- a/tests/emtests/_common.rs +++ b/tests/emtests/_common.rs @@ -37,7 +37,7 @@ macro_rules! assert_emscripten_output { EmscriptenGlobals, generate_emscripten_env, }; - use wasmer_dev_utils::stdio::StdioCapturer; + use crate::dev_utils::stdio::StdioCapturer; let wasm_bytes = include_bytes!($file); let backend = $crate::emtests::_common::get_backend().expect("Please set one of `WASMER_TEST_CRANELIFT`, `WASMER_TEST_LLVM`, or `WASMER_TEST_SINGELPASS` to `1`."); diff --git a/tests/wasitest.rs b/tests/wasitest.rs index a89a8f1a3..dd8af3824 100644 --- a/tests/wasitest.rs +++ b/tests/wasitest.rs @@ -1 +1,2 @@ +pub mod dev_utils; mod wasitests; diff --git a/tests/wasitests/_common.rs b/tests/wasitests/_common.rs index a747f18ee..6cc303332 100644 --- a/tests/wasitests/_common.rs +++ b/tests/wasitests/_common.rs @@ -32,7 +32,7 @@ pub fn get_backend() -> Option { macro_rules! assert_wasi_output { ($file:expr, $name:expr, $po_dir_args: expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{ - use wasmer_dev_utils::stdio::StdioCapturer; + use crate::dev_utils::stdio::StdioCapturer; use wasmer_runtime::Func; use wasmer_wasi::{generate_import_object_for_version, get_wasi_version};