Skip to content

Commit

Permalink
refactor: Update cargo_near_build import in files
Browse files Browse the repository at this point in the history
  • Loading branch information
virajbhartiya committed Nov 22, 2024
1 parent a343b68 commit 6be8cde
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions examples/factory-contract/high-level/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ near-sdk = { path = "../../../near-sdk" }

[dev-dependencies]
near-sdk = { path = "../../../near-sdk", features = ["unit-testing"] }

[build-dependencies]
near-workspaces = { version = "0.15", features = ["unstable"] }
11 changes: 5 additions & 6 deletions examples/factory-contract/high-level/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::str::FromStr;

use near_workspaces::cargo_near_build;

fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
Expand All @@ -9,18 +8,18 @@ fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
let nep330_contract_path = "examples/status-message";

let manifest =
camino::Utf8PathBuf::from_str(workdir).expect("pathbuf from str").join("Cargo.toml");
cargo_near_build::camino::Utf8PathBuf::from_str(workdir).expect("pathbuf from str").join("Cargo.toml");

let build_opts = BuildOpts::builder()
let build_opts = cargo_near_build::BuildOpts::builder()
.manifest_path(manifest)
.no_locked(true)
.override_nep330_contract_path(nep330_contract_path)
// a distinct target is needed to avoid deadlock during build
.override_cargo_target_dir("../target/build-rs-status-message-for-high-level-factory")
.build();

let build_script_opts = extended::BuildScriptOpts::builder()
.rerun_if_changed_list(bon::vec![workdir, "Cargo.toml", "../Cargo.lock"])
let build_script_opts = cargo_near_build::extended::BuildScriptOpts::builder()
.rerun_if_changed_list(vec![workdir, "Cargo.toml", "../Cargo.lock"])
.build_skipped_when_env_is(vec![
// shorter build for `cargo check`
("PROFILE", "debug"),
Expand All @@ -30,7 +29,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
.result_env_key("BUILD_RS_SUB_BUILD_STATUS-MESSAGE")
.build();

let extended_opts = extended::BuildOptsExtended::builder()
let extended_opts = cargo_near_build::extended::BuildOptsExtended::builder()
.build_opts(build_opts)
.build_script_opts(build_script_opts)
.build();
Expand Down
3 changes: 3 additions & 0 deletions examples/factory-contract/low-level/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ near-sdk = { path = "../../../near-sdk" }

[dev-dependencies]
near-sdk = { path = "../../../near-sdk", features = ["unit-testing"] }

[build-dependencies]
near-workspaces = { version = "0.15", features = ["unstable"] }
11 changes: 5 additions & 6 deletions examples/factory-contract/low-level/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use near_workspaces::cargo_near_build::*;
use std::str::FromStr;

use near_workspaces::cargo_near_build;

fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
// directory of target `status-message` sub-contract's crate
let workdir = "../../status-message";
Expand All @@ -11,16 +10,16 @@ fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
let manifest =
camino::Utf8PathBuf::from_str(workdir).expect("pathbuf from str").join("Cargo.toml");

let build_opts = BuildOpts::builder()
let build_opts = cargo_near_build::BuildOpts::builder()
.manifest_path(manifest)
.no_locked(true)
.override_nep330_contract_path(nep330_contract_path)
// a distinct target is needed to avoid deadlock during build
.override_cargo_target_dir("../target/build-rs-status-message-for-low-level-factory")
.build();

let build_script_opts = extended::BuildScriptOpts::builder()
.rerun_if_changed_list(bon::vec![workdir, "Cargo.toml", "../Cargo.lock"])
let build_script_opts = cargo_near_build::extended::BuildScriptOpts::builder()
.rerun_if_changed_list(vec![workdir, "Cargo.toml", "../Cargo.lock"])
.build_skipped_when_env_is(vec![
// shorter build for `cargo check`
("PROFILE", "debug"),
Expand All @@ -30,7 +29,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
.result_env_key("BUILD_RS_SUB_BUILD_STATUS-MESSAGE")
.build();

let extended_opts = extended::BuildOptsExtended::builder()
let extended_opts = cargo_near_build::extended::BuildOptsExtended::builder()
.build_opts(build_opts)
.build_script_opts(build_script_opts)
.build();
Expand Down

0 comments on commit 6be8cde

Please sign in to comment.