From patchwork Fri Oct 6 07:24:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 730577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC4DBE92FF1 for ; Fri, 6 Oct 2023 07:24:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbjJFHYh (ORCPT ); Fri, 6 Oct 2023 03:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230226AbjJFHYf (ORCPT ); Fri, 6 Oct 2023 03:24:35 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C84CA for ; Fri, 6 Oct 2023 00:24:32 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9adca291f99so311130466b.2 for ; Fri, 06 Oct 2023 00:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696577071; x=1697181871; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RgOnqDtHwQ7h8p/R01B58Kl1a7Klb09gudZ6n02NOho=; b=fEs/Zcrq38vQf+3AfJm5L+qXWKX8DF0KZm5vSknyJGLOkA6/gbKVp+y3DscLi/FxaS jNSa7AvIWmH4vHurmCYQweL7TJ+TMqFj27YFUPPT0i8t3qfAepTfRpZxL497rNgjc2dz 0Y6JvtapDY6hf0CGJhd+7yVM83kdAoM0Gw1n/IRrFXQucEFR3BMdNrExyn4UbCle2dwQ JOFrTjD2kXS3vGpC8+Qk/WmtvyS3/taCv6GtWilzDg5BOjTdx3qEPDEtM7wSxbXKsuwG 7yYOvPp29wLnGadObmLqWO6qP0NwSKX0UmErsa3QLtN3FvLHBTaQtZJ6NEO/lVdzIJ9z Ar2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696577071; x=1697181871; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RgOnqDtHwQ7h8p/R01B58Kl1a7Klb09gudZ6n02NOho=; b=CSL5QV9+PdzIKphtviqwN5H+wbC4zCnBtSygnpx5BoNf8VLyX4hhZC8NX9FDezaP9A y3aIYSdO/qh9EishtSsOQz94kCHPEj2/eC+3XLqftg3er2es3VU1vJOcD74K+ayZDvXC pXswa408Ou2qPC7hLdExWaYURnr8p2Wkrr00sjv/ElxdRMKlmqbo18uVbjojksged2pQ UcQnJTC3fkc3MCH5EPzFe/nZ/aS29PHCsxOL8paQ0MwWz/dM+1j4FqyiGX/RtPBYdzHA 1m0i7qYLqQeh/Zj2wDBSBHU/Rndb/amkF8ed8TbxSTYpzUiG+ZhNMA3dYtW5Fq79pSdm uctA== X-Gm-Message-State: AOJu0Yy8eh1I1rdA4nlrNSU5UbjjJoF3eV6Djz+qBH6zOvMCXubgr3Mq YJFUoNXcy0tdfe8X0xsEJeo1OQ== X-Google-Smtp-Source: AGHT+IH59Kjq51CdReP9LPYl8HRuBWwl6HV954S7s59BqaojAPMmbGKpaxDgvv2eV/xiSI0nVjKabQ== X-Received: by 2002:a17:906:530b:b0:9a9:9c6c:c4ef with SMTP id h11-20020a170906530b00b009a99c6cc4efmr6522492ejo.23.1696577070913; Fri, 06 Oct 2023 00:24:30 -0700 (PDT) Received: from [192.168.1.149] (i5C743835.versanet.de. [92.116.56.53]) by smtp.gmail.com with ESMTPSA id l9-20020a170906230900b009928b4e3b9fsm2394963eja.114.2023.10.06.00.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:24:30 -0700 (PDT) From: Erik Schilling Date: Fri, 06 Oct 2023 09:24:26 +0200 Subject: [libgpiod][PATCH 1/2] bindings: rust: feature gate unreleased features MIME-Version: 1.0 Message-Id: <20231006-b4-bindings-old-version-fix-v1-1-a65f431afb97@linaro.org> References: <20231006-b4-bindings-old-version-fix-v1-0-a65f431afb97@linaro.org> In-Reply-To: <20231006-b4-bindings-old-version-fix-v1-0-a65f431afb97@linaro.org> To: Bartosz Golaszewski , Linux-GPIO Cc: Viresh Kumar , Manos Pitsidianakis , Kent Gibson , Erik Schilling X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1696577069; l=4315; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=Af7w3grDk1o85odIatDfXZ6tJDlO6vC+GJr6NWVKej8=; b=WnthAk2Zdp/6RBz+yx2WHaILDQKwpUNPK0olypQyCuDwvonM4l4Nsop7o8+8mt2yWjZuo+x2u qgT2gKBrjt9AZT/PnOf/ZUAdaUPZMgCvUJu8nANbZlCeU6z4QrSlrcH X-Developer-Key: i=erik.schilling@linaro.org; a=ed25519; pk=/nNqy8/YOEdthj1epXl5FgwCTKEiVqTqqnVN1jVal7s= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org `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 --- bindings/rust/libgpiod/Cargo.toml | 3 +++ bindings/rust/libgpiod/Makefile.am | 2 +- bindings/rust/libgpiod/README.md | 13 +++++++++++++ bindings/rust/libgpiod/src/line_request.rs | 2 ++ bindings/rust/libgpiod/tests/line_request.rs | 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bindings/rust/libgpiod/Cargo.toml b/bindings/rust/libgpiod/Cargo.toml index 3be4aa0..3fd1d74 100644 --- a/bindings/rust/libgpiod/Cargo.toml +++ b/bindings/rust/libgpiod/Cargo.toml @@ -18,6 +18,9 @@ exclude = [ "Makefile.am", ] +[features] +vnext = [] + [dependencies] errno = "0.2.8" intmap = "2.0.0" diff --git a/bindings/rust/libgpiod/Makefile.am b/bindings/rust/libgpiod/Makefile.am index 92edbfc..619e36c 100644 --- a/bindings/rust/libgpiod/Makefile.am +++ b/bindings/rust/libgpiod/Makefile.am @@ -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 diff --git a/bindings/rust/libgpiod/README.md b/bindings/rust/libgpiod/README.md index 8d514e7..c86b06e 100644 --- a/bindings/rust/libgpiod/README.md +++ b/bindings/rust/libgpiod/README.md @@ -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 diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs index 64ef05d..a7fe6d0 100644 --- a/bindings/rust/libgpiod/src/line_request.rs +++ b/bindings/rust/libgpiod/src/line_request.rs @@ -2,6 +2,7 @@ // SPDX-FileCopyrightText: 2022 Linaro Ltd. // SPDX-FileCopyrightText: 2022 Viresh Kumar +#[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` diff --git a/bindings/rust/libgpiod/tests/line_request.rs b/bindings/rust/libgpiod/tests/line_request.rs index e0ae200..a936a1b 100644 --- a/bindings/rust/libgpiod/tests/line_request.rs +++ b/bindings/rust/libgpiod/tests/line_request.rs @@ -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(); From patchwork Fri Oct 6 07:24:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 730128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9289EE92FF4 for ; Fri, 6 Oct 2023 07:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbjJFHYh (ORCPT ); Fri, 6 Oct 2023 03:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbjJFHYg (ORCPT ); Fri, 6 Oct 2023 03:24:36 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C614E9 for ; Fri, 6 Oct 2023 00:24:33 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9b1ebc80d0aso316183566b.0 for ; Fri, 06 Oct 2023 00:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696577072; x=1697181872; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=if/WrUmwUFuAXP+TYQ6DFL1rpC0gab1v5RiN72QS+4c=; b=T2zTt094EBXV74zu/wQD5jijZmPZkTqxb2o+WUPTQqxy7+f0FDeq2NieOKAyP0WxJK bbFvBOTdFMUVARvk8882Qdsd8n+m7PqwjBqGEhSI7aDRJZ2DjYd0S1ccuZO9O5ORyMNG D1HWtITsUilYbd24MFvd8l5MxafxCF0Pckl+5AQ0mFLc85tGN9XI+YjkyROvbt3pUhcJ /69UidZVJ0Fi3zpzoyrgcQUP8UE9zVeR1FDilqbQMx5gpt5qmrkGc5pUHn5qv1VHVA4L l3pY22GHEirN0phWI+NZyvH/p5Ip3avunmrK+fODPxwP1zHEd7N8pE9cQyEupVcw+9yF 38Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696577072; x=1697181872; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=if/WrUmwUFuAXP+TYQ6DFL1rpC0gab1v5RiN72QS+4c=; b=gsPs3FEsas+wsJlt6M9WUkVBu5fYarS2OxW89pXZBrOXZ8fjOO1nM9+9o2TqI/JyBP WkSmYFlm0flbkpyTq1BzZjN3TdT9vkSHnsFTciyd+517z2YeOWlcM4gl+YHC8VvFQgD7 9l5fnaaW4YtqMf4UdCab/AbVtCRh3Iu0PfubUq+6zjWPhqVpfc1oOw/IXJsk8LsIJp+d liOuOZNqTLAgjJI67rrlN+bDHybVTHeQ/UBA4J3KERkpXGuWu9p2H6xxeFxyb+RDB9mB 12WWXATvks6TXnGkFrblIvUbLUG1Vu8w0xk4vZizmCIaLF/wDtoLQBzar/KJSxGZDAe0 8oRg== X-Gm-Message-State: AOJu0Yz+zlOTev1GxKaL9oxiPNO8NO3V/a+aMatMhJWl48CLbbfl0fTR cN7CsXAL6kEY7nExoraApx9XYg== X-Google-Smtp-Source: AGHT+IHN2ICnFQ73TBYWwomq3IlINDt+UQzZka6xOwnGaDeGBtErxMFxbcP6owQFm1VIsccj/z3nPw== X-Received: by 2002:a17:907:1dd2:b0:9a1:d087:e0c0 with SMTP id og18-20020a1709071dd200b009a1d087e0c0mr6468888ejc.42.1696577071634; Fri, 06 Oct 2023 00:24:31 -0700 (PDT) Received: from [192.168.1.149] (i5C743835.versanet.de. [92.116.56.53]) by smtp.gmail.com with ESMTPSA id l9-20020a170906230900b009928b4e3b9fsm2394963eja.114.2023.10.06.00.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:24:31 -0700 (PDT) From: Erik Schilling Date: Fri, 06 Oct 2023 09:24:27 +0200 Subject: [libgpiod][PATCH 2/2] DONOTMERGE: bindings: rust: simulate v2.1 release MIME-Version: 1.0 Message-Id: <20231006-b4-bindings-old-version-fix-v1-2-a65f431afb97@linaro.org> References: <20231006-b4-bindings-old-version-fix-v1-0-a65f431afb97@linaro.org> In-Reply-To: <20231006-b4-bindings-old-version-fix-v1-0-a65f431afb97@linaro.org> To: Bartosz Golaszewski , Linux-GPIO Cc: Viresh Kumar , Manos Pitsidianakis , Kent Gibson , Erik Schilling X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1696577069; l=3237; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=m3OsgXmD8vXFhN8t3H37VIfRSxWj1p4yKCZVoXPvcTw=; b=fUcXQ8G7F1L6btGnkZ+IC7IMbSYxLxRgDa3dpXm6vU7nqaJoNxxhUCe1RDZCe3i8ev19ogai6 y5kqOo0UWEyA2+p2Wma6vrQu7CAcOuFADhj/MRtrzE+RkcfQXpWIbmd X-Developer-Key: i=erik.schilling@linaro.org; a=ed25519; pk=/nNqy8/YOEdthj1epXl5FgwCTKEiVqTqqnVN1jVal7s= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This is just a demo of a release bump to better illustrate what was sketched in the previous commit. Signed-off-by: Erik Schilling --- bindings/rust/libgpiod-sys/Cargo.toml | 9 +++++++-- bindings/rust/libgpiod/Cargo.toml | 3 ++- bindings/rust/libgpiod/README.md | 1 + bindings/rust/libgpiod/src/line_request.rs | 4 ++-- bindings/rust/libgpiod/tests/line_request.rs | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bindings/rust/libgpiod-sys/Cargo.toml b/bindings/rust/libgpiod-sys/Cargo.toml index b4d26e9..f90615d 100644 --- a/bindings/rust/libgpiod-sys/Cargo.toml +++ b/bindings/rust/libgpiod-sys/Cargo.toml @@ -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" } diff --git a/bindings/rust/libgpiod/Cargo.toml b/bindings/rust/libgpiod/Cargo.toml index 3fd1d74..0d8745d 100644 --- a/bindings/rust/libgpiod/Cargo.toml +++ b/bindings/rust/libgpiod/Cargo.toml @@ -19,7 +19,8 @@ exclude = [ ] [features] -vnext = [] +v2_1 = ["libgpiod-sys/v2_1"] +vnext = ["v2_1"] [dependencies] errno = "0.2.8" diff --git a/bindings/rust/libgpiod/README.md b/bindings/rust/libgpiod/README.md index c86b06e..1ef3743 100644 --- a/bindings/rust/libgpiod/README.md +++ b/bindings/rust/libgpiod/README.md @@ -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 diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs index a7fe6d0..7ec6508 100644 --- a/bindings/rust/libgpiod/src/line_request.rs +++ b/bindings/rust/libgpiod/src/line_request.rs @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 2022 Linaro Ltd. // SPDX-FileCopyrightText: 2022 Viresh Kumar -#[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` diff --git a/bindings/rust/libgpiod/tests/line_request.rs b/bindings/rust/libgpiod/tests/line_request.rs index a936a1b..4e095a4 100644 --- a/bindings/rust/libgpiod/tests/line_request.rs +++ b/bindings/rust/libgpiod/tests/line_request.rs @@ -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();