This repository has been archived by the owner on Nov 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
/
build.rs
58 lines (49 loc) · 1.81 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
extern crate cc;
use std::env;
use std::path::PathBuf;
fn main() {
let mut build = cc::Build::new();
let outdir = env::var("DEP_MOZJS_OUTDIR").unwrap();
let include_path: PathBuf = [&outdir, "dist", "include"].iter().collect();
build
.cpp(true)
.file("src/jsglue.cpp")
.flag("-DSTATIC_JS_API")
.include(include_path);
if env::var("CARGO_FEATURE_DEBUGMOZJS").is_ok() {
build.define("DEBUG", "");
if cfg!(target_os = "windows") {
build.flag("-Od");
} else {
build.flag("-g");
build.flag("-O0");
}
}
if env::var("CARGO_FEATURE_PROFILEMOZJS").is_ok() {
build.flag_if_supported("-fno-omit-frame-pointer");
}
build.flag_if_supported("-Wno-c++0x-extensions");
build.flag_if_supported("-Wno-return-type-c-linkage");
build.flag_if_supported("-Wno-invalid-offsetof");
build.flag_if_supported("-Wno-unused-parameter");
let confdefs_path: PathBuf = [&outdir, "js", "src", "js-confdefs.h"].iter().collect();
if build.get_compiler().is_like_msvc() {
build.flag(&format!("-FI{}", confdefs_path.to_string_lossy()));
build.define("WIN32", "");
build.flag("-Zi");
build.flag("-GR-");
build.flag("-std:c++17");
} else {
build.flag("-fPIC");
build.flag("-fno-rtti");
build.flag("-std=c++17");
build.define("JS_NO_JSVAL_JSID_STRUCT_TYPES", "");
build.flag("-include");
build.flag(&confdefs_path.to_string_lossy());
}
build.compile("jsglue");
println!("cargo:rerun-if-changed=src/jsglue.cpp");
}