Skip to content

Commit

Permalink
Allow building with rusb
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Jul 31, 2024
1 parent 1709d23 commit 6d71f32
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ Keyboard backlight: 0%
sudo pkg install hidapi
# Build the library and tool
cargo build --no-default-features --features freebsd
cargo build --no-default-features --features freebsd rusb
# Running the tool
cargo run --no-default-features --features freebsd
cargo run --no-default-features --features freebsd rusb
```
7 changes: 4 additions & 3 deletions framework_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ build = "build.rs"
default = ["linux"]
# Linux/FreeBSD
unix = ["std", "raw_pio", "smbios", "dep:nix", "dep:libc"]
linux = ["unix", "linux_pio", "cros_ec_driver", "hidapi"]
linux = ["unix", "linux_pio", "cros_ec_driver", "hidapi", "rusb"]
freebsd = ["unix", "freebsd_pio", "hidapi"]
cross_freebsd = ["unix", "freebsd_pio"]
# Windows does not have the cros_ec driver nor raw port I/O access to userspace
windows = ["std", "smbios", "dep:windows", "win_driver", "raw_pio", "hidapi"]
windows = ["std", "smbios", "dep:windows", "win_driver", "raw_pio", "hidapi", "rusb"]
smbios = ["dep:smbios-lib"]
std = ["dep:clap", "dep:clap-verbosity-flag", "dep:env_logger", "smbios-lib?/std", "dep:rusb"]
std = ["dep:clap", "dep:clap-verbosity-flag", "dep:env_logger", "smbios-lib?/std"]
rusb = ["dep:rusb"]
hidapi = ["dep:hidapi"]
uefi = [
"dep:plain", "raw_pio", "smbios", "lazy_static/spin_no_std", "dep:uefi", "dep:uefi-services",
Expand Down
6 changes: 3 additions & 3 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::fs;
#[cfg(all(not(feature = "uefi"), feature = "std"))]
use std::io::prelude::*;

#[cfg(not(feature = "uefi"))]
#[cfg(feature = "rusb")]
use crate::audio_card::check_synaptics_fw_version;
use crate::built_info;
use crate::capsule;
Expand Down Expand Up @@ -200,7 +200,7 @@ fn print_pd_details(ec: &CrosEc) {
#[cfg(feature = "hidapi")]
const NOT_SET: &str = "NOT SET";

#[cfg(not(feature = "uefi"))]
#[cfg(feature = "rusb")]
fn print_audio_card_details() {
check_synaptics_fw_version();
}
Expand Down Expand Up @@ -624,7 +624,7 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
#[cfg(not(feature = "hidapi"))]
let _ = pd_bin_path;
} else if args.audio_card_info {
#[cfg(not(feature = "uefi"))]
#[cfg(feature = "rusb")]
print_audio_card_details();
} else if args.privacy {
if let Some((mic, cam)) = print_err(ec.get_privacy_info()) {
Expand Down
2 changes: 1 addition & 1 deletion framework_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate lazy_static;
#[macro_use]
extern crate log;

#[cfg(not(feature = "uefi"))]
#[cfg(feature = "rusb")]
pub mod audio_card;

#[cfg(feature = "uefi")]
Expand Down
2 changes: 1 addition & 1 deletion framework_lib/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] {
}

/// Convert any type to a mut u8 slice (Like a C byte buffer)
#[cfg(not(feature = "uefi"))]
#[cfg(feature = "rusb")]
pub unsafe fn any_as_mut_u8_slice<T: Sized>(p: &mut T) -> &mut [u8] {
let len = ::std::mem::size_of::<T>();
::std::slice::from_raw_parts_mut((p as *mut T) as *mut u8, len)
Expand Down

0 comments on commit 6d71f32

Please sign in to comment.