Skip to content
Permalink
Browse files

Fix error message for invalid combination of style crate feature flags

Instead of ``cannot find value `engine` in this scope``
#24284
  • Loading branch information...
SimonSapin committed Sep 25, 2019
1 parent a1c911f commit 36e53a39bfba3e362ace336db0af6584a3d7c20f
Showing with 15 additions and 23 deletions.
  1. +15 −23 components/style/build.rs
@@ -75,7 +75,7 @@ lazy_static! {
pub static ref PYTHON: String = env::var("PYTHON").ok().unwrap_or_else(find_python);
}

fn generate_properties() {
fn generate_properties(engine: &str) {
for entry in WalkDir::new("properties") {
let entry = entry.unwrap();
match entry.path().extension().and_then(|e| e.to_str()) {
@@ -90,15 +90,6 @@ fn generate_properties() {
.join("properties")
.join("build.py");

#[cfg(feature = "gecko")]
let engine = "gecko";

#[cfg(feature = "servo-layout-2013")]
let engine = "servo-2013";

#[cfg(feature = "servo-layout-2020")]
let engine = "servo-2020";

let status = Command::new(&*PYTHON)
.arg(&script)
.arg(engine)
@@ -113,20 +104,21 @@ fn generate_properties() {
fn main() {
let gecko = cfg!(feature = "gecko");
let servo = cfg!(feature = "servo");
if !(gecko || servo) {
panic!("The style crate requires enabling one of its 'servo' or 'gecko' feature flags");
}
if gecko && servo {
panic!(
"The style crate does not support enabling both its 'servo' or 'gecko' \
feature flags at the same time."
);
}
if gecko && (cfg!(feature = "servo-layout-2013") || cfg!(feature = "servo-layout-2020")) {
panic!("The 'servo-layout-*' features can only be enabled together with 'servo'.");
}
let l2013 = cfg!(feature = "servo-layout-2013");
let l2020 = cfg!(feature = "servo-layout-2020");
let engine = match (gecko, servo, l2013, l2020) {
(true, false, false, false) => "gecko",
(false, true, true, false) => "servo-2013",
(false, true, false, true) => "servo-2020",
_ => panic!(
"\n\n\
The style crate requires enabling one of its 'servo' or 'gecko' feature flags \
and, in the 'servo' case, one of 'servo-layout-2013' or 'servo-layout-2020'.\
\n\n"
),
};
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:out_dir={}", env::var("OUT_DIR").unwrap());
generate_properties();
generate_properties(engine);
build_gecko::generate();
}

0 comments on commit 36e53a3

Please sign in to comment.
You can’t perform that action at this time.