woweb-poc/woweb/build.rs

30 lines
1010 B
Rust
Raw Normal View History

use std::env;
use std::fs;
use std::path::Path;
use std::process::Command;
fn main() {
let woweb_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let woweb_path = Path::new(&woweb_dir);
let woweb_asset_path = woweb_path.join("assets");
let dist_text_path = woweb_path.parent().unwrap().join("dist_text_js");
let dist_text_pkg_path = dist_text_path.join("pkg");
Command::new("wasm-pack")
.args(&["build", "--target", "web", "--release", "--no-typescript"])
.current_dir(dist_text_path)
.status()
.unwrap();
let js_path_src = dist_text_pkg_path.join("dist_text_js.js");
let js_path_dest = woweb_asset_path.join("dist_text_js.js");
let wasm_path_src = dist_text_pkg_path.join("dist_text_js_bg.wasm");
let wasm_path_dest = woweb_asset_path.join("dist_text_js_bg.wasm");
let _ = fs::copy(js_path_src, js_path_dest);
let _ = fs::copy(wasm_path_src, wasm_path_dest);
println!("cargo:rerun-if-changed=../dist_text_js/**/*.rs");
}