Skip to content

Commit a178c5a

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 7adba91 commit a178c5a

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"] }
@@ -51,7 +52,7 @@ clap = { version = "4.5", features = ["derive", "cargo"] }
5152
clap-num = { version = "1.2.0" }
5253
clap-verbosity-flag = { version = "2.2.1" }
5354
windows-version = "0.1.4"
54-
nvml-wrapper = "0.11.0"
55+
nvml-wrapper = { version = "0.11.0", optional = true }
5556

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

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

framework_lib/src/commandline/mod.rs

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

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

7575
use crate::chromium_ec::{CrosEc, CrosEcDriverType, HardwareDeviceType};
@@ -357,8 +357,6 @@ fn print_pd_details(ec: &CrosEc) {
357357
#[cfg(feature = "hidapi")]
358358
const NOT_SET: &str = "NOT SET";
359359

360-
const UNKNOWN: &str = "Unknown";
361-
362360
#[cfg(feature = "rusb")]
363361
fn print_audio_card_details() {
364362
check_synaptics_fw_version();
@@ -728,11 +726,11 @@ fn print_versions(ec: &CrosEc) {
728726
#[cfg(feature = "hidapi")]
729727
print_dp_hdmi_details(false);
730728

731-
#[cfg(any(target_os = "linux", target_os = "windows"))]
729+
#[cfg(feature = "nvidia")]
732730
print_nvidia_details();
733731
}
734732

735-
#[cfg(any(target_os = "linux", target_os = "windows"))]
733+
#[cfg(feature = "nvidia")]
736734
fn print_nvidia_details() {
737735
let nvml = match Nvml::init() {
738736
Ok(nvml) => nvml,
@@ -755,18 +753,18 @@ fn print_nvidia_details() {
755753
info!(" BRAND: {:?}", device.brand());
756754
println!(
757755
" Name: {}",
758-
device.name().unwrap_or(UNKNOWN.to_string())
756+
device.name().unwrap_or("Unknown".to_string())
759757
);
760758
println!(" Architecture: {:?}", device.architecture());
761759
println!(
762760
" VBIOS Version: {}",
763-
device.vbios_version().unwrap_or(UNKNOWN.to_string())
761+
device.vbios_version().unwrap_or("Unknown".to_string())
764762
);
765763
println!(
766764
" INFO ROM Ver: {}",
767765
device
768766
.info_rom_image_version()
769-
.unwrap_or(UNKNOWN.to_string())
767+
.unwrap_or("Unknown".to_string())
770768
);
771769
println!(" PCI Info: {:X?}", device.pci_info());
772770
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)