Skip to content

Commit dcb221a

Browse files
committed
link to nvidia lib only if nvidia feature
it's proprietary, many distributions won't ship it by default. And almost all of our systems don't use nvidia Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 3cf86e7 commit dcb221a

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

framework_lib/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ readonly = [ ]
1818
rusb = ["dep:rusb"]
1919
hidapi = ["dep:hidapi"]
2020
uefi = [ "lazy_static/spin_no_std" ]
21+
nvidia = ["dep:nvml-wrapper"]
2122

2223
[build-dependencies]
2324
built = { version = "0.5", features = ["chrono", "git2"] }
@@ -52,7 +53,7 @@ clap-num = { version = "1.2.0" }
5253
clap-verbosity-flag = { version = "2.2.1" }
5354
windows-version = "0.1.4"
5455
winreg = "0.55.0"
55-
nvml-wrapper = "0.11.0"
56+
nvml-wrapper = { version = "0.11.0", optional = true }
5657

5758
[target.'cfg(unix)'.dependencies]
5859
libc = "0.2.155"
@@ -63,7 +64,7 @@ env_logger = "0.11"
6364
clap = { version = "4.5", features = ["derive", "cargo"] }
6465
clap-num = { version = "1.2.0" }
6566
clap-verbosity-flag = { version = "2.2.1" }
66-
nvml-wrapper = "0.11.0"
67+
nvml-wrapper = { version = "0.11.0", optional = true }
6768

6869
[target.'cfg(windows)'.dependencies.windows]
6970
version = "0.59.0"

framework_lib/src/commandline/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use sha2::{Digest, Sha256, Sha384, Sha512};
7272
//use smbioslib::*;
7373
use smbioslib::{DefinedStruct, SMBiosInformation};
7474

75-
#[cfg(any(target_os = "linux", target_os = "windows"))]
75+
#[cfg(feature = "nvidia")]
7676
use nvml_wrapper::{enum_wrappers::device::TemperatureSensor, Nvml};
7777

7878
use crate::chromium_ec::{CrosEc, CrosEcDriverType, HardwareDeviceType};
@@ -366,8 +366,6 @@ fn print_pd_details(ec: &CrosEc) {
366366
#[cfg(feature = "hidapi")]
367367
const NOT_SET: &str = "NOT SET";
368368

369-
const UNKNOWN: &str = "Unknown";
370-
371369
#[cfg(feature = "rusb")]
372370
fn print_audio_card_details() {
373371
check_synaptics_fw_version();
@@ -773,11 +771,11 @@ fn print_versions(ec: &CrosEc) {
773771
}
774772
}
775773

776-
#[cfg(any(target_os = "linux", target_os = "windows"))]
774+
#[cfg(feature = "nvidia")]
777775
print_nvidia_details();
778776
}
779777

780-
#[cfg(any(target_os = "linux", target_os = "windows"))]
778+
#[cfg(feature = "nvidia")]
781779
fn print_nvidia_details() {
782780
let nvml = match Nvml::init() {
783781
Ok(nvml) => nvml,
@@ -800,18 +798,18 @@ fn print_nvidia_details() {
800798
info!(" BRAND: {:?}", device.brand());
801799
println!(
802800
" Name: {}",
803-
device.name().unwrap_or(UNKNOWN.to_string())
801+
device.name().unwrap_or("Unknown".to_string())
804802
);
805803
println!(" Architecture: {:?}", device.architecture());
806804
println!(
807805
" VBIOS Version: {}",
808-
device.vbios_version().unwrap_or(UNKNOWN.to_string())
806+
device.vbios_version().unwrap_or("Unknown".to_string())
809807
);
810808
println!(
811809
" INFO ROM Ver: {}",
812810
device
813811
.info_rom_image_version()
814-
.unwrap_or(UNKNOWN.to_string())
812+
.unwrap_or("Unknown".to_string())
815813
);
816814
println!(" PCI Info: {:X?}", device.pci_info());
817815
println!(" Performance State:{:?}", device.performance_state());

framework_tool/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ path = "src/main.rs"
1515
[features]
1616
default = [ ]
1717
readonly = [ "framework_lib/readonly" ]
18+
nvidia = [ "framework_lib/nvidia" ]
1819

1920
[dependencies.framework_lib]
2021
path = "../framework_lib"

0 commit comments

Comments
 (0)