Bug 1509848: Allow Baldrdash to be compiled independently from Spidermonkey; r=froydnj
authorBenjamin Bouvier <benj@benj.me>
Mon, 19 Nov 2018 15:27:20 +0100
changeset 507500 9fcec7e5baa7e044e0a403d70ded222dc4d7bb1f
parent 507499 2b4844c3f4d88f746755c49d8d41de016ef8f2cb
child 507501 ecf218f8c16a46fecbcf7e24c2e862b726a0c020
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1509848
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1509848: Allow Baldrdash to be compiled independently from Spidermonkey; r=froydnj This allows tools like the Rust Language Server to still run for Cranelift, allowing IDE integration and useful developer feedback when hacking in this directory.
js/src/wasm/cranelift/build.rs
--- a/js/src/wasm/cranelift/build.rs
+++ b/js/src/wasm/cranelift/build.rs
@@ -45,34 +45,40 @@ fn main() {
         .clang_args(&[
             "-x",
             "c++",
             "-std=gnu++14",
             "-fno-sized-deallocation",
             "-DRUST_BINDGEN",
         ]).clang_arg("-I../..");
 
-    let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap())
-        .join("js/src/rust/extra-bindgen-flags");
+    match env::var_os("MOZ_TOPOBJDIR") {
+        Some(path) => {
+            let path = PathBuf::from(path).join("js/src/rust/extra-bindgen-flags");
 
-    let mut extra_flags = String::new();
-    File::open(&path)
-        .expect("Failed to open extra-bindgen-flags file")
-        .read_to_string(&mut extra_flags)
-        .expect("Failed to read extra-bindgen-flags file");
+            let mut extra_flags = String::new();
+            File::open(&path)
+                .expect("Failed to open extra-bindgen-flags file")
+                .read_to_string(&mut extra_flags)
+                .expect("Failed to read extra-bindgen-flags file");
 
-    let display_path = path.to_str().expect("path is utf8 encoded");
-    println!("cargo:rerun-if-changed={}", display_path);
+            let display_path = path.to_str().expect("path is utf8 encoded");
+            println!("cargo:rerun-if-changed={}", display_path);
 
-    let extra_flags: Vec<String> = extra_flags
-        .split_whitespace()
-        .map(|s| s.to_owned())
-        .collect();
-    for flag in extra_flags {
-        bindings = bindings.clang_arg(flag);
+            let extra_flags: Vec<String> = extra_flags
+                .split_whitespace()
+                .map(|s| s.to_owned())
+                .collect();
+            for flag in extra_flags {
+                bindings = bindings.clang_arg(flag);
+            }
+        }
+        None => {
+            println!("cargo:warning={}", "MOZ_TOPOBJDIR should be set by default, otherwise the build is not guaranted to finish.");
+        }
     }
 
     let bindings = bindings
         .generate()
         .expect("Unable to generate baldrapi.h bindings");
 
     // Write the bindings to the $OUT_DIR/bindings.rs file.
     let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());