Have tests targetting Linux by default on Windows
@@ -137,6 +137,20 @@ fn create_bindgen_builder(header: &PathBuf) -> Result<Option<Builder>, Error> {
}
}
+ // Windows platform has various different conventions than *nix platforms,
+ // e.g. default enum underlying type, struct padding, mangling. Most tests
+ // were written and checked on Linux and macOS, and thus they could fail on
+ // Windows. We just make those tests targetting Linux instead as far as one
+ // isn't annotated for a specific target.
+ if cfg!(target_os = "windows") {
+ if flags.iter().all(|flag| !flag.starts_with("--target=")) {
+ if !flags.iter().any(|flag| flag == "--") {
+ flags.push("--".into());
+ }
+ flags.push("--target=x86_64-unknown-linux".into());
+ }
+ }
+
// Fool builder_from_flags() into believing it has real env::args_os...
// - add "bindgen" as executable name 0th element
// - add header filename as 1st element
