Bug 1471486 part 2 - Use RUSTFMT env in stylo build script. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Wed, 27 Jun 2018 15:28:22 +1000
changeset 811190 9e35709e038ccaf47b05ceafed7178934381dd41
parent 811189 f13ce95ff5e65e862f620d6bf69b451248d563ed
push id114223
push userxquan@mozilla.com
push dateWed, 27 Jun 2018 05:28:57 +0000
reviewersemilio
bugs1471486
milestone63.0a1
Bug 1471486 part 2 - Use RUSTFMT env in stylo build script. r?emilio MozReview-Commit-ID: JOg0xkmG5Yx
servo/components/style/build_gecko.rs
--- a/servo/components/style/build_gecko.rs
+++ b/servo/components/style/build_gecko.rs
@@ -177,24 +177,31 @@ mod bindings {
 
     impl BuilderExt for Builder {
         fn get_initial_builder() -> Builder {
             use bindgen::RustTarget;
 
             // Disable rust unions, because we replace some types inside of
             // them.
             let mut builder = Builder::default().rust_target(RustTarget::Stable_1_0);
-            let rustfmt_path = env::var_os("MOZ_AUTOMATION")
-                .and_then(|_| env::var_os("TOOLTOOL_DIR").or_else(|| env::var_os("MOZ_SRC")))
-                .map(PathBuf::from);
 
-            builder = match rustfmt_path {
-                Some(path) => builder.with_rustfmt(path.join("rustc").join("bin").join("rustfmt")),
-                None => builder.rustfmt_bindings(env::var_os("STYLO_RUSTFMT_BINDINGS").is_some()),
-            };
+            let rustfmt_path = env::var_os("RUSTFMT")
+                // This can be replaced with
+                // > .filter(|p| !p.is_empty()).map(PathBuf::from)
+                // once we can use 1.27+.
+                .and_then(|p| {
+                    if p.is_empty() {
+                        None
+                    } else {
+                        Some(PathBuf::from(p))
+                    }
+                });
+            if let Some(path) = rustfmt_path {
+                builder = builder.with_rustfmt(path);
+            }
 
             for dir in SEARCH_PATHS.iter() {
                 builder = builder.clang_arg("-I").clang_arg(dir.to_str().unwrap());
             }
 
             builder = builder.include(add_include("mozilla-config.h"));
 
             if env::var("CARGO_FEATURE_GECKO_DEBUG").is_ok() {