Skip to content

Commit

Permalink
Get version of libcamera with pkgconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
fishrockz committed Dec 20, 2024
1 parent 2e8303a commit 210c338
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libcamera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ smallvec = "1.10"
thiserror = "1.0"

[build-dependencies]
libcamera-sys = { path = "../libcamera-sys", version = "0.3.0" }
semver = "1.0.22"
pkg-config = "0.3"
25 changes: 20 additions & 5 deletions libcamera/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::panic;
use std::{
env,
path::{Path, PathBuf},
Expand All @@ -6,11 +7,25 @@ use std::{
use semver::{Comparator, Op, Version};

fn main() {
let libcamera_version = Version::new(
libcamera_sys::LIBCAMERA_VERSION_MAJOR as _,
libcamera_sys::LIBCAMERA_VERSION_MINOR as _,
libcamera_sys::LIBCAMERA_VERSION_PATCH as _,
);
let libcamera = match pkg_config::probe_library("libcamera") {
Ok(lib) => Ok(lib),
Err(e) => {
// Older libcamera versions use camera name instead of libcamera, try that instead
match pkg_config::probe_library("camera") {
Ok(lib) => Ok(lib),
// Return original error
Err(_) => Err(e),
}
}
}
.unwrap();

let libcamera_version = match Version::parse(&libcamera.version) {
Ok(v) => v,
Err(e) => {
panic!("bad version from pkgconfig, {e:?}")
}
};

let versioned_files = Path::new("versioned_files");
let mut candidates = std::fs::read_dir(versioned_files)
Expand Down

0 comments on commit 210c338

Please sign in to comment.