From 369be1d191041c8cfee738a91aa0aaab57167507 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 18 Mar 2022 08:23:18 +0100 Subject: [PATCH 1/6] Improve error output during build script --- build.rs | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/build.rs b/build.rs index 23b08711..c9498c83 100644 --- a/build.rs +++ b/build.rs @@ -85,24 +85,42 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf) // > * Any sub-packages will be skipped (any subdirectory that contains a Cargo.toml file). // // (from https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields) - std::fs::rename( - ink_dylint_driver_dir.join("_Cargo.toml"), - ink_dylint_driver_dir.join("Cargo.toml"), - )?; - - let res = build_and_zip_dylint_driver( - ink_dylint_driver_dir.clone(), - out_dir, - dylint_driver_dst_file, - ); + let original_name = ink_dylint_driver_dir.join("_Cargo.toml"); + let original_name = original_name.canonicalize().map_err(|err| { + anyhow::anyhow!("Unable to canonicalize '{:?}': {:?}", original_name, err) + })?; + if !original_name.exists() { + anyhow::bail!( + "'{:?}' does not exist, does the folder '{:?}'? {:?}", + original_name, + ink_dylint_driver_dir, + ink_dylint_driver_dir.exists() + ); + } + + let tmp_name = ink_dylint_driver_dir.join("Cargo.toml"); + std::fs::rename(&original_name, &tmp_name).map_err(|err| { + anyhow::anyhow!( + "Failed renaming '{:?}' to '{:?}': {:?}", + original_name, + tmp_name, + err + ) + })?; + + let res = build_and_zip_dylint_driver(ink_dylint_driver_dir, out_dir, dylint_driver_dst_file); // After the build process of `ink_linting` happened we need to name back to the original // `_Cargo.toml` name, otherwise the directory would be "dirty" and `cargo publish` would // fail with `Source directory was modified by build.rs during cargo publish`. - std::fs::rename( - ink_dylint_driver_dir.join("Cargo.toml"), - ink_dylint_driver_dir.join("_Cargo.toml"), - )?; + std::fs::rename(&tmp_name, &original_name).map_err(|err| { + anyhow::anyhow!( + "Failed renaming '{:?}' to '{:?}': {:?}", + tmp_name, + original_name, + err + ) + })?; res } -- GitLab From 9ba71aad9a9728116a2a71d2a7b44f347ba35516 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 18 Mar 2022 10:08:30 +0100 Subject: [PATCH 2/6] Bump version to `1.0.1` --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4285af3d..f152bfdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,7 +465,7 @@ dependencies = [ [[package]] name = "cargo-contract" -version = "1.0.0" +version = "1.0.1" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 9d2b7474..130aef98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [".", "metadata"] [package] name = "cargo-contract" -version = "1.0.0" +version = "1.0.1" authors = ["Parity Technologies "] build = "build.rs" edition = "2021" -- GitLab From cdf86058939a5cc6ff14c7e40d223b01eaccd72d Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 18 Mar 2022 10:08:33 +0100 Subject: [PATCH 3/6] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e9f8e64..99d979e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.1] - 2022-03-18 +- Improved error reporting during installation - [#468](https://github.com/paritytech/cargo-contract/pull/468) + ## [1.0.0] - 2022-03-17 ### Changed -- GitLab From f7dcbab28b2d3b3e98705f052eb4afba89ae8a60 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 18 Mar 2022 11:00:39 +0100 Subject: [PATCH 4/6] Canonicalize `ink_dylint_driver_dir` directly --- build.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index c9498c83..e4e83c5a 100644 --- a/build.rs +++ b/build.rs @@ -70,6 +70,14 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf) let dylint_driver_dst_file = out_dir.join("ink-dylint-driver.zip"); let ink_dylint_driver_dir = manifest_dir.join("ink_linting"); + let ink_dylint_driver_dir = ink_dylint_driver_dir.canonicalize().map_err(|err| { + anyhow::anyhow!( + "Unable to canonicalize '{:?}': {:?}\nDoes the folder exist? {}", + ink_dylint_driver_dir, + err, + ink_dylint_driver_dir.exists() + ) + })?; // The `ink_linting/Cargo.toml` file is named `_Cargo.toml` in the repository. // This is because we need to have the `ink_linting` folder part of the release, @@ -86,9 +94,6 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf) // // (from https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields) let original_name = ink_dylint_driver_dir.join("_Cargo.toml"); - let original_name = original_name.canonicalize().map_err(|err| { - anyhow::anyhow!("Unable to canonicalize '{:?}': {:?}", original_name, err) - })?; if !original_name.exists() { anyhow::bail!( "'{:?}' does not exist, does the folder '{:?}'? {:?}", -- GitLab From b7b364c33941ed3f366bdf2a5527353b19e336a3 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 18 Mar 2022 11:24:26 +0100 Subject: [PATCH 5/6] Remove unneeded check for dir existence --- build.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.rs b/build.rs index e4e83c5a..e646e820 100644 --- a/build.rs +++ b/build.rs @@ -96,10 +96,8 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf) let original_name = ink_dylint_driver_dir.join("_Cargo.toml"); if !original_name.exists() { anyhow::bail!( - "'{:?}' does not exist, does the folder '{:?}'? {:?}", + "'{:?}' does not exist", original_name, - ink_dylint_driver_dir, - ink_dylint_driver_dir.exists() ); } -- GitLab From dff930df1c8fbdce24964fb970d00e419b34fc77 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 18 Mar 2022 11:27:10 +0100 Subject: [PATCH 6/6] Apply `cargo fmt` --- build.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build.rs b/build.rs index e646e820..7b5618ed 100644 --- a/build.rs +++ b/build.rs @@ -95,10 +95,7 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf) // (from https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields) let original_name = ink_dylint_driver_dir.join("_Cargo.toml"); if !original_name.exists() { - anyhow::bail!( - "'{:?}' does not exist", - original_name, - ); + anyhow::bail!("'{:?}' does not exist", original_name); } let tmp_name = ink_dylint_driver_dir.join("Cargo.toml"); -- GitLab