@@ -11,7 +11,8 @@ use std::ffi::{OsStr, OsString};
11
11
use std:: process:: { Command , Stdio } ;
12
12
13
13
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" ) {
15
16
// https://github.com/rust-lang/rust/issues/39016
16
17
panic ! ( "Rustc doesn't support MSVC debug runtime." ) ;
17
18
}
@@ -38,22 +39,23 @@ fn cc_flags() -> Vec<&'static str> {
38
39
"-DSTATIC_JS_API" ,
39
40
] ;
40
41
41
- if cfg ! ( feature = "debugmozjs" ) {
42
+ if env :: var_os ( "CARGO_FEATURE_DEBUGMOZJS" ) . is_some ( ) {
42
43
result. extend ( & [
43
44
"-DJS_GC_ZEAL" ,
44
45
"-DDEBUG" ,
45
46
"-DJS_DEBUG" ,
46
47
] ) ;
47
48
}
48
49
49
- if cfg ! ( windows) {
50
+ let target = env:: var ( "TARGET" ) . unwrap ( ) ;
51
+ if target. contains ( "windows" ) {
50
52
result. extend ( & [
51
53
"-std=c++14" ,
52
54
"-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" ,
57
59
] ) ;
58
60
} else {
59
61
result. extend ( & [
@@ -64,6 +66,13 @@ fn cc_flags() -> Vec<&'static str> {
64
66
] ) ;
65
67
}
66
68
69
+ let is_apple = target. contains ( "apple" ) ;
70
+ let is_freebsd = target. contains ( "freebsd" ) ;
71
+
72
+ if is_apple || is_freebsd {
73
+ result. push ( "-stdlib=libc++" ) ;
74
+ }
75
+
67
76
result
68
77
}
69
78
@@ -86,7 +95,7 @@ fn build_jsapi() {
86
95
87
96
// We're using the MSYS make which doesn't work with the mingw32-make-style
88
97
// MAKEFLAGS, so remove that from the env if present.
89
- if cfg ! ( windows) {
98
+ if target . contains ( " windows" ) {
90
99
cmd. env_remove ( "MAKEFLAGS" ) . env_remove ( "MFLAGS" ) ;
91
100
} else if let Some ( makeflags) = env:: var_os ( "CARGO_MAKEFLAGS" ) {
92
101
cmd. env ( "MAKEFLAGS" , makeflags) ;
@@ -133,8 +142,9 @@ fn build_jsglue() {
133
142
build. flag_if_supported ( flag) ;
134
143
}
135
144
145
+ let target = env:: var ( "TARGET" ) . unwrap ( ) ;
136
146
let config = format ! ( "{}/js/src/js-confdefs.h" , out. display( ) ) ;
137
- if cfg ! ( windows) {
147
+ if target . contains ( " windows" ) {
138
148
build. flag ( "-FI" ) ;
139
149
} else {
140
150
build. flag ( "-include" ) ;
@@ -180,7 +190,8 @@ fn build_jsapi_bindings() {
180
190
. clang_arg ( "-I" ) . clang_arg ( out. join ( "js/src" ) . to_str ( ) . expect ( "UTF-8" ) )
181
191
. clang_arg ( "-x" ) . clang_arg ( "c++" ) ;
182
192
183
- if cfg ! ( windows) {
193
+ let target = env:: var ( "TARGET" ) . unwrap ( ) ;
194
+ if target. contains ( "windows" ) {
184
195
builder = builder. clang_arg ( "-fms-compatibility" ) ;
185
196
}
186
197
0 commit comments