From 9bb22153ae14bbc98fe51b49d1604b9fa546c727 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Wed, 22 Dec 2021 12:25:13 +0900 Subject: [PATCH] libvda: ignore pkg_config errors if chromeos feature is not set pkg_config has introduced a new error type, Error::ProbeFailure, with version 0.3.23 and returns this new error for the pattern we were trying to match using Error::Failure. This causes the build script to fail if the host is using version 0.3.23 or later. Chrome OS is still using an older version, but trying to build with cargo is likely to pull a newer one. The pkg_config crate explicitly advises against matching these errors anyway, so change the strategy by ignoring the errors if the chromeos feature is not set. That way we still get clippy coverage while making sure a missing libvda package is caught during builds that actually use it (libvda is not used outside of Chrome OS). BUG=None TEST=cargo build --features "video-decoder,libvda" TEST=emerge-zork-arc-r chromeos-base/crosvm Change-Id: Ib2aad9f41541d3f4fe3cfb89f8b0f857d8033dcb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3347307 Reviewed-by: Chirantan Ekbote Tested-by: kokoro Commit-Queue: Alexandre Courbot --- libvda/build.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libvda/build.rs b/libvda/build.rs index 253bba97ba..47fa015b4d 100644 --- a/libvda/build.rs +++ b/libvda/build.rs @@ -3,12 +3,14 @@ // found in the LICENSE file. fn main() { + #[allow(clippy::single_match)] match pkg_config::probe_library("libvda") { Ok(_) => (), - // Ignore a pkg-config failure to allow cargo-clippy to run even when libvda.pc doesn't - // exist. - Err(pkg_config::Error::Failure { command, .. }) - if command == r#""pkg-config" "--libs" "--cflags" "libvda""# => {} + // Ignore pkg-config failures on non-chromeos platforms to allow cargo-clippy to run even + // if libvda.pc doesn't exist. + #[cfg(not(feature = "chromeos"))] + Err(_) => (), + #[cfg(feature = "chromeos")] Err(e) => panic!("{}", e), };