Skip to content

Commit

Permalink
allow empty CROSS_DEB_ARCH
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Nov 21, 2023
1 parent 7911e60 commit f40bf2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ codegen-units = 1 # quicker binary, slower build
[package.metadata.cross.build]
pre-build = ["dpkg --add-architecture $CROSS_DEB_ARCH && apt-get update && apt-get install --assume-yes libusb-1.0-0-dev:$CROSS_DEB_ARCH libudev-dev:$CROSS_DEB_ARCH"]

[package.metadata.cross.target.x86_64-unknown-linux-gnu]
pre-build = ["apt-get update && apt-get install --assume-yes libusb-1.0-0-dev libudev-dev"]

[package.metadata.deb]
section = "utility"
2 changes: 1 addition & 1 deletion src/lsusb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ pub mod names {
#[allow(unused_variables)]
fn hwdb_get(modalias: &str, key: &'static str) -> Result<Option<String>, Error> {
#[cfg(all(target_os = "linux", feature = "udev_hwdb"))]
return crate::udev::hwdb::hwdb_get(modalias, key);
return crate::udev::hwdb::get(modalias, key);

#[cfg(not(all(target_os = "linux", feature = "udev_hwdb")))]
return Err(Error::new(
Expand Down
10 changes: 5 additions & 5 deletions src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ pub mod hwdb {
/// Should act like https://github.com/gregkh/usbutils/blob/master/names.c#L115
///
/// ```
/// use cyme::udev::hwdb_get;
/// use cyme::udev;
///
/// let modalias = "usb:v1D6Bp0001";
/// let vendor = hwdb_get(&modalias, "ID_VENDOR_FROM_DATABASE").unwrap();
/// let vendor = hwdb::get(&modalias, "ID_VENDOR_FROM_DATABASE").unwrap();
///
/// assert_eq!(vendor, Some("Linux Foundation".into()));
///
/// let modalias = "usb:v*p*d*dc03dsc01dp01*";
/// let vendor = hwdb_get(&modalias, "ID_USB_PROTOCOL_FROM_DATABASE").unwrap();
/// let vendor = hwdb::get(&modalias, "ID_USB_PROTOCOL_FROM_DATABASE").unwrap();
///
/// assert_eq!(vendor, Some("Keyboard".into()));
/// ```
pub fn hwdb_get(modalias: &str, key: &'static str) -> Result<Option<String>, Error> {
pub fn get(modalias: &str, key: &'static str) -> Result<Option<String>, Error> {
let hwdb = udevlib::Hwdb::new().map_err(|e| {
Error::new(
ErrorKind::Udev,
Expand Down Expand Up @@ -180,7 +180,7 @@ mod tests {
}

/// Tests can lookup bInterfaceClass of the root hub, which is always 09
#[cfg_attr(not(feature = "usb_test", feature = "udev_hwdb"), ignore)]
#[cfg_attr(not(feature = "usb_test"), ignore)]
#[test]
fn test_udev_attribute() {
let interface_class = get_udev_attribute("1-0:1.0", "bInterfaceClass").unwrap();
Expand Down

0 comments on commit f40bf2c

Please sign in to comment.