Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit a4ceb81

Browse files
Add fallback for pkg-config
1 parent 1ec6649 commit a4ceb81

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

gio/sys/tests/abi.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ use std::process::Command;
1414
use std::str;
1515
use tempfile::Builder;
1616

17-
static PACKAGES: &[&str] = &["gio-2.0", "gio-2.0-unix"];
17+
static PACKAGES: &[&str] = &["gio-2.0"];
18+
static PACKAGES_FALLBACK: &[&str] = &["gio-2.0-unix"];
1819

1920
#[derive(Clone, Debug)]
2021
struct Compiler {
2122
pub args: Vec<String>,
2223
}
2324

2425
impl Compiler {
25-
pub fn new() -> Result<Compiler, Box<dyn Error>> {
26+
pub fn new(packages: &[&str]) -> Result<Compiler, Box<dyn Error>> {
2627
let mut args = get_var("CC", "cc")?;
2728
args.push("-Wno-deprecated-declarations".to_owned());
2829
// For %z support in printf when using MinGW.
2930
args.push("-D__USE_MINGW_ANSI_STDIO".to_owned());
3031
args.extend(get_var("CFLAGS", "")?);
3132
args.extend(get_var("CPPFLAGS", "")?);
32-
args.extend(pkg_config_cflags(PACKAGES)?);
33+
args.extend(pkg_config_cflags(packages)?);
3334
Ok(Compiler { args })
3435
}
3536

@@ -131,7 +132,10 @@ fn cross_validate_constants_with_c() {
131132
.prefix("abi")
132133
.tempdir()
133134
.expect("temporary directory");
134-
let cc = Compiler::new().expect("configured compiler");
135+
let cc = match Compiler::new(PACKAKES) {
136+
Ok(cc) => Ok(cc),
137+
Err(_) => Compiler::new(PACKAGES_FALLBACK),
138+
}.expect("configured compiler");
135139

136140
assert_eq!(
137141
"1",

0 commit comments

Comments
 (0)