mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Set the cfg properly for the production-stripped profile (#32991)
Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
a1d3649f7c
commit
2ebb71f08a
3 changed files with 21 additions and 4 deletions
|
@ -49,6 +49,9 @@ webrender_api = { workspace = true }
|
|||
webrender_traits = { workspace = true }
|
||||
xi-unicode = { workspace = true }
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ohos_mock)'] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
byteorder = { workspace = true }
|
||||
core-foundation = "0.9"
|
||||
|
|
|
@ -6,14 +6,21 @@ 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();
|
||||
if profile.file_name().unwrap() == "production" {
|
||||
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");
|
||||
|
|
|
@ -21,14 +21,21 @@ fn generate_egl_bindings(out_dir: &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();
|
||||
if profile.file_name().unwrap() == "production" {
|
||||
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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue