Skip to content

Commit

Permalink
fix: Addressed warnings in cargo build -p cargo-near-build cmd in r…
Browse files Browse the repository at this point in the history
…eleaze-plz flow (#212)
  • Loading branch information
dj8yfo authored Sep 2, 2024
1 parent b6aa11b commit 17e3dd3
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 21 deletions.
6 changes: 4 additions & 2 deletions cargo-near-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
name = "cargo-near-build"
edition = "2021"
version = "0.1.0"
description = "Library for building Rust smart contracts on NEAR, basis of `cargo-near` crate/CLI"
repository = "https://github.com/near/cargo-near"
license = "MIT OR Apache-2.0"

[dependencies]
eyre = "0.6.12"
Expand Down Expand Up @@ -38,9 +41,8 @@ targets = ["x86_64-unknown-linux-gnu"]
[features]
default = []
build_script = []
cli_exports = []
abi_build = []
docker = [
"cli_exports",
"dep:url", "dep:serde", "dep:git2",
"dep:home", "dep:pathdiff", "dep:unix_path",
"dep:tempfile", "dep:nix"
Expand Down
1 change: 1 addition & 0 deletions cargo-near-build/src/env_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod nep330 {
/// NEP-330 1.1.0
pub const VERSION: &str = "NEP330_VERSION";
// ====================== End section =======================================
#[cfg(feature = "docker")]
pub(crate) mod nonspec {
pub const SERVER_DISABLE_INTERACTIVE: &str = "CARGO_NEAR_SERVER_BUILD_DISABLE_INTERACTIVE";
}
Expand Down
9 changes: 4 additions & 5 deletions cargo-near-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
//!
//! * **build_script** -
//! Adds [extended] module for use in build scripts
//! * **cli_exports** -
//! Additional exports, needed from lib in context of cli tool
//! * **abi_build** -
//! Additional functionality, needed for build of ABI separately
//! * **docker** -
//! Adds `docker` module for functionality of
//! building in docker with WASM reproducibility.
//! This feature implies **cli_exports** feature.
//!
//! ### Default features
//!
Expand Down Expand Up @@ -44,15 +43,15 @@ pub(crate) mod near;
pub(crate) mod pretty_print;
pub(crate) mod types;

#[cfg(feature = "cli_exports")]
#[cfg(feature = "abi_build")]
pub mod abi {
pub use crate::near::abi::build;
pub use crate::types::near::abi::Opts as AbiOpts;
}

mod build_exports {
pub use crate::near::build::run as build;
#[cfg(feature = "cli_exports")]
#[cfg(feature = "docker")]
pub use crate::types::near::build::input::BuildContext;
pub use crate::types::near::build::input::Opts as BuildOpts;
pub use crate::types::near::build::input::{CliDescription, ColorPreference};
Expand Down
22 changes: 11 additions & 11 deletions cargo-near-build/src/near/abi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use camino::Utf8PathBuf;
use colored::Colorize;
use crate::types::cargo::metadata::CrateMetadata;
use crate::types::near::abi as abi_types;

use crate::{
pretty_print,
types::{
cargo::{manifest_path::ManifestPath, metadata::CrateMetadata},
near::abi as abi_types,
},
};

use crate::types::near::build::input::ColorPreference;
pub mod generate;

#[cfg(feature = "abi_build")]
pub fn build(args: abi_types::Opts) -> eyre::Result<()> {
// imports #[cfg(feature = "abi_build")]
use crate::{
pretty_print,
types::{cargo::manifest_path::ManifestPath, near::build::input::ColorPreference},
};
use camino::Utf8PathBuf;
use colored::Colorize;

let color = args.color.unwrap_or(ColorPreference::Auto);
color.apply();

Expand Down
2 changes: 2 additions & 0 deletions cargo-near-build/src/types/near/abi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use camino::Utf8PathBuf;

#[cfg(feature = "abi_build")]
use crate::types::near::build::input::ColorPreference;

#[cfg(feature = "abi_build")]
#[derive(Default)]
pub struct Opts {
/// disable implicit `--locked` flag for all `cargo` commands, enabled by default
Expand Down
1 change: 1 addition & 0 deletions cargo-near-build/src/types/near/build/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::io::IsTerminal;
#[cfg(feature = "docker")]
mod docker_context;

#[cfg(feature = "docker")]
#[derive(Debug, Clone, Copy)]
pub enum BuildContext {
Build,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use crate::env_keys;
pub type Version = String;

#[derive(Debug)]
pub enum VersionMismatch {
pub(crate) enum VersionMismatch {
Some {
environment: Version,
current_process: Version,
},
None,
#[cfg(feature = "docker")]
UnknownFromDocker,
}

Expand All @@ -26,6 +27,7 @@ impl std::fmt::Display for VersionMismatch {
)
}
Self::None => write!(f, "no `cargo-near` version mismatch in nested builds detected",),
#[cfg(feature = "docker")]
Self::UnknownFromDocker => write!(f, "it's unknown if `cargo-near` version mismatch has occurred in docker build environment",),
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-near/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ license = false
eula = false

[dependencies]
cargo-near-build = { version = "0.1.0", path = "../cargo-near-build", features = ["docker"] }
cargo-near-build = { version = "0.1.0", path = "../cargo-near-build", features = ["abi_build", "docker"] }
clap = { version = "4.0.18", features = ["derive", "env"] }
colored = "2.0"
env_logger = "0.11.5"
Expand Down
6 changes: 5 additions & 1 deletion release-plz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ changelog_update = false
name = "cargo-near"
changelog_update = true
changelog_path = "./CHANGELOG.md"
changelog_include = ["cargo-near-build"]

[[package]]
name = "cargo-near-build"
changelog_update = true
changelog_path = "./cargo-near-build/CHANGELOG.md"

0 comments on commit 17e3dd3

Please sign in to comment.