mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-09-13 13:55:24 +00:00
build: validate CFG_SRC_URL and simplify CFG_RELEASE handling
This commit is contained in:
parent
fa14844d0d
commit
fac146e859
6 changed files with 32 additions and 12 deletions
20
blahd/build.rs
Normal file
20
blahd/build.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
fn main() {
|
||||
// No rerun on file changes.
|
||||
println!("cargo::rerun-if-changed=build.rs");
|
||||
|
||||
println!("cargo::rerun-if-env-changed=CFG_RELEASE");
|
||||
if std::env::var_os("CFG_RELEASE").is_none() {
|
||||
let vers = std::env::var("CARGO_PKG_VERSION").expect("cargo should set it");
|
||||
println!("cargo::rustc-env=CFG_RELEASE={vers}");
|
||||
}
|
||||
|
||||
println!("cargo::rerun-if-env-changed=CFG_SRC_URL");
|
||||
if let Some(url) = std::env::var_os("CFG_SRC_URL") {
|
||||
url.to_str()
|
||||
.expect("CFG_SRC_URL is not in UTF-8")
|
||||
.parse::<url::Url>()
|
||||
.expect("CFG_SRC_URL is not a valid URL");
|
||||
} else {
|
||||
println!("cargo::warning=CFG_SRC_URL is not set");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue