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 bdd79a6 commit 6d00e67
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libcamera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ thiserror = "1.0"

[build-dependencies]
semver = "1.0.22"
pkg-config = "0.3"
21 changes: 20 additions & 1 deletion 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,7 +7,25 @@ use std::{
use semver::{Comparator, Op, Version};

fn main() {
let libcamera_version = Version::new(0, 4, 0);
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 6d00e67

Please sign in to comment.