mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
30 lines
1.1 KiB
Rust
30 lines
1.1 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use std::error::Error;
|
|
use std::path::Path;
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
println!("cargo::rustc-check-cfg=cfg(servo_production)");
|
|
println!("cargo::rustc-check-cfg=cfg(servo_do_not_use_in_production)");
|
|
// Cargo does not expose the profile name to crates or their build scripts,
|
|
// but we can extract it from OUT_DIR and set a custom cfg() ourselves.
|
|
let out = std::env::var("OUT_DIR")?;
|
|
let out = Path::new(&out);
|
|
let krate = out.parent().unwrap();
|
|
let build = krate.parent().unwrap();
|
|
let profile = build
|
|
.parent()
|
|
.unwrap()
|
|
.file_name()
|
|
.unwrap()
|
|
.to_string_lossy();
|
|
if profile == "production" || profile.starts_with("production-") {
|
|
println!("cargo:rustc-cfg=servo_production");
|
|
} else {
|
|
println!("cargo:rustc-cfg=servo_do_not_use_in_production");
|
|
}
|
|
|
|
Ok(())
|
|
}
|