Skip to content

Commit f0b7ad1

Browse files
committed
Stop using cfg!(windows) and remove some tabs
1 parent 9b44b1e commit f0b7ad1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

build.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use std::ffi::{OsStr, OsString};
1111
use std::process::{Command, Stdio};
1212

1313
fn main() {
14-
if cfg!(feature = "debugmozjs") && cfg!(windows) {
14+
let target = env::var("TARGET").unwrap();
15+
if env::var_os("CARGO_FEATURE_DEBUGMOZJS").is_some() && target.contains("windows") {
1516
// https://github.com/rust-lang/rust/issues/39016
1617
panic!("Rustc doesn't support MSVC debug runtime.");
1718
}
@@ -38,22 +39,23 @@ fn cc_flags() -> Vec<&'static str> {
3839
"-DSTATIC_JS_API",
3940
];
4041

41-
if cfg!(feature = "debugmozjs") {
42+
if env::var_os("CARGO_FEATURE_DEBUGMOZJS").is_some() {
4243
result.extend(&[
4344
"-DJS_GC_ZEAL",
4445
"-DDEBUG",
4546
"-DJS_DEBUG",
4647
]);
4748
}
4849

49-
if cfg!(windows) {
50+
let target = env::var("TARGET").unwrap();
51+
if target.contains("windows") {
5052
result.extend(&[
5153
"-std=c++14",
5254
"-DWIN32",
53-
// Don't use reinterpret_cast() in offsetof(),
54-
// since it's not a constant expression, so can't
55-
// be used in static_assert().
56-
"-D_CRT_USE_BUILTIN_OFFSETOF",
55+
// Don't use reinterpret_cast() in offsetof(),
56+
// since it's not a constant expression, so can't
57+
// be used in static_assert().
58+
"-D_CRT_USE_BUILTIN_OFFSETOF",
5759
]);
5860
} else {
5961
result.extend(&[
@@ -86,7 +88,7 @@ fn build_jsapi() {
8688

8789
// We're using the MSYS make which doesn't work with the mingw32-make-style
8890
// MAKEFLAGS, so remove that from the env if present.
89-
if cfg!(windows) {
91+
if target.contains("windows") {
9092
cmd.env_remove("MAKEFLAGS").env_remove("MFLAGS");
9193
} else if let Some(makeflags) = env::var_os("CARGO_MAKEFLAGS") {
9294
cmd.env("MAKEFLAGS", makeflags);
@@ -133,8 +135,9 @@ fn build_jsglue() {
133135
build.flag_if_supported(flag);
134136
}
135137

138+
let target = env::var("TARGET").unwrap();
136139
let config = format!("{}/js/src/js-confdefs.h", out.display());
137-
if cfg!(windows) {
140+
if target.contains("windows") {
138141
build.flag("-FI");
139142
} else {
140143
build.flag("-include");
@@ -180,7 +183,8 @@ fn build_jsapi_bindings() {
180183
.clang_arg("-I").clang_arg(out.join("js/src").to_str().expect("UTF-8"))
181184
.clang_arg("-x").clang_arg("c++");
182185

183-
if cfg!(windows) {
186+
let target = env::var("TARGET").unwrap();
187+
if target.contains("windows") {
184188
builder = builder.clang_arg("-fms-compatibility");
185189
}
186190

0 commit comments

Comments
 (0)