Skip to content

Commit 5adadd1

Browse files
authored
Merge pull request #17 from tnull/2023-11-genproto-cfg-flag
Make `genproto` a `cfg` flag instead of a feature
2 parents 2b97b10 + d9ac1d3 commit 5adadd1

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ build = "build.rs"
1515
prost = "0.11.6"
1616
reqwest = { version = "0.11.13", features = ["rustls-tls"] }
1717

18-
[build-dependencies]
18+
[target.'cfg(genproto)'.build-dependencies]
1919
prost-build = { version = "0.11.3" }
2020
reqwest = { version = "0.11.13", features = ["blocking"] }
2121

2222
[dev-dependencies]
2323
mockito = "0.31.1"
2424
tokio = { version = "1.22.0", features = ["macros"]}
25-
26-
[features]
27-
genproto = []

build.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
#[cfg(feature = "genproto")]
1+
#[cfg(genproto)]
22
extern crate prost_build;
3-
#[cfg(feature = "genproto")]
3+
#[cfg(genproto)]
44
use std::{env, fs, fs::File, path::Path};
55

66
/// To generate updated proto objects:
77
/// 1. Place `vss.proto` file in `src/proto/`
8-
/// 2. run `cargo build --features=genproto`
8+
/// 2. run `RUSTFLAGS="--cfg genproto" cargo build`
99
fn main() {
10-
#[cfg(feature = "genproto")]
10+
#[cfg(genproto)]
1111
generate_protos();
1212
}
1313

14-
#[cfg(feature = "genproto")]
14+
#[cfg(genproto)]
1515
fn generate_protos() {
1616
download_file(
1717
"https://raw.githubusercontent.com/lightningdevkit/vss-server/cb1159c3b1835c66a857b25b114f15d18d2a4297/app/src/main/proto/vss.proto",
@@ -23,7 +23,7 @@ fn generate_protos() {
2323
fs::copy(from_path, "src/types.rs").unwrap();
2424
}
2525

26-
#[cfg(feature = "genproto")]
26+
#[cfg(genproto)]
2727
fn download_file(url: &str, save_to: &str) -> Result<(), Box<dyn std::error::Error>> {
2828
let mut response = reqwest::blocking::get(url)?;
2929
fs::create_dir_all(Path::new(save_to).parent().unwrap())?;

0 commit comments

Comments
 (0)