Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/bindgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
libcec_major_version: ["4", "5", "6"]
libcec_major_version: ["4", "5", "6", "7"]
env:
LIBCLANG_PATH: 'C:\Program Files\LLVM\lib'
steps:
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
libcec_major_version: ["4", "5", "6"]
libcec_major_version: ["4", "5", "6", "7"]
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
libcec_major_version: ["4", "5", "6"]
libcec_major_version: ["4", "5", "6", "7"]
target_triplet: ["x86_64-unknown-linux-gnu", "armv7-unknown-linux-gnueabihf", "arm-unknown-linux-gnueabi", "aarch64-unknown-linux-gnu"]
steps:
- name: Checkout repo
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,40 @@ jobs:
target: x86_64-pc-windows-msvc
use-cross: false
libcec: vendored-libcec
expected_libcec_abi: 6
expected_libcec_abi: 7
- os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false
libcec: static-libcec
expected_libcec_abi: 6
expected_libcec_abi: 7
additional_env:
LIBCEC_STATIC: "1"
- os: ubuntu-latest
target: arm-unknown-linux-gnueabi
use-cross: true
libcec: vendored-libcec
expected_libcec_abi: 6
expected_libcec_abi: 7
additional_env:
LIBCEC_VENDORED: "1"
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
use-cross: true
libcec: vendored-libcec
expected_libcec_abi: 6
expected_libcec_abi: 7
additional_env:
LIBCEC_VENDORED: "1"
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use-cross: false # Not run in cross so that EXPECTED_LIBCEC_VERSION_MAJOR shows inside the test
libcec: vendored-libcec
expected_libcec_abi: 6
expected_libcec_abi: 7
additional_env:
LIBCEC_VENDORED: "1"
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
libcec: static-libcec
expected_libcec_abi: 6
expected_libcec_abi: 7
additional_env:
LIBCEC_STATIC: "1"
#
Expand Down Expand Up @@ -103,15 +103,15 @@ jobs:
use-cross: false
libcec: "static-libcec"
pkg-config: false
expected_libcec_abi: 6
expected_libcec_abi: 7
additional_env:
LIBCEC_STATIC: "1"
- os: macos-latest
target: aarch64-apple-darwin
use-cross: false
libcec: "static-libcec"
pkg-config: false
expected_libcec_abi: 6
expected_libcec_abi: 7
additional_env:
LIBCEC_STATIC: "1"
steps:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED]

## 8.0.0

- Support linking to libcec v7 shared libraries. Previously only libcec v6 was supported, and build reverted to v6.0.2 static
- vendored libcec updated to version 7.0.0
- static libcec updated to version 7.0.0

## 7.0.7

- Fix breakage for systems with libcec7 installed: revert to static prebuilt v6 libcec for now.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [".", "cec_bindgen"]

[package]
name = 'libcec-sys'
version = "7.0.8-alpha.0"
version = "8.0.0-alpha.0"
authors = ['Sami Salonen']
edition = '2021'
license = 'GPL-2.0'
Expand Down Expand Up @@ -48,4 +48,4 @@ static = []
status = 'passively-maintained'

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(abi4)', 'cfg(abi5)', 'cfg(abi6)'] }
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(abi4)', 'cfg(abi5)', 'cfg(abi6)', 'cfg(abi7)'] }
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ FFI bindings for the libcec

## Finding libcec

This crate works with `libcec` v4.x, v5.x and v6.x (latest version as time of writing). During the build we try to find `libcec` system library installation using `pkg-config` and compilation using default C compiler (`cc` crate).
This crate works with `libcec` v4.x, v5.x, v6.x and v7.x(latest version as time of writing). During the build we try to find `libcec` system library installation using `pkg-config` and compilation using default C compiler (`cc` crate).

