Skip to content

Commit aa3981c

Browse files
chore: use build-rs in build scripts (#1716)
1 parent 218848c commit aa3981c

File tree

16 files changed

+51
-47
lines changed

16 files changed

+51
-47
lines changed

Cargo.lock

Lines changed: 17 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ miden-crypto = { default-features = false, version = "0.19" }
7777
anyhow = { version = "1.0" }
7878
assert_matches = { version = "1.5" }
7979
async-trait = { version = "0.1" }
80+
build-rs = { version = "0.3" }
8081
clap = { features = ["derive"], version = "4.5" }
8182
deadpool = { default-features = false, version = "0.12" }
8283
deadpool-diesel = { version = "0.6" }

bin/remote-prover/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ miden-testing = { workspace = true }
4747
miden-tx = { features = ["testing"], workspace = true }
4848

4949
[build-dependencies]
50+
build-rs = { workspace = true }
5051
fs-err = { workspace = true }
5152
miden-node-proto-build = { features = ["internal"], workspace = true }
5253
miden-node-rocksdb-cxx-linkage-fix = { workspace = true }

bin/remote-prover/build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::path::{Path, PathBuf};
1+
use std::path::Path;
22

33
use fs_err as fs;
44
use miden_node_proto_build::remote_prover_api_descriptor;
@@ -9,8 +9,7 @@ use tonic_prost_build::FileDescriptorSet;
99
fn main() -> miette::Result<()> {
1010
miden_node_rocksdb_cxx_linkage_fix::configure();
1111

12-
let dst_dir =
13-
PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR should be set")).join("generated");
12+
let dst_dir = build_rs::input::out_dir().join("generated");
1413

1514
// Remove all existing files.
1615
let _ = fs::remove_dir_all(&dst_dir);

crates/ntx-builder/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ tonic = { workspace = true }
3434
tracing = { workspace = true }
3535
url = { workspace = true }
3636

37+
[build-dependencies]
38+
build-rs = { workspace = true }
39+
3740
[dev-dependencies]
3841
miden-node-test-macro = { path = "../test-macro" }
3942
miden-node-utils = { features = ["testing"], workspace = true }

crates/ntx-builder/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// <https://docs.rs/diesel_migrations/latest/diesel_migrations/macro.embed_migrations.html#automatic-rebuilds>.
44

55
fn main() {
6-
println!("cargo:rerun-if-changed=./src/db/migrations");
6+
build_rs::output::rerun_if_changed("src/db/migrations");
77
// If we do one re-write, the default rules are disabled,
88
// hence we need to trigger explicitly on `Cargo.toml`.
99
// <https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed>
10-
println!("cargo:rerun-if-changed=Cargo.toml");
10+
build_rs::output::rerun_if_changed("Cargo.toml");
1111
}

crates/proto/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ assert_matches = { workspace = true }
3333
proptest = { version = "1.7" }
3434

3535
[build-dependencies]
36+
build-rs = { workspace = true }
3637
fs-err = { workspace = true }
3738
miden-node-proto-build = { features = ["internal"], workspace = true }
3839
miden-node-rocksdb-cxx-linkage-fix = { workspace = true }

crates/proto/build.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use std::env;
2-
use std::path::{Path, PathBuf};
1+
use std::path::Path;
32

43
use fs_err as fs;
54
use miden_node_proto_build::{
@@ -16,12 +15,9 @@ use tonic_prost_build::FileDescriptorSet;
1615

1716
/// Generates Rust protobuf bindings using `miden-node-proto-build`.
1817
fn main() -> miette::Result<()> {
19-
println!("cargo::rerun-if-changed=../../proto/proto");
20-
2118
miden_node_rocksdb_cxx_linkage_fix::configure();
2219

23-
let dst_dir =
24-
PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR should be set")).join("generated");
20+
let dst_dir = build_rs::input::out_dir().join("generated");
2521

2622
// Remove all existing files.
2723
let _ = fs::remove_dir_all(&dst_dir);

crates/remote-prover-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ tokio = { default-features = false, features = ["sync"], optional = tru
4141
tonic-prost = { workspace = true }
4242

4343
[build-dependencies]
44+
build-rs = { workspace = true }
4445
fs-err = { workspace = true }
4546
miden-node-proto-build = { workspace = true }
4647
miette = { features = ["fancy"], version = "7.5" }

crates/remote-prover-client/build.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::io::Write;
2-
use std::path::{Path, PathBuf};
2+
use std::path::Path;
33

44
use fs_err as fs;
55
use miden_node_proto_build::remote_prover_api_descriptor;
@@ -8,9 +8,7 @@ use tonic_prost_build::FileDescriptorSet;
88

99
/// Generates Rust protobuf bindings.
1010
fn main() -> miette::Result<()> {
11-
let dst_dir =
12-
PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR is always set for build.rs"))
13-
.join("generated");
11+
let dst_dir = build_rs::input::out_dir().join("generated");
1412

1513
// Remove all existing files.
1614
let _ = fs::remove_dir_all(&dst_dir);

0 commit comments

Comments
 (0)