From a5b30c52e6b4f1091a671fa728cd5ac5291e1031 Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Thu, 11 Feb 2021 13:19:15 +0100 Subject: [PATCH] fix(build): copy assets also without --release (#179) --- build.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/build.rs b/build.rs index f1090b95e..2bea27270 100644 --- a/build.rs +++ b/build.rs @@ -90,6 +90,34 @@ fn main() { }); } } + } else { + // FIXME: Deduplicate this with the initial walk all .rs pattern + for entry in fs::read_dir(alt_target.join("wasm32-wasi/debug/")).unwrap() { + let entry = entry.unwrap().path(); + let ext = entry.extension(); + if ext.is_some() && ext.unwrap() == "wasm" { + dbg!(&entry); + Command::new("wasm-opt") + .arg("-O") + .arg(entry.as_os_str()) + .arg("-o") + .arg(format!( + "assets/plugins/{}", + entry.file_name().unwrap().to_string_lossy() + )) + .status() + .unwrap_or_else(|_| { + Command::new("cp") + .arg(entry.as_os_str()) + .arg(format!( + "assets/plugins/{}", + entry.file_name().unwrap().to_string_lossy() + )) + .status() + .unwrap() + }); + } + } } // Generate Shell Completions