As a fallback, static pre-built `libcec` (v6.0.2) is downloaded from [ssalonen/libcec-static-builds](https://github.com/ssalonen/libcec-static-builds/releases/tag/libcec-v6.0.2-202412-1). Most common targets are supported.
As a fallback, static pre-built `libcec` (v7.0.0) is downloaded from [ssalonen/libcec-static-builds](https://github.com/ssalonen/libcec-static-builds/releases/tag/libcec-v7.0.0-202504-1). Most common targets are supported.

There are `vendored` and `static` feature to allow more explicit control. There are also `LIBCEC_VENDORED` and `LIBCEC_STATIC` environment variables, just set them to value `1`.

The crate is tested mainly with Linux and Windows but could work with other platforms as well. PRs welcome.

### Linux (general)

On Linux, for most convenient build process, it is recommended to install `pkg-config`, `libcec-dev` (headers and pkg-config configuration), `libcec6` (dynamic library), `libp8-platform-dev` and `libp8-platform2` from your package distribution before installing this crate. Exact package names vary between distributions and package managers.
On Linux, for most convenient build process, it is recommended to install `pkg-config`, `libcec-dev` (headers and pkg-config configuration), `libcec6` or `libcec7` (dynamic library), `libp8-platform-dev` and `libp8-platform2` from your package distribution before installing this crate. Exact package names vary between distributions and package managers.

In addition `libudev-dev` might be needed.

Expand All @@ -43,7 +43,7 @@ For dynamic linking: On Windows, it is recommended to install `libcec` via the [
For a vendored build: `libcec-sys` will dynamically link to the compiled `cec.dll`. This means you must package your standalone executable with the compiled dynamic library.

#### Vendored Build Prerequisites:
- Visual Studio 2019 w/ `Desktop Development with C++` and `Universal Windows Platform development`
- Visual Studio 2022 w/ `Desktop Development with C++` and `Universal Windows Platform development`
- CMake 3.12+
- Python 3.6+ with Debug Binaries

Expand Down
15 changes: 11 additions & 4 deletions build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum CecVersion {
V4,
V5,
V6,
V7,
}

impl CecVersion {
Expand All @@ -39,6 +40,7 @@ impl CecVersion {
Self::V4 => 4,
Self::V5 => 5,
Self::V6 => 6,
Self::V7 => 7,
}
}
}
Expand All @@ -50,7 +52,12 @@ enum BuildMode {
}

// libcec versions that are supported when linking dynamically. In preference order
const CEC_MAJOR_VERSIONS: [CecVersion; 3] = [CecVersion::V6, CecVersion::V5, CecVersion::V4];
const CEC_MAJOR_VERSIONS: [CecVersion; 4] = [
CecVersion::V7,
CecVersion::V6,
CecVersion::V5,
CecVersion::V4,
];

fn prepare_vendored_build(dst: &Path) {
let dst_src = dst.join(LIBCEC_SRC);
Expand Down Expand Up @@ -386,12 +393,12 @@ fn parse_vendored_libcec_major_version(cmakelists: &Path) -> u32 {
pub fn fetch_static_libcec<P: AsRef<Path>>(path: P, debug_build: bool) {
println!("\n\n==============================================================\nFetching pre-built static libcec\n==============================================================");
println!("cargo:lib_static=true");
println!("cargo:libcec_version_major=6");
println!("cargo:rustc-cfg=abi6");
println!("cargo:libcec_version_major=7");
println!("cargo:rustc-cfg=abi7");

let target = env::var("TARGET").expect("Must have TARGET env variable in build.rs");
let kind = if debug_build { "debug" } else { "release" };
let url = format!("https://github.com/ssalonen/libcec-static-builds/releases/download/libcec-v6.0.2-202412-1/libcec-v6.0.2-static-{target}-{kind}.zip");
let url = format!("https://github.com/ssalonen/libcec-static-builds/releases/download/libcec-v7.0.0-202504-1/libcec-v7.0.0-static-{target}-{kind}.zip");
dbg!(&target, kind, &url);

let response = reqwest::blocking::get(&url)
Expand Down
9 changes: 9 additions & 0 deletions build/smoke_abi7.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdint.h>
#include <cecc.h>

int main()
{
_Static_assert(CEC_LIB_VERSION_MAJOR == 7,
"libcec major version is " CEC_LIB_VERSION_MAJOR_STR ", not as expected (7)");
return (intptr_t)libcec_initialise;
}
6 changes: 6 additions & 0 deletions cec_bindgen/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl From<&str> for CecVersion<'_> {
patch: 2,
git_tag: "libcec-6.0.2",
},
"7" => Self {
major: 7,
minor: 0,
patch: 0,
git_tag: "libcec-7.0.0",
},
_ => panic!("Unexpected major version"),
}
}
Expand Down
22 changes: 20 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,48 @@ mod bindings {
include!("lib_abi5_x86_64-pc-windows-msvc.rs");
} else if #[cfg(all(abi6, target_os = "windows", target_arch = "x86_64", target_env = "msvc"))] {
include!("lib_abi6_x86_64-pc-windows-msvc.rs");
} else if #[cfg(all(abi4, target_os = "linux", target_arch = "x86_64", target_env = "gnu"))] {
} else if #[cfg(all(abi7, target_os = "windows", target_arch = "x86_64", target_env = "msvc"))] {
include!("lib_abi7_x86_64-pc-windows-msvc.rs");
}else if #[cfg(all(abi4, target_os = "linux", target_arch = "x86_64", target_env = "gnu"))] {
include!("lib_abi4_x86_64-unknown-linux-gnu.rs");
} else if #[cfg(all(abi5, target_os = "linux", target_arch = "x86_64", target_env = "gnu"))] {
include!("lib_abi5_x86_64-unknown-linux-gnu.rs");
} else if #[cfg(all(abi6, target_os = "linux", target_arch = "x86_64", target_env = "gnu"))] {
include!("lib_abi6_x86_64-unknown-linux-gnu.rs");
} else if #[cfg(all(abi4, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
} else if #[cfg(all(abi7, target_os = "linux", target_arch = "x86_64", target_env = "gnu"))] {
include!("lib_abi7_x86_64-unknown-linux-gnu.rs");
}else if #[cfg(all(abi4, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi4_armv7-unknown-linux-gnueabihf.rs");
} else if #[cfg(all(abi5, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi5_armv7-unknown-linux-gnueabihf.rs");
} else if #[cfg(all(abi6, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi6_armv7-unknown-linux-gnueabihf.rs");
} else if #[cfg(all(abi7, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi7_armv7-unknown-linux-gnueabihf.rs");
} else if #[cfg(all(abi4, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi4_arm-unknown-linux-gnueabi.rs");
} else if #[cfg(all(abi5, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi5_arm-unknown-linux-gnueabi.rs");
} else if #[cfg(all(abi6, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi6_arm-unknown-linux-gnueabi.rs");
} else if #[cfg(all(abi7, target_os = "linux", target_arch = "arm", target_env = "gnu"))] {
include!("lib_abi7_arm-unknown-linux-gnueabi.rs");
} else if #[cfg(all(abi4, target_os = "linux", target_arch = "aarch64", target_env = "gnu"))] {
include!("lib_abi4_aarch64-unknown-linux-gnu.rs");
} else if #[cfg(all(abi5, target_os = "linux", target_arch = "aarch64", target_env = "gnu"))] {
include!("lib_abi5_aarch64-unknown-linux-gnu.rs");
} else if #[cfg(all(abi6, target_os = "linux", target_arch = "aarch64", target_env = "gnu"))] {
include!("lib_abi6_aarch64-unknown-linux-gnu.rs");
} else if #[cfg(all(abi7, target_os = "linux", target_arch = "aarch64", target_env = "gnu"))] {
include!("lib_abi7_aarch64-unknown-linux-gnu.rs");
} else if #[cfg(all(abi4, target_os = "macos", target_arch = "aarch64"))] {
include!("lib_abi4_aarch64-apple-darwin.rs");
} else if #[cfg(all(abi5, target_os = "macos", target_arch = "aarch64"))] {
include!("lib_abi5_aarch64-apple-darwin.rs");
} else if #[cfg(all(abi6, target_os = "macos", target_arch = "aarch64"))] {
include!("lib_abi6_aarch64-apple-darwin.rs");
} else if #[cfg(all(abi7, target_os = "macos", target_arch = "aarch64"))] {
include!("lib_abi7_aarch64-apple-darwin.rs");
}
else {
compile_error!("unsupported platform");
Expand Down Expand Up @@ -90,4 +102,10 @@ mod tests {
fn test_abi6() {
assert_eq!(CEC_LIB_VERSION_MAJOR, 6);
}

#[cfg(abi7)]
#[test]
fn test_abi7() {
assert_eq!(CEC_LIB_VERSION_MAJOR, 7);
}
}
Loading
Loading