xtask: the ALSA probe reads PKG_CONFIG before PATH

The probe ran pkg-config straight from PATH while the build's alsa-sys
goes through the pkg-config crate, which reads PKG_CONFIG first: the
variable may name a working pkg-config that is not on PATH, and then
cargo xtask ci would report ALSA as missing over a build that finds
it. The probe now selects the same executable the same way; no test
stands over it because the probe needs a real pkg-config environment
(the hint is split out for exactly that machine-dependence).
This commit is contained in:
Kaedo17
2026-10-30 01:30:50 +08:00
parent ac0188f315
commit ccc59cf55f
+4 -1
View File
@@ -430,9 +430,12 @@ fn audio_backend_hint(found: bool) -> Result<(), String> {
/// `cargo xtask ci` builds the desktop app on the host, so on Linux it needs ALSA headers to be
/// present. Checking here turns a late, confusing link error into one line naming the package.
/// The probe reads `PKG_CONFIG` first, like the pkg-config crate alsa-sys goes through: the
/// variable may name a working pkg-config that is not on `PATH`, and the build would use it too.
#[cfg(target_os = "linux")]
fn audio_backend() -> Result<(), String> {
let found = Command::new("pkg-config").args(["--exists", "alsa"]).status().map(|s| s.success()).unwrap_or(false);
let program = std::env::var_os("PKG_CONFIG").unwrap_or_else(|| "pkg-config".into());
let found = Command::new(program).args(["--exists", "alsa"]).status().map(|s| s.success()).unwrap_or(false);
audio_backend_hint(found)
}