mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-14 06:35:40 +00:00
Merge pull request #210 from wasmerio/fix/disable-caching-for-windows
no caching on windows
This commit is contained in:
commit
921f1d7671
@ -1,7 +1,6 @@
|
|||||||
extern crate structopt;
|
extern crate structopt;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
@ -14,7 +13,6 @@ use wasmer::webassembly::InstanceABI;
|
|||||||
use wasmer::*;
|
use wasmer::*;
|
||||||
use wasmer_emscripten;
|
use wasmer_emscripten;
|
||||||
use wasmer_runtime::cache::{Cache as BaseCache, FileSystemCache, WasmHash};
|
use wasmer_runtime::cache::{Cache as BaseCache, FileSystemCache, WasmHash};
|
||||||
use wasmer_runtime::error::CacheError;
|
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
#[structopt(name = "wasmer", about = "Wasm execution runtime.")]
|
#[structopt(name = "wasmer", about = "Wasm execution runtime.")]
|
||||||
@ -84,6 +82,12 @@ fn get_cache_dir() -> PathBuf {
|
|||||||
|
|
||||||
/// Execute a wasm/wat file
|
/// Execute a wasm/wat file
|
||||||
fn execute_wasm(options: &Run) -> Result<(), String> {
|
fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||||
|
// force disable caching on windows
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
let disable_cache = true;
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
let disable_cache = options.disable_cache;
|
||||||
|
|
||||||
let wasm_path = &options.path;
|
let wasm_path = &options.path;
|
||||||
|
|
||||||
let mut wasm_binary: Vec<u8> = read_file_contents(wasm_path).map_err(|err| {
|
let mut wasm_binary: Vec<u8> = read_file_contents(wasm_path).map_err(|err| {
|
||||||
@ -99,7 +103,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
.map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?;
|
.map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let module = if !options.disable_cache {
|
let module = if !disable_cache {
|
||||||
// If we have cache enabled
|
// If we have cache enabled
|
||||||
|
|
||||||
// We generate a hash for the given binary, so we can use it as key
|
// We generate a hash for the given binary, so we can use it as key
|
||||||
@ -188,8 +192,10 @@ fn main() {
|
|||||||
CLIOptions::SelfUpdate => {
|
CLIOptions::SelfUpdate => {
|
||||||
println!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io");
|
println!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io");
|
||||||
}
|
}
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
CLIOptions::Cache(cache) => match cache {
|
CLIOptions::Cache(cache) => match cache {
|
||||||
Cache::Clean => {
|
Cache::Clean => {
|
||||||
|
use std::fs;
|
||||||
let cache_dir = get_cache_dir();
|
let cache_dir = get_cache_dir();
|
||||||
fs::remove_dir_all(cache_dir.clone()).expect("Can't remove cache dir");
|
fs::remove_dir_all(cache_dir.clone()).expect("Can't remove cache dir");
|
||||||
fs::create_dir(cache_dir.clone()).expect("Can't create cache dir");
|
fs::create_dir(cache_dir.clone()).expect("Can't create cache dir");
|
||||||
@ -198,5 +204,9 @@ fn main() {
|
|||||||
println!("{}", get_cache_dir().to_string_lossy());
|
println!("{}", get_cache_dir().to_string_lossy());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
CLIOptions::Cache(_) => {
|
||||||
|
println!("Caching is disabled for Windows.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ ChangesEnvironment=yes
|
|||||||
OutputBaseFilename=WasmerInstaller
|
OutputBaseFilename=WasmerInstaller
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
Source: "..\target\release\wasmer.exe"; DestDir: "{app}\bin"
|
Source: "..\..\target\release\wasmer.exe"; DestDir: "{app}\bin"
|
||||||
|
|
||||||
[Code]
|
[Code]
|
||||||
const EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
|
const EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
|
||||||
|
Loading…
Reference in New Issue
Block a user