Skip to content

Commit

Permalink
Improve error reporting during installation + Release 1.0.1 (#469)
Browse files Browse the repository at this point in the history
* Improve error output during build script

* Bump version to `1.0.1`

* Update changelog

* Canonicalize `ink_dylint_driver_dir` directly

* Remove unneeded check for dir existence

* Apply `cargo fmt`
  • Loading branch information
cmichi authored Mar 18, 2022
1 parent 82157f4 commit c40da7c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `--skip-linting` flag that allows to skip the linting step during build process - [#468](https://github.com/paritytech/cargo-contract/pull/468)

## [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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [".", "metadata"]

[package]
name = "cargo-contract"
version = "1.0.0"
version = "1.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
edition = "2021"
Expand Down
46 changes: 32 additions & 14 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -85,24 +93,34 @@ 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");
if !original_name.exists() {
anyhow::bail!("'{:?}' does not exist", original_name);
}

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
}
Expand Down

0 comments on commit c40da7c

Please sign in to comment.