Skip to content

Conversation

@xobs
Copy link
Contributor

@xobs xobs commented Mar 9, 2025

Add a new feature, linux-native-basic-udev. This is identical to linux-native but uses basic-udev as a udev source rather than udev-rs.

basic-udev is a reimplementation of just enough udev functionality to support device discovery on most common platforms without needing to link libudev.so.

As a result, it becomes possible to cross-compile crates that depend on hidapi-rs to Linux (both GNU and Musl) without needing a full sysroot. This greatly simplifies cross-compiling to multiple target architectures, particularly when using cargo-zigbuild.

Avoid having to rely on libudev, which makes this crate difficult to
cross-compile. Instead, traverse `/sys` directly to discover what it is we
need.

Signed-off-by: Sean Cross <[email protected]>
@xobs xobs force-pushed the add-basic-udev-option branch 2 times, most recently from 54732a2 to ada8041 Compare March 9, 2025 05:40
Copy link
Owner

@ruabmbua ruabmbua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. If you want I can make small fixes myself after merging, or you can do it yourself.

Add an alternative to `libudev-sys` that doesn't require pkgconfig. This
allows for cross-compiling to Linux without first obtaining a sysroot for
the target. It also allows for compiling to musl, and statically-linking
projects that use hidapi.

Signed-off-by: Sean Cross <[email protected]>
@xobs xobs force-pushed the add-basic-udev-option branch from ada8041 to 1310a6b Compare March 17, 2025 04:29
Build linux-native-basic-udev as part of CI. Build it on both Linux native,
as well as on Windows to verify that cross-compiling works.

Signed-off-by: Sean Cross <[email protected]>
@xobs xobs force-pushed the add-basic-udev-option branch from 1310a6b to 7c67945 Compare March 18, 2025 01:29
@ruabmbua ruabmbua merged commit 260a100 into ruabmbua:main Mar 18, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants