diff --git a/CHANGELOG.md b/CHANGELOG.md index e45e926..b5dc879 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] +## 7.0.7 + +- Fix breakage for systems with libcec7 installed: revert to static prebuilt v6 libcec for now. + ## 7.0.6 - Support for `aarch64-unknown-linux-gnu` diff --git a/build/build.rs b/build/build.rs index f199685..674976e 100644 --- a/build/build.rs +++ b/build/build.rs @@ -317,8 +317,10 @@ fn libcec_installed_pkg_config() -> Result { println!("\n\n==============================================================\nUsing pkg-config to find out if libcec is installed\n=============================================================="); for abi in CEC_MAJOR_VERSIONS { println!("\n\npkg-config with libcec major {}", abi.major()); + let major = format!("{}.0.0", abi.major()); // inclusive + let next_major = format!("{}.0.0", abi.major() + 1); // exclusive let pkg_config_result = pkg_config::Config::new() - .atleast_version(&abi.major().to_string()) + .range_version(major.as_str()..next_major.as_str()) .probe("libcec"); if pkg_config_result.is_ok() { println!("pkg_config(>={}) -> found", abi.major()); @@ -481,11 +483,11 @@ fn find_using_smoke_test() -> bool { fn determine_mode() -> BuildMode { let vendored_explicitly_via_env = - env::var("LIBCEC_VENDORED").map_or(false, |s| s != "0" && !s.is_empty()); + env::var("LIBCEC_VENDORED").is_ok_and(|s| s != "0" && !s.is_empty()); let vendored_forbidden_explicitly_via_env = - env::var("LIBCEC_NO_VENDOR").map_or(false, |s| s != "0" && !s.is_empty()); + env::var("LIBCEC_NO_VENDOR").is_ok_and(|s| s != "0" && !s.is_empty()); let static_explicitly_via_env = - env::var("LIBCEC_STATIC").map_or(false, |s| s != "0" && !s.is_empty()); + env::var("LIBCEC_STATIC").is_ok_and(|s| s != "0" && !s.is_empty()); if (cfg!(feature = "vendored") || vendored_explicitly_via_env) && !vendored_forbidden_explicitly_via_env diff --git a/cec_bindgen/src/build.rs b/cec_bindgen/src/build.rs index 2f39f8f..09a9799 100644 --- a/cec_bindgen/src/build.rs +++ b/cec_bindgen/src/build.rs @@ -96,6 +96,19 @@ fn fetch_libcec_source>(path: P, major_version: &str) -> Result<( Ok(()) } +fn preprocess_headers>(path: P){ + let cectypes_path = path.as_ref().join("include").join("cectypes.h"); + let mut cectypes_content = + std::fs::read_to_string(&cectypes_path).expect("Failed to read cectypes.h"); + + // replace weird comments so they don't end up with the bindgen result and result in clippy issues + cectypes_content = cectypes_content.replace("@/*!< ", "/* "); + cectypes_content = cectypes_content.replace("//!< ", "// "); + + + std::fs::write(cectypes_path, cectypes_content).expect("Failed to create cectypes.h"); +} + fn main() -> Result<()> { color_eyre::install()?; let args: Args = Args::parse(); @@ -129,6 +142,7 @@ fn main() -> Result<()> { // Only the headers are used, so fetch the release version since it's smaller. fetch_libcec_source(&lib_path, &args.major_version).context("failed to fetch libcec source")?; + preprocess_headers(&lib_path); run_bindgen(&src_path, &lib_path, &out_path).context("failed to run bindgen")?; dbg!(&out_path); diff --git a/src/lib_abi6_x86_64-unknown-linux-gnu.rs b/src/lib_abi6_x86_64-unknown-linux-gnu.rs index a7a31fb..0d01813 100644 --- a/src/lib_abi6_x86_64-unknown-linux-gnu.rs +++ b/src/lib_abi6_x86_64-unknown-linux-gnu.rs @@ -309,15 +309,10 @@ pub const CEC_IMX_VIRTUAL_COM: &[u8; 5] = b"i.MX\0"; pub const CEC_MIN_LIB_VERSION: u32 = 4; pub const CEC_FEATURE_CONFIGURABLE_COMBO_KEY: u32 = 1; pub const LIBCEC_OSD_NAME_SIZE: u32 = 15; -#[doc = "!< CEC_ABORT_REASON_UNRECOGNIZED_OPCODE"] pub const cec_abort_reason_UNRECOGNIZED_OPCODE: cec_abort_reason = 0; -#[doc = "!< CEC_ABORT_REASON_NOT_IN_CORRECT_MODE_TO_RESPOND"] pub const cec_abort_reason_NOT_IN_CORRECT_MODE_TO_RESPOND: cec_abort_reason = 1; -#[doc = "!< CEC_ABORT_REASON_CANNOT_PROVIDE_SOURCE"] pub const cec_abort_reason_CANNOT_PROVIDE_SOURCE: cec_abort_reason = 2; -#[doc = "!< CEC_ABORT_REASON_INVALID_OPERAND"] pub const cec_abort_reason_INVALID_OPERAND: cec_abort_reason = 3; -#[doc = "!< CEC_ABORT_REASON_REFUSED"] pub const cec_abort_reason_REFUSED: cec_abort_reason = 4; pub const cec_analogue_broadcast_type_CABLE: cec_analogue_broadcast_type = 0; pub const cec_analogue_broadcast_type_SATELLITE: cec_analogue_broadcast_type = 1;