Skip to content

Commit

Permalink
Skip files optimization in Nix.
Browse files Browse the repository at this point in the history
  • Loading branch information
koxu1996 committed Jul 30, 2024
1 parent de9c5a2 commit 92f9ae5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kairos-cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ fn main() {
println!("cargo:rerun-if-env-changed=PATH_TO_SESSION_BINARIES");

// Determine the session binaries directory.
let session_binaries_dir = if let Ok(session_code_dir) = env::var("PATH_TO_SESSION_BINARIES") {
PathBuf::from(session_code_dir)
let (is_automatic_path, session_binaries_dir) = if let Ok(session_code_dir) = env::var("PATH_TO_SESSION_BINARIES") {
(false, PathBuf::from(session_code_dir))
} else {
// Run `cargo build --release` if the environment variable is not set.
println!("cargo:warning=Building session code dependency.");
Expand All @@ -25,14 +25,17 @@ fn main() {
panic!("cargo build --release failed");
}

get_default_wasm_directory(&project_root)
(true, get_default_wasm_directory(&project_root))
};

// Rerun the build script if the session binaries directory changes.
println!("cargo:rerun-if-changed={}", session_binaries_dir.display());

// Ensure all WASM files are optimized.
optimize_files(&session_binaries_dir).expect("Unable to optimize WASM files");
// NOTE: We skip it for Nix (it relies on env variable), as files are already optimized and read-only.
if is_automatic_path {
optimize_files(&session_binaries_dir).expect("Unable to optimize WASM files");
}

// Get the output directory set by Cargo.
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
Expand Down

0 comments on commit 92f9ae5

Please sign in to comment.