Message ID | cover.1667815011.git.viresh.kumar@linaro.org |
---|---|
Headers | show |
Series | libgpiod: Add Rust bindings | expand |
On Mon, Nov 7, 2022 at 10:57 AM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > Hello, > > Here is another version of the rust bindings, based of the master branch. > > Pushed here: > > https://github.com/vireshk/libgpiod v9 > > V8->V9: > - Merged the last patch (supporting Events) with the other patches. > - Events implementation is simplified and made efficient. nth() is also > implemented for the iterator. > - Unnecessary comment removed from Cargo.toml files. > - Updated categories in libgpiod's Cargo.toml. > - Updated gpio_events example to show cloned events live past another > read_edge_events(). > - Implement AsRawFd for Chip. > - Other minor changes. > Kent, Miguel: if you are ok with this version - can you add your review tags? Bart
On Thu, Nov 17, 2022 at 11:40 AM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > On 17-11-22, 11:18, Bartosz Golaszewski wrote: > > Do these problems you faced apply to libgpiod too? > > I faced them with libgpiod only :( > > > Honestly, putting > > automatically generated files in the repo just feels wrong. > > I agree, but ... > > > It defeats > > the whole purpose of code generation. If we can't reliably regenerate > > them, then it sounds like a problem with the tools, not the library. > > Maybe we don't need to worry about that just yet? > > it isn't about reliability of the generated code, but making everyone do it, > even if they don't need to. > > Also, the code generated here is Rust code wrappers and other declarations, > which let us call the C helpers eventually. It can be considered like hand > written code here, for the argument that it is automatically generated stuff. > Just that we have a tool (bindgen) here which lets us generate it automatically, > without introducing bugs. > > Anyway, I am fine with whatever you decide. > Let me propose a different solution. When preparing release tarballs with autotools, certain files are generated automatically that go into the tarball but are never part of the repository. This way developers don't have to deal with the automatically generated files polluting the repo while end-users get a tarball with less dependencies and reproducible results. It's called the dist-local hook in automake. Does it sound like something we could use here? Bart
> On Thu, Nov 17, 2022 at 10:56 AM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > Do these problems you faced apply to libgpiod too? Honestly, putting > automatically generated files in the repo just feels wrong. It defeats > the whole purpose of code generation. If we can't reliably regenerate > them, then it sounds like a problem with the tools, not the library. > Maybe we don't need to worry about that just yet? If the library is stable enough, then removing a heavy build dependency on bindgen may be worth it. But yeah, by default I would avoid it unless one is sure it is possible. Though, if one can store it because it is fixed, at that point one may take advantage of that and manually write (or tweak) the bindings instead. In any case, I would explain the rationale one way or the other in the commit message or ideally in the `README.MD`. One thing I may have missed: why is there a `-sys` crate for one of the bindings but not the other? It may be a good idea to document the intention as well. Cheers, Miguel
On 17-11-22, 11:48, Bartosz Golaszewski wrote: > Let me propose a different solution. When preparing release tarballs > with autotools, certain files are generated automatically that go into > the tarball but are never part of the repository. This way developers > don't have to deal with the automatically generated files polluting > the repo while end-users get a tarball with less dependencies and > reproducible results. > > It's called the dist-local hook in automake. > > Does it sound like something we could use here? These auto-generated bindings are used only by the code present in bindings/rust/libgpiod/src/, and are never visible to end user code. The end user will use the new interface provided by the libgpiod Rust bindings instead and that works over the web and will be picked from libgpiod's git tree or crates.io (later). Not sure how the tarball solution will work here.
On Thu, Nov 17, 2022 at 11:55 AM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > On 17-11-22, 11:48, Bartosz Golaszewski wrote: > > Let me propose a different solution. When preparing release tarballs > > with autotools, certain files are generated automatically that go into > > the tarball but are never part of the repository. This way developers > > don't have to deal with the automatically generated files polluting > > the repo while end-users get a tarball with less dependencies and > > reproducible results. > > > > It's called the dist-local hook in automake. > > > > Does it sound like something we could use here? > > These auto-generated bindings are used only by the code present in > bindings/rust/libgpiod/src/, and are never visible to end user code. > > The end user will use the new interface provided by the libgpiod Rust bindings > instead and that works over the web and will be picked from libgpiod's git tree > or crates.io (later). > > Not sure how the tarball solution will work here. > So it already only impacts developers exclusively and not users who'd for example want to install libgpiod from crates.io? If so then I don't really see a reason to keep those files in the repo really. I'm not familiar with rust-vmm containers but the fact that bindgen support is missing or causes problems sounds like a problem with rust-vmm and not users of bindgen, right? Bart
On 17-11-22, 12:05, Bartosz Golaszewski wrote: > So it already only impacts developers exclusively and not users who'd > for example want to install libgpiod from crates.io? If so then I > don't really see a reason to keep those files in the repo really. Users are impacted in the sense that they will be forced to build the bindings using bindgen now, automatically of course. It is an extra, time consuming, operation which can be avoided. For rust-vmm projects, every pull request results in fresh rebuild of the entire crate, which would mean two additional bindgen builds too, just for gpio now. It isn't a huge problem, but it is time that could have been saved. > I'm not familiar with rust-vmm containers but the fact that bindgen > support is missing or causes problems sounds like a problem with > rust-vmm and not users of bindgen, right? Yeah it can be, but IIUC, in the Rust world, more often than not such bindings are pre-generated, as this basically is Rust code only. These bindings will only change if we make a change to the gpiod API. Perhaps that's why I was asked to avoid generating the bindings there, but I can ask again and try fixing the rust-vmm containers if it doesn't work.
On 17-11-22, 12:15, Bartosz Golaszewski wrote:
> So I'd say - just use CC0-1.0 license in Cargo.toml?
The Cargo.toml files already have following currently:
license = "Apache-2.0 OR BSD-3-Clause"
On Thu, Nov 17, 2022 at 12:25 PM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > On 17-11-22, 12:15, Bartosz Golaszewski wrote: > > So I'd say - just use CC0-1.0 license in Cargo.toml? > > The Cargo.toml files already have following currently: > > license = "Apache-2.0 OR BSD-3-Clause" > Then let's just add the SPDX identifier on top to make reuse happy. Bart
On Fri, Nov 18, 2022 at 10:36 AM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > On 17-11-22, 13:18, Bartosz Golaszewski wrote: > > Then let's just add the SPDX identifier on top to make reuse happy. > > This looks fine ? > > diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml > index 4fdf4e06ff90..85abe70b4aa5 100644 > --- a/bindings/rust/Cargo.toml > +++ b/bindings/rust/Cargo.toml > @@ -1,7 +1,12 @@ > +# SPDX-License-Identifier: CC0-1.0 > +# > +# Copyright 2022 Linaro Ltd. All Rights Reserved. > +# Viresh Kumar <viresh.kumar@linaro.org> > + Should be: # SPDX-License-Identifier: CC0-1.0 # SPDX-FileCopyrightText: 2022 Linaro Ltd. # SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org> > [workspace] > > > diff --git a/bindings/rust/libgpiod-sys/README.md b/bindings/rust/libgpiod-sys/README.md > index ecf75b31c41e..567891a30868 100644 > --- a/bindings/rust/libgpiod-sys/README.md > +++ b/bindings/rust/libgpiod-sys/README.md > @@ -1,11 +1,15 @@ > +# SPDX-License-Identifier: CC0-1.0 > +# > +# Copyright 2022 Linaro Ltd. All Rights Reserved. > +# Viresh Kumar <viresh.kumar@linaro.org> > + > # Generated libgpiod-sys Rust FFI bindings > > -- > viresh
On Fri, Nov 18, 2022 at 10:41 AM Viresh Kumar <viresh.kumar@linaro.org> wrote: > > On 18-11-22, 10:38, Bartosz Golaszewski wrote: > > Should be: > > > > # SPDX-License-Identifier: CC0-1.0 > > # SPDX-FileCopyrightText: 2022 Linaro Ltd. > > # SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org> > > For all files ? Or just Cargo.toml and README.md files ? > All files. We're using unified SPFX-FileCopyrightText instead of custom notices. Bart