From e0840b34c4f5fb7b56d4a62b31ee0ad877d75df0 Mon Sep 17 00:00:00 2001 From: Victor Gao Date: Thu, 5 May 2022 10:35:19 -0700 Subject: [PATCH] [evm][move package] remove build dir before starting a new build --- .../move-package/src/compilation/build_plan.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/language/tools/move-package/src/compilation/build_plan.rs b/language/tools/move-package/src/compilation/build_plan.rs index c952fe56fa..019e3d772a 100644 --- a/language/tools/move-package/src/compilation/build_plan.rs +++ b/language/tools/move-package/src/compilation/build_plan.rs @@ -248,6 +248,22 @@ impl BuildPlan { package_names )?; + if let Err(err) = std::fs::remove_dir_all(&build_root_path) { + match err.kind() { + io::ErrorKind::NotFound => (), + _ => { + writeln!( + writer, + "{} Failed to remove build dir {}: {}", + "ERROR".bold().red(), + build_root_path.to_string_lossy(), + err, + )?; + + return Err(err.into()); + } + } + } if let Err(err) = std::fs::create_dir_all(&build_root_path) { writeln!( writer, @@ -296,6 +312,7 @@ impl BuildPlan { } // Step 2: Compile Yul into bytecode using solc + let yul_source = match std::fs::read_to_string(&yul_output) { Ok(yul_source) => yul_source, Err(err) => {