1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00

bindings: rust: expose v2.1 features as flag

v2.1 provided a getter to read the chip name from a request.

This adds v2_1 as feature in order to raise the minimum requested version
to v2.1 for exposing the new API.

This is identical to the concept patch that was posted [1] when this
feature flag mechanism was proposed. Only the commit message was
reworded.

[1] https://lore.kernel.org/all/20231006-b4-bindings-old-version-fix-v1-2-a65f431afb97@linaro.org/

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
Erik Schilling
2023-11-06 13:53:14 +01:00
committed by Bartosz Golaszewski
parent 8c8547bfdd
commit 7552e5d9ed
5 changed files with 13 additions and 6 deletions

View File

@@ -18,11 +18,16 @@ exclude = [
"Makefile.am",
]
[features]
v2_1 = []
[dependencies]
[build-dependencies]
bindgen = "0.63"
system-deps = "2.0"
[package.metadata.system-deps]
libgpiod = "2"
[package.metadata.system-deps.libgpiod]
name = "libgpiod"
version = "2"
v2_1 = { version = "2.1" }

View File

@@ -19,7 +19,8 @@ exclude = [
]
[features]
vnext = []
v2_1 = ["libgpiod-sys/v2_1"]
vnext = ["v2_1"]
[dependencies]
errno = "0.2.8"

View File

@@ -28,6 +28,7 @@ C library will be exposed by default.
Setting flags allows to increase the base version and export features of newer
versions:
- `v2_1`: Minimum version of `2.1.x`
- `vnext`: The upcoming, still unreleased version of the C lib
## License

View File

@@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: 2022 Linaro Ltd.
// SPDX-FileCopyrightText: 2022 Viresh Kumar <viresh.kumar@linaro.org>
#[cfg(feature = "vnext")]
#[cfg(feature = "v2_1")]
use std::ffi::CStr;
use std::os::unix::prelude::AsRawFd;
use std::time::Duration;
@@ -32,7 +32,7 @@ impl Request {
}
/// Get the name of the chip this request was made on.
#[cfg(feature = "vnext")]
#[cfg(feature = "v2_1")]
pub fn chip_name(&self) -> Result<&str> {
// SAFETY: The `gpiod_line_request` is guaranteed to be live as long
// as `&self`

View File

@@ -60,7 +60,7 @@ mod line_request {
use super::*;
#[test]
#[cfg(feature = "vnext")]
#[cfg(feature = "v2_1")]
fn chip_name() {
const GPIO: Offset = 2;
let mut config = TestConfig::new(NGPIO).unwrap();