linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Erik Schilling" <erik.schilling@linaro.org>
To: "Kent Gibson" <warthog618@gmail.com>
Cc: "Viresh Kumar" <viresh.kumar@linaro.org>,
	<linux-gpio@vger.kernel.org>,
	"Bartosz Golaszewski" <brgl@bgdev.pl>
Subject: Re: [libgpiod][bug] building rust bindings requires clang headers
Date: Mon, 12 Jun 2023 13:16:09 +0200	[thread overview]
Message-ID: <CTAMNSQLDDKK.3Q7FW6IVJQ26U@fedora> (raw)
In-Reply-To: <ZIbJ9yM9zdfcj0kO@sol>

> > Setting PKG_CONFIG_PATH will only work if you point it at the install
> > folder of libgpiod.
>
> Correct - that is exactly what I did.
>
> > If you do not want to install, you will need to set
>
> Yeah, I don't install on my dev machine - I deploy to separate machines
> for testing.  For dev I just want to be able to use the same workflow I
> would use for a general rust project, so cargo XXX, and purely in the
> code tree.  At least that is what I was doing previously.

I agree that there is _some_ friction, but I did not come up with a way
to preserve the old behavior without the risk of being confusing for
consumers of the lib (or even people attempting to compile things where
libgpiod-sys is just a transitive dependency).

The current solution mostly resembles how most of the Rust bindings
that I know work. But I acknowledge that those bindings are usually
developed in repositories separate from the underlying lib. Are there
good examples how other libs are solving this problem?

> > See https://lore.kernel.org/r/20230522-crates-io-v2-2-d8de75e7f584@linaro.org/
> > on why it had to become a little bit ugly for rust bindings hackers.
>
> I understand why you might be changing things to be able to package the
> crates, but in an ideal world that wouldn't impact normal workflow.
> Or it would be simple to switch.

I fear the ideal world where there is no impact may be hard to achieve.
When building with make, we _know_ that the C lib is also built, but
when building from cargo, there is no good way (that I know of) to
differ between a build that just happens because someone is building
from crates.io or a developer invoking cargo sub-commands. Ideally, a
build from local source should also show identical behavior compared to
a build from the registry.

Also, we will (at least in the future) need an easy way to build against
different versions of the C lib. For me the easiest way seems to be to
install different libgpiod versions to some non-system path and then
use PKG_CONFIG_PATH to switch... That just allows us to use standard
mechanisms without requiring to reinvent any wheels.

> > Maybe we should put that example back to the README.md (or into the top-
> > level README?)
> > 
>
> Sounds like a plan to me.  I would go with the rust specific README.
> Or add a file that can be sourced to setup the build environment to get
> cargo working from the command line.

I started with the README. Sent as part of my series of last crates.io
publishing tweaks:

https://lore.kernel.org/r/20230612-crates_io_publish-v1-0-70988ee9a655@linaro.org

- Erik

      reply	other threads:[~2023-06-12 11:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09  2:37 [libgpiod][bug] building rust bindings requires clang headers Kent Gibson
2023-06-09  6:18 ` Viresh Kumar
2023-06-09  6:21   ` Kent Gibson
2023-06-09  6:24     ` Viresh Kumar
2023-06-10  5:27       ` Kent Gibson
2023-06-12  5:26         ` Erik Schilling
2023-06-12  7:32           ` Kent Gibson
2023-06-12 11:16             ` Erik Schilling [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CTAMNSQLDDKK.3Q7FW6IVJQ26U@fedora \
    --to=erik.schilling@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).