Skip to content

Commit 8315646

Browse files
author
bors-servo
authored
Auto merge of #1073 - liranringel:linux-default-target, r=pepyakin
Make the default target for expectation files as x86_64-unknown-linux Solves #1067 I didn't check it on macos because I don't have one, but it will be a surprise if it doesn't work.
2 parents bd5f928 + f74a52c commit 8315646

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

tests/headers/call-conv-field.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// bindgen-flags: -- -target i686-pc-win32
1+
// bindgen-flags: -- --target=i686-pc-win32
22
// bindgen-unstable
33
// bindgen-generate-bindings-on-linux-only
44
//

tests/tests.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,13 @@ fn create_bindgen_builder(header: &PathBuf) -> Result<Option<Builder>, Error> {
235235
}
236236
}
237237

238-
// Windows platform has various different conventions than *nix platforms,
239-
// e.g. default enum underlying type, struct padding, mangling. Most tests
240-
// were written and checked on Linux and macOS, and thus they could fail on
241-
// Windows. We just make those tests targetting Linux instead as far as one
242-
// isn't annotated for a specific target.
243-
if cfg!(target_os = "windows") {
244-
if flags.iter().all(|flag| !flag.starts_with("--target=")) {
245-
if !flags.iter().any(|flag| flag == "--") {
246-
flags.push("--".into());
247-
}
248-
flags.push("--target=x86_64-unknown-linux".into());
238+
// Different platforms have various different conventions like struct padding, mangling, etc.
239+
// We make the default target as x86_64-unknown-linux
240+
if flags.iter().all(|flag| !flag.starts_with("--target=")) {
241+
if !flags.iter().any(|flag| flag == "--") {
242+
flags.push("--".into());
249243
}
244+
flags.push("--target=x86_64-unknown-linux".into());
250245
}
251246

252247
// Fool builder_from_flags() into believing it has real env::args_os...
@@ -307,6 +302,7 @@ include!(concat!(env!("OUT_DIR"), "/tests.rs"));
307302
fn test_header_contents() {
308303
let actual = builder()
309304
.header_contents("test.h", "int foo(const char* a);")
305+
.clang_arg("--target=x86_64-unknown-linux")
310306
.generate()
311307
.unwrap()
312308
.to_string();
@@ -335,6 +331,7 @@ fn test_multiple_header_calls_in_builder() {
335331
"/tests/headers/func_ptr.h"
336332
))
337333
.header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/char.h"))
334+
.clang_arg("--target=x86_64-unknown-linux")
338335
.generate()
339336
.unwrap()
340337
.to_string();

0 commit comments

Comments
 (0)