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 std::env;
6 use std::path::PathBuf;
7 
main()8 fn main() {
9     let dist_path = {
10         let path = PathBuf::from(env::var_os("MOZ_DIST").unwrap());
11         if !path.is_absolute() || !path.is_dir() {
12             panic!(
13                 "MOZ_DIST must be an absolute directory, was: {}",
14                 path.display()
15             );
16         }
17         path
18     };
19     let topobjdir = {
20         let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap());
21         if !path.is_absolute() || !path.is_dir() {
22             panic!(
23                 "MOZ_TOPOBJDIR must be an absolute directory, was: {}",
24                 path.display()
25             );
26         }
27         path
28     };
29     let mut build = cc::Build::new();
30     build.cpp(true);
31     // For js-confdefs.h, see wrappers.cpp.
32     build.include(topobjdir.join("js").join("src"));
33     build.include(dist_path.join("include"));
34     build.define("MOZ_HAS_MOZGLUE", None);
35     build.file("wrappers.cpp");
36     build.compile("wrappers");
37     println!("cargo:rerun-if-changed=wrappers.cpp");
38 }
39