@@ -50,10 +50,14 @@ fn cc_flags() -> Vec<&'static str> {
50
50
result. extend ( & [
51
51
"-std=c++14" ,
52
52
"-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" ,
53
57
] ) ;
54
58
} else {
55
59
result. extend ( & [
56
- "-std=gnu++11 " ,
60
+ "-std=gnu++14 " ,
57
61
"-fno-sized-deallocation" ,
58
62
"-Wno-unused-parameter" ,
59
63
"-Wno-invalid-offsetof" ,
@@ -95,11 +99,18 @@ fn build_jsapi() {
95
99
. expect ( "Failed to run `make`" ) ;
96
100
97
101
assert ! ( result. success( ) ) ;
98
- println ! ( "cargo:rustc-link-search=native={}/js/src" , out_dir) ;
102
+ println ! ( "cargo:rustc-link-search=native={}/js/src/build " , out_dir) ;
99
103
println ! ( "cargo:rustc-link-lib=static=js_static" ) ; // Must come before c++
104
+ println ! ( "cargo:rustc-link-search=native={}/mozglue/build" , out_dir) ;
105
+ println ! ( "cargo:rustc-link-lib=static=mozglue" ) ;
100
106
if target. contains ( "windows" ) {
107
+ println ! ( "cargo:rustc-link-search=native={}/dist/bin" , out_dir) ;
101
108
println ! ( "cargo:rustc-link-lib=winmm" ) ;
102
109
println ! ( "cargo:rustc-link-lib=psapi" ) ;
110
+ println ! ( "cargo:rustc-link-lib=user32" ) ;
111
+ println ! ( "cargo:rustc-link-lib=Dbghelp" ) ;
112
+ println ! ( "cargo:rustc-link-search=native={}/config/external/nspr/pr" , out_dir) ;
113
+ println ! ( "cargo:rustc-link-lib=nspr4" ) ;
103
114
if target. contains ( "gnu" ) {
104
115
println ! ( "cargo:rustc-link-lib=stdc++" ) ;
105
116
}
@@ -114,7 +125,7 @@ fn build_jsapi() {
114
125
115
126
fn build_jsglue ( ) {
116
127
let out = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
117
-
128
+
118
129
let mut build = cc:: Build :: new ( ) ;
119
130
build. cpp ( true ) ;
120
131
@@ -132,6 +143,8 @@ fn build_jsglue() {
132
143
133
144
build. file ( "src/jsglue.cpp" ) ;
134
145
build. include ( out. join ( "dist/include" ) ) ;
146
+ build. include ( out. join ( "js/src" ) ) ;
147
+
135
148
build. compile ( "jsglue" ) ;
136
149
}
137
150
@@ -142,6 +155,7 @@ fn build_jsglue() {
142
155
/// generated, see the `const` configuration variables below.
143
156
fn build_jsapi_bindings ( ) {
144
157
let out = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
158
+ let rustfmt_config = Some ( PathBuf :: from ( "rustfmt.toml" ) ) ;
145
159
146
160
// By default, constructors, destructors and methods declared in .h files are inlined,
147
161
// so their symbols aren't available. Adding the -fkeep-inlined-functions option
@@ -160,7 +174,10 @@ fn build_jsapi_bindings() {
160
174
. rustified_enum ( ".*" )
161
175
. enable_cxx_namespaces ( )
162
176
. with_codegen_config ( config)
177
+ . rustfmt_bindings ( true )
178
+ . rustfmt_configuration_file ( rustfmt_config)
163
179
. clang_arg ( "-I" ) . clang_arg ( out. join ( "dist/include" ) . to_str ( ) . expect ( "UTF-8" ) )
180
+ . clang_arg ( "-I" ) . clang_arg ( out. join ( "js/src" ) . to_str ( ) . expect ( "UTF-8" ) )
164
181
. clang_arg ( "-x" ) . clang_arg ( "c++" ) ;
165
182
166
183
if cfg ! ( windows) {
@@ -175,14 +192,20 @@ fn build_jsapi_bindings() {
175
192
}
176
193
}
177
194
195
+ if let Ok ( flags) = env:: var ( "CLANGFLAGS" ) {
196
+ for flag in flags. split_whitespace ( ) {
197
+ builder = builder. clang_arg ( flag) ;
198
+ }
199
+ }
200
+
178
201
for flag in cc_flags ( ) {
179
202
builder = builder. clang_arg ( flag) ;
180
203
}
181
204
182
205
builder = builder. clang_arg ( "-include" ) ;
183
206
builder = builder. clang_arg ( out. join ( "js/src/js-confdefs.h" ) . to_str ( ) . expect ( "UTF-8" ) ) ;
184
207
185
- println ! ( "Generting bindings {:?}." , builder. command_line_flags( ) ) ;
208
+ println ! ( "Generting bindings {:?} {} ." , builder. command_line_flags( ) , bindgen :: clang_version ( ) . full ) ;
186
209
187
210
for ty in UNSAFE_IMPL_SYNC_TYPES {
188
211
builder = builder. raw_line ( format ! ( "unsafe impl Sync for root::{} {{}}" , ty) ) ;
@@ -218,7 +241,9 @@ fn build_jsapi_bindings() {
218
241
bindings. write_to_file ( out. join ( "jsapi.rs" ) )
219
242
. expect ( "Should write bindings to file OK" ) ;
220
243
244
+ println ! ( "cargo:rerun-if-changed=rustfmt.toml" ) ;
221
245
println ! ( "cargo:rerun-if-changed=src/jsglue.hpp" ) ;
246
+ println ! ( "cargo:rerun-if-changed=src/jsglue.cpp" ) ;
222
247
}
223
248
224
249
/// JSAPI types for which we should implement `Sync`.
@@ -270,6 +295,7 @@ const WHITELIST_FUNCTIONS: &'static [&'static str] = &[
270
295
const OPAQUE_TYPES : & ' static [ & ' static str ] = & [
271
296
"JS::Auto.*Impl" ,
272
297
"JS::Auto.*Vector.*" ,
298
+ "JS::PersistentRooted.*" ,
273
299
"JS::ReadOnlyCompileOptions" ,
274
300
"JS::Rooted<JS::Auto.*Vector.*>" ,
275
301
"JS::detail::CallArgsBase.*" ,
@@ -279,6 +305,7 @@ const OPAQUE_TYPES: &'static [&'static str] = &[
279
305
"mozilla::BufferList" ,
280
306
"mozilla::Maybe.*" ,
281
307
"mozilla::UniquePtr.*" ,
308
+ "mozilla::Variant" ,
282
309
] ;
283
310
284
311
/// Types for which we should NEVER generate bindings, even if it is used within
@@ -289,6 +316,9 @@ const BLACKLIST_TYPES: &'static [&'static str] = &[
289
316
// We provide our own definition because we need to express trait bounds in
290
317
// the definition of the struct to make our Drop implementation correct.
291
318
"JS::Heap" ,
319
+ // We provide our own definition because SM's use of templates
320
+ // is more than bindgen can cope with.
321
+ "JS::Rooted" ,
292
322
// Bindgen generates bitfields with private fields, so they cannot
293
323
// be used in const expressions.
294
324
"JSJitInfo" ,
@@ -299,5 +329,6 @@ const MODULE_RAW_LINES: &'static [(&'static str, &'static str)] = &[
299
329
( "root" , "pub type FILE = ::libc::FILE;" ) ,
300
330
( "root" , "pub type JSJitInfo = ::jsjit::JSJitInfo;" ) ,
301
331
( "root::JS" , "pub type Heap<T> = ::jsgc::Heap<T>;" ) ,
332
+ ( "root::JS" , "pub type Rooted<T> = ::jsgc::Rooted<T>;" ) ,
302
333
( "root::JS" , "pub type AutoGCRooterTag = AutoGCRooter__bindgen_ty_1;" ) ,
303
334
] ;
0 commit comments