Skip to content

Commit

Permalink
DO NOT MERGE WITHOUT REFACTORING: skip wasm-opt if the optimized wasm…
Browse files Browse the repository at this point in the history
… is newer than the original wasm, which means that we have already optimized it
  • Loading branch information
frol authored and dj8yf0μl committed Jan 20, 2025
1 parent 15d3749 commit e746699
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cargo-near-build/src/near/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,20 @@ pub fn run(args: Opts) -> eyre::Result<CompilationArtifact> {
)?;

wasm_artifact.path = {
let (from_path, _maybe_tmpfile) =
maybe_wasm_opt_step(&wasm_artifact.path, args.no_wasmopt)?;
crate::fs::copy_to_file(
&from_path,
&out_dir.join(wasm_artifact.path.file_name().expect("has filename")),
)?
let target_path = out_dir.join(wasm_artifact.path.file_name().expect("has filename"));
if std::fs::metadata(&wasm_artifact.path)
.and_then(|m| m.modified())
.unwrap_or_else(|_| std::time::SystemTime::now())
> std::fs::metadata(&target_path)
.and_then(|m| m.modified())
.unwrap_or_else(|_| std::time::SystemTime::UNIX_EPOCH)
{
let (from_path, _maybe_tmpfile) =
maybe_wasm_opt_step(&wasm_artifact.path, args.no_wasmopt)?;
crate::fs::copy_to_file(&from_path, &target_path)?
} else {
target_path
}
};

wasm_artifact.builder_version_info = Some(builder_version_info);
Expand Down

0 comments on commit e746699

Please sign in to comment.