make it possible to override wasm directory from wasm-dev during build
This commit is contained in:
parent
c9859124c3
commit
03412722d8
2
Justfile
2
Justfile
|
@ -1,7 +1,7 @@
|
||||||
port := "8080"
|
port := "8080"
|
||||||
|
|
||||||
serve wasm_profile="wasm-dev": (wasm wasm_profile)
|
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":
|
wasm profile="wasm-dev":
|
||||||
cargo build -p haku-wasm --target wasm32-unknown-unknown --profile {{profile}}
|
cargo build -p haku-wasm --target wasm32-unknown-unknown --profile {{profile}}
|
||||||
|
|
|
@ -34,6 +34,7 @@ static GLOBAL_ALLOCATOR: tracy_client::ProfiledAllocator<std::alloc::System> =
|
||||||
|
|
||||||
struct Paths<'a> {
|
struct Paths<'a> {
|
||||||
target_dir: &'a Path,
|
target_dir: &'a Path,
|
||||||
|
target_wasm_dir: &'a Path,
|
||||||
database_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"))
|
create_dir_all(paths.target_dir.join("static/wasm"))
|
||||||
.context("cannot create static/wasm directory")?;
|
.context("cannot create static/wasm directory")?;
|
||||||
copy(
|
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"),
|
paths.target_dir.join("static/wasm/haku.wasm"),
|
||||||
)
|
)
|
||||||
.context("cannot copy haku.wasm file")?;
|
.context("cannot copy haku.wasm file")?;
|
||||||
|
@ -76,7 +77,10 @@ fn database(config: &Config, paths: &Paths<'_>) -> eyre::Result<Databases> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fallible_main() -> 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 {
|
let paths = Paths {
|
||||||
|
target_wasm_dir: Path::new(&target_wasm_dir),
|
||||||
target_dir: Path::new("target/site"),
|
target_dir: Path::new("target/site"),
|
||||||
database_dir: Path::new("database"),
|
database_dir: Path::new("database"),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue