mirror of
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
synced 2026-10-24 00:48:53 +03:00
bindings: rust: feature gate unreleased features
`gpiod_line_request_get_chip_name()` is not released yet. Still, libgpiod-sys will just happily generate bindings for it if it sees the definition in the header file. This guards the unreleased features behind an optional feature `vnext`. To sketch the process of what happens once these features get into an assumed "2.1" release: libgpiod-sys will get updated with a `v2_1` feature. That feature would then raise the minimum version that is attempted to query from pkg- config. An identical feature will then be introduced on the `libgpiod` crate and `vnext` guards will be changed to `v2_1` guards. The `vnext` feature will then be updated to require the new `v2_1` feature. Eventually, we will probably raise the minimum supported version for the rust bindings and drop all the version gates before that. 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:
committed by
Bartosz Golaszewski
parent
e7b02c2259
commit
acebcf2cbe
@@ -18,6 +18,9 @@ exclude = [
|
||||
"Makefile.am",
|
||||
]
|
||||
|
||||
[features]
|
||||
vnext = []
|
||||
|
||||
[dependencies]
|
||||
errno = "0.2.8"
|
||||
intmap = "2.0.0"
|
||||
|
||||
@@ -8,7 +8,7 @@ command = SYSTEM_DEPS_LIBGPIOD_NO_PKG_CONFIG=1 \
|
||||
SYSTEM_DEPS_LIBGPIOD_SEARCH_NATIVE="${PWD}/../../../lib/.libs/" \
|
||||
SYSTEM_DEPS_LIBGPIOD_LIB=gpiod \
|
||||
SYSTEM_DEPS_LIBGPIOD_INCLUDE="${PWD}/../../../include/" \
|
||||
cargo build --release --lib
|
||||
cargo build --features=vnext --release --lib
|
||||
|
||||
if WITH_TESTS
|
||||
command += --tests
|
||||
|
||||
@@ -17,6 +17,19 @@ By default, `libgpiod-sys` builds against the libgpiod version identified via
|
||||
`pkg-config`. See the `README.md` of `libgpiod-sys` for options to override
|
||||
that.
|
||||
|
||||
Currently at least libgpiod 2.0 is required with the default feature set.
|
||||
|
||||
## Features
|
||||
|
||||
The Rust bindings will usually be built against whatever libgpiod version a
|
||||
system provides. Hence, only the functionality of the oldest supported libgpiod
|
||||
C library will be exposed by default.
|
||||
|
||||
Setting flags allows to increase the base version and export features of newer
|
||||
versions:
|
||||
|
||||
- `vnext`: The upcoming, still unreleased version of the C lib
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under either of
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-FileCopyrightText: 2022 Linaro Ltd.
|
||||
// SPDX-FileCopyrightText: 2022 Viresh Kumar <viresh.kumar@linaro.org>
|
||||
|
||||
#[cfg(feature = "vnext")]
|
||||
use std::ffi::CStr;
|
||||
use std::os::unix::prelude::AsRawFd;
|
||||
use std::time::Duration;
|
||||
@@ -31,6 +32,7 @@ impl Request {
|
||||
}
|
||||
|
||||
/// Get the name of the chip this request was made on.
|
||||
#[cfg(feature = "vnext")]
|
||||
pub fn chip_name(&self) -> Result<&str> {
|
||||
// SAFETY: The `gpiod_line_request` is guaranteed to be live as long
|
||||
// as `&self`
|
||||
|
||||
@@ -60,6 +60,7 @@ mod line_request {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "vnext")]
|
||||
fn chip_name() {
|
||||
const GPIO: Offset = 2;
|
||||
let mut config = TestConfig::new(NGPIO).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user