Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ jobs:
- name: Verify package
run: cargo package --no-default-features --features linux-native --verbose

build-linux-native-basic-udev:
runs-on: ubuntu-latest
env:
DEBIAN_FRONTEND: noninteractive
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libudev-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --no-default-features --features linux-native-basic-udev --verbose
- name: Run tests
run: cargo test --no-default-features --features linux-native-basic-udev --verbose
- name: Verify package
run: cargo package --no-default-features --features linux-native-basic-udev --verbose

build-windows:
runs-on: windows-latest
steps:
Expand Down Expand Up @@ -121,6 +143,22 @@ jobs:
- name: Verify package
run: cargo package --no-default-features --features windows-native --verbose

build-linux-on-windows:
runs-on: windows-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Linux target
run: rustup target add arm-unknown-linux-musleabihf
- name: Build
run: cargo build --target arm-unknown-linux-musleabihf --no-default-features --features linux-native-basic-udev --verbose
- name: Verify package
run: cargo package --target arm-unknown-linux-musleabihf --no-default-features --features linux-native-basic-udev --verbose

build-macos:
runs-on: macos-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ linux-static-hidraw = []
linux-shared-libusb = []
linux-shared-hidraw = []
linux-native = ["dep:udev", "dep:nix"]
linux-native-basic-udev = ["dep:basic-udev", "dep:nix"]
illumos-static-libusb = []
illumos-shared-libusb = []
macos-shared-device = []
Expand All @@ -69,6 +70,7 @@ cfg-if = "1"

[target.'cfg(target_os = "linux")'.dependencies]
udev = { version = "0.8", optional = true }
basic-udev = { version = "0.1", optional = true }
nix = { version = "0.27", optional = true, features = ["fs", "ioctl", "poll"] }

[target.'cfg(windows)'.dependencies]
Expand Down
11 changes: 10 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn compile_linux() {
// First check the features enabled for the crate.
// Only one linux backend should be enabled at a time.

let avail_backends: [(&'static str, Box<dyn Fn()>); 5] = [
let avail_backends: [(&'static str, Box<dyn Fn()>); 6] = [
(
"LINUX_STATIC_HIDRAW",
Box::new(|| {
Expand Down Expand Up @@ -106,6 +106,15 @@ fn compile_linux() {
// The udev crate takes care of finding its library
}),
),
(
"LINUX_NATIVE_BASIC_UDEV",
Box::new(|| {
// Enable `feature="linux-native"` to reuse the existing
// linux-native code. It is considered an error in
// basic-udev if this fails to compile.
println!("cargo:rustc-cfg=feature=\"linux-native\"");
}),
),
];

let mut backends = avail_backends
Expand Down
3 changes: 3 additions & 0 deletions src/linux_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
mod ioctl;

#[cfg(feature = "linux-native-basic-udev")]
use basic_udev as udev;

use std::{
cell::{Cell, Ref, RefCell},
ffi::{CStr, CString, OsStr, OsString},
Expand Down