Skip to content

Commit 40950b4

Browse files
committed
Allow building without hidapi
Useful for FreeBSD crossbuild, but we also don't have support for it in UEFI right now. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent e80e538 commit 40950b4

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

framework_lib/Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ build = "build.rs"
99
default = ["linux"]
1010
# Linux/FreeBSD
1111
unix = ["std", "raw_pio", "smbios", "dep:nix", "dep:libc"]
12-
linux = ["unix", "linux_pio", "cros_ec_driver"]
13-
freebsd = ["unix", "freebsd_pio"]
12+
linux = ["unix", "linux_pio", "cros_ec_driver", "hidapi"]
13+
freebsd = ["unix", "freebsd_pio", "hidapi"]
14+
cross_freebsd = ["unix", "freebsd_pio"]
1415
# Windows does not have the cros_ec driver nor raw port I/O access to userspace
15-
windows = ["std", "smbios", "dep:windows", "win_driver", "raw_pio"]
16+
windows = ["std", "smbios", "dep:windows", "win_driver", "raw_pio", "hidapi"]
1617
smbios = ["dep:smbios-lib"]
17-
std = ["dep:clap", "dep:clap-verbosity-flag", "dep:env_logger", "smbios-lib?/std", "dep:hidapi", "dep:rusb"]
18+
std = ["dep:clap", "dep:clap-verbosity-flag", "dep:env_logger", "smbios-lib?/std", "dep:rusb"]
19+
hidapi = ["dep:hidapi"]
1820
uefi = [
1921
"dep:plain", "raw_pio", "smbios", "lazy_static/spin_no_std", "dep:uefi", "dep:uefi-services",
2022
# Otherwise I get: `LLVM ERROR: Do not know how to split the result of this operator!`

framework_lib/src/ccgx/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use self::device::{PdController, PdPort};
1111

1212
pub mod binary;
1313
pub mod device;
14-
#[cfg(not(feature = "uefi"))]
14+
#[cfg(feature = "hidapi")]
1515
pub mod hid;
1616

1717
const FW1_METADATA_ROW: u32 = 0x1FE;

framework_lib/src/commandline/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::capsule_content::{
2727
find_bios_version, find_ec_in_bios_cap, find_pd_in_bios_cap, find_retimer_version,
2828
};
2929
use crate::ccgx::device::{PdController, PdPort};
30-
#[cfg(not(feature = "uefi"))]
30+
#[cfg(feature = "hidapi")]
3131
use crate::ccgx::hid::{check_ccg_fw_version, find_devices, DP_CARD_PID, HDMI_CARD_PID};
3232
use crate::ccgx::{self, SiliconId::*};
3333
use crate::chromium_ec;
@@ -48,7 +48,7 @@ use crate::smbios::{dmidecode_string_val, get_smbios, is_framework};
4848
use crate::uefi::enable_page_break;
4949
use crate::util;
5050
use crate::util::Config;
51-
#[cfg(not(feature = "uefi"))]
51+
#[cfg(feature = "hidapi")]
5252
use hidapi::HidApi;
5353
use sha2::{Digest, Sha256, Sha384, Sha512};
5454
//use smbioslib::*;
@@ -197,15 +197,15 @@ fn print_pd_details(ec: &CrosEc) {
197197
print_single_pd_details(&pd_23);
198198
}
199199

200-
#[cfg(not(feature = "uefi"))]
200+
#[cfg(feature = "hidapi")]
201201
const NOT_SET: &str = "NOT SET";
202202

203203
#[cfg(not(feature = "uefi"))]
204204
fn print_audio_card_details() {
205205
check_synaptics_fw_version();
206206
}
207207

208-
#[cfg(not(feature = "uefi"))]
208+
#[cfg(feature = "hidapi")]
209209
fn print_dp_hdmi_details() {
210210
match HidApi::new() {
211211
Ok(api) => {
@@ -270,7 +270,7 @@ fn print_tool_version() {
270270
}
271271

272272
// TODO: Check if HDMI card is same
273-
#[cfg(not(feature = "uefi"))]
273+
#[cfg(feature = "hidapi")]
274274
fn flash_dp_hdmi_card(pd_bin_path: &str) {
275275
let data = match fs::read(pd_bin_path) {
276276
Ok(data) => Some(data),
@@ -616,12 +616,12 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
616616
} else if args.pd_info {
617617
print_pd_details(&ec);
618618
} else if args.dp_hdmi_info {
619-
#[cfg(not(feature = "uefi"))]
619+
#[cfg(feature = "hidapi")]
620620
print_dp_hdmi_details();
621621
} else if let Some(pd_bin_path) = &args.dp_hdmi_update {
622-
#[cfg(not(feature = "uefi"))]
622+
#[cfg(feature = "hidapi")]
623623
flash_dp_hdmi_card(pd_bin_path);
624-
#[cfg(feature = "uefi")]
624+
#[cfg(not(feature = "hidapi"))]
625625
let _ = pd_bin_path;
626626
} else if args.audio_card_info {
627627
#[cfg(not(feature = "uefi"))]

0 commit comments

Comments
 (0)