From 03412722d81ec17fa7b1aa1c98d53d92ecaf4d75 Mon Sep 17 00:00:00 2001 From: liquidev Date: Fri, 23 Aug 2024 23:14:33 +0200 Subject: [PATCH] make it possible to override wasm directory from wasm-dev during build --- Justfile | 2 +- crates/rkgk/src/main.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Justfile b/Justfile index 97d5b34..852af34 100644 --- a/Justfile +++ b/Justfile @@ -1,7 +1,7 @@ port := "8080" serve wasm_profile="wasm-dev": (wasm wasm_profile) - RKGK_PORT={{port}} cargo run -p rkgk + RKGK_PORT={{port}} RKGK_WASM_PATH=target/wasm32-unknown-unknown/{{wasm_profile}} cargo run -p rkgk wasm profile="wasm-dev": cargo build -p haku-wasm --target wasm32-unknown-unknown --profile {{profile}} diff --git a/crates/rkgk/src/main.rs b/crates/rkgk/src/main.rs index d2686ac..aea8e11 100644 --- a/crates/rkgk/src/main.rs +++ b/crates/rkgk/src/main.rs @@ -34,6 +34,7 @@ static GLOBAL_ALLOCATOR: tracy_client::ProfiledAllocator = struct Paths<'a> { target_dir: &'a Path, + target_wasm_dir: &'a Path, database_dir: &'a Path, } @@ -47,7 +48,7 @@ fn build(paths: &Paths<'_>) -> eyre::Result<()> { create_dir_all(paths.target_dir.join("static/wasm")) .context("cannot create static/wasm directory")?; copy( - "target/wasm32-unknown-unknown/wasm-dev/haku_wasm.wasm", + paths.target_wasm_dir.join("haku_wasm.wasm"), paths.target_dir.join("static/wasm/haku.wasm"), ) .context("cannot copy haku.wasm file")?; @@ -76,7 +77,10 @@ fn database(config: &Config, paths: &Paths<'_>) -> eyre::Result { } async fn fallible_main() -> eyre::Result<()> { + let target_wasm_dir = + std::env::var("RKGK_WASM_PATH").unwrap_or("target/wasm32-unknown-unknown/wasm-dev".into()); let paths = Paths { + target_wasm_dir: Path::new(&target_wasm_dir), target_dir: Path::new("target/site"), database_dir: Path::new("database"), };