Skip to content

Commit 9a5e8c4

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 <[email protected]>
1 parent 69d1380 commit 9a5e8c4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

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};
@@ -360,8 +360,6 @@ fn print_pd_details(ec: &CrosEc) {
360360
#[cfg(feature = "hidapi")]
361361
const NOT_SET: &str = "NOT SET";
362362

363-
const UNKNOWN: &str = "Unknown";
364-
365363
#[cfg(feature = "rusb")]
366364
fn print_audio_card_details() {
367365
check_synaptics_fw_version();
@@ -762,11 +760,11 @@ fn print_versions(ec: &CrosEc) {
762760
}
763761
}
764762

765-
#[cfg(any(target_os = "linux", target_os = "windows"))]
763+
#[cfg(feature = "nvidia")]
766764
print_nvidia_details();
767765
}
768766

769-
#[cfg(any(target_os = "linux", target_os = "windows"))]
767+
#[cfg(feature = "nvidia")]
770768
fn print_nvidia_details() {
771769
let nvml = match Nvml::init() {
772770
Ok(nvml) => nvml,
@@ -789,18 +787,18 @@ fn print_nvidia_details() {
789787
info!(" BRAND: {:?}", device.brand());
790788
println!(
791789
" Name: {}",
792-
device.name().unwrap_or(UNKNOWN.to_string())
790+
device.name().unwrap_or("Unknown".to_string())
793791
);
794792
println!(" Architecture: {:?}", device.architecture());
795793
println!(
796794
" VBIOS Version: {}",
797-
device.vbios_version().unwrap_or(UNKNOWN.to_string())
795+
device.vbios_version().unwrap_or("Unknown".to_string())
798796
);
799797
println!(
800798
" INFO ROM Ver: {}",
801799
device
802800
.info_rom_image_version()
803-
.unwrap_or(UNKNOWN.to_string())
801+
.unwrap_or("Unknown".to_string())
804802
);
805803
println!(" PCI Info: {:X?}", device.pci_info());
806804
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)