Conform to Cargo's conventional file layout

Move `src/*.rs` to `src/bin/*.rs` which are automatically inferred as
binaries and move `src/utils.rs` to `src/lib.rs` which is compiled as a
reusable library for each of the binaries we're building.
This commit is contained in:
Alex Crichton
2019-08-13 12:47:33 -07:00
committed by Dan Gohman
parent e7fd72bd5c
commit 5fe550f533
5 changed files with 8 additions and 34 deletions

View File

@@ -56,10 +56,6 @@ use wasmtime_environ::{
};
use wasmtime_obj::emit_module;
mod utils;
static LOG_FILENAME_PREFIX: &str = "wasm2obj.dbg.";
const USAGE: &str = "
Wasm to native object translation utility.
Takes a binary WebAssembly module into a native object file.
@@ -112,7 +108,7 @@ fn main() {
if args.flag_debug {
pretty_env_logger::init();
} else {
utils::init_file_per_thread_logger();
wasmtime::init_file_per_thread_logger("wasm2obj.dbg.");
}
cache_conf::init(args.flag_cache);

View File

@@ -54,10 +54,6 @@ use wasmtime_wast::instantiate_spectest;
#[cfg(feature = "wasi-c")]
use wasmtime_wasi_c::instantiate_wasi_c;
mod utils;
static LOG_FILENAME_PREFIX: &str = "wasmtime.dbg.";
const USAGE: &str = "
Wasm runner.
@@ -207,7 +203,7 @@ fn main() {
if args.flag_debug {
pretty_env_logger::init();
} else {
utils::init_file_per_thread_logger();
wasmtime::init_file_per_thread_logger("wasmtime.dbg.");
}
cache_conf::init(args.flag_cache);

View File

@@ -37,10 +37,6 @@ use wasmtime_environ::cache_conf;
use wasmtime_jit::{Compiler, Features};
use wasmtime_wast::WastContext;
mod utils;
static LOG_FILENAME_PREFIX: &str = "cranelift.dbg.";
const USAGE: &str = "
Wast test runner.
@@ -80,7 +76,7 @@ fn main() {
if args.flag_debug {
pretty_env_logger::init();
} else {
utils::init_file_per_thread_logger();
wasmtime::init_file_per_thread_logger("cranelift.dbg.");
}
cache_conf::init(args.flag_cache);

View File

@@ -1,14 +1,12 @@
pub fn init_file_per_thread_logger() {
use super::LOG_FILENAME_PREFIX;
file_per_thread_logger::initialize(LOG_FILENAME_PREFIX);
pub fn init_file_per_thread_logger(prefix: &'static str) {
file_per_thread_logger::initialize(prefix);
// Extending behavior of default spawner:
// https://docs.rs/rayon/1.1.0/rayon/struct.ThreadPoolBuilder.html#method.spawn_handler
// Source code says DefaultSpawner is implementation detail and
// shouldn't be used directly.
rayon::ThreadPoolBuilder::new()
.spawn_handler(|thread| {
.spawn_handler(move |thread| {
let mut b = std::thread::Builder::new();
if let Some(name) = thread.name() {
b = b.name(name.to_owned());
@@ -16,8 +14,8 @@ pub fn init_file_per_thread_logger() {
if let Some(stack_size) = thread.stack_size() {
b = b.stack_size(stack_size);
}
b.spawn(|| {
file_per_thread_logger::initialize(LOG_FILENAME_PREFIX);
b.spawn(move || {
file_per_thread_logger::initialize(prefix);
thread.run()
})?;
Ok(())