build.rs (1701B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 use rustc_version::{version, version_meta, Channel, Version}; 6 7 fn main() { 8 let mut build = cc::Build::new(); 9 build.cpp(true); 10 // For js-confdefs.h, see wrappers.cpp. 11 build.include(mozbuild::TOPOBJDIR.join("js").join("src")); 12 build.include(mozbuild::TOPOBJDIR.join("dist").join("include")); 13 build.define("MOZ_HAS_MOZGLUE", None); 14 build.file("wrappers.cpp"); 15 build.compile("wrappers"); 16 println!("cargo:rerun-if-changed=wrappers.cpp"); 17 18 let ver = version().unwrap(); 19 let max_oom_hook_version = Version::parse("1.92.0-alpha").unwrap(); 20 // The new alloc error panic feature was temporarily reverted. We kept the 21 // code in tree, but the version here is such that it's effectively never used. 22 let max_alloc_error_panic_version = Version::parse("1.92.0-alpha").unwrap(); 23 24 println!("cargo::rustc-check-cfg=cfg(has_panic_hook_info)"); 25 println!("cargo::rustc-check-cfg=cfg(oom_with, values(\"hook\", \"alloc_error_panic\"))"); 26 if ver < max_oom_hook_version { 27 println!("cargo:rustc-cfg=oom_with=\"hook\""); 28 } else if ver < max_alloc_error_panic_version { 29 println!("cargo:rustc-cfg=oom_with=\"alloc_error_panic\""); 30 } else if std::env::var("MOZ_AUTOMATION").is_ok() 31 && version_meta().unwrap().channel != Channel::Nightly 32 { 33 panic!("Builds on automation must use a version of rust for which we know how to hook OOM: want < {}, have {}", 34 max_alloc_error_panic_version, ver); 35 } 36 }