diff options
author | webbeef <me@webbeef.org> | 2024-08-09 02:16:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-09 09:16:51 +0000 |
commit | 2ebb71f08a9e2521a2fd277c2bc2b54b9e21dd8d (patch) | |
tree | d41d0b8ca2d546ecfd3301d639bdec57f0663b13 | |
parent | a1d3649f7c282aec9220ab67b203297fe33e5a07 (diff) | |
download | servo-2ebb71f08a9e2521a2fd277c2bc2b54b9e21dd8d.tar.gz servo-2ebb71f08a9e2521a2fd277c2bc2b54b9e21dd8d.zip |
Set the cfg properly for the production-stripped profile (#32991)
Signed-off-by: webbeef <me@webbeef.org>
-rw-r--r-- | components/fonts/Cargo.toml | 3 | ||||
-rw-r--r-- | components/shared/embedder/build.rs | 11 | ||||
-rw-r--r-- | ports/servoshell/build.rs | 11 |
3 files changed, 21 insertions, 4 deletions
diff --git a/components/fonts/Cargo.toml b/components/fonts/Cargo.toml index a0301ceaad8..120e16037f4 100644 --- a/components/fonts/Cargo.toml +++ b/components/fonts/Cargo.toml @@ -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" diff --git a/components/shared/embedder/build.rs b/components/shared/embedder/build.rs index 25c737ffaa9..06e47f2099b 100644 --- a/components/shared/embedder/build.rs +++ b/components/shared/embedder/build.rs @@ -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"); diff --git a/ports/servoshell/build.rs b/ports/servoshell/build.rs index c593c3f8a88..2bce85cdefb 100644 --- a/ports/servoshell/build.rs +++ b/ports/servoshell/build.rs @@ -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"); |