Make GPU support optional to enable RISC-V builds without libdrm
- Add 'gpu' feature flag (enabled by default) - Make gfxinfo dependency optional - Provide no-op GPU metrics when gpu feature disabled - Disable GPU support for RISC-V builds in CI (libdrm unavailable) - All other architectures (amd64, arm64, armhf) still get GPU support
This commit is contained in:
parent
512913e897
commit
f9462a1633
8
.github/workflows/build-deb.yml
vendored
8
.github/workflows/build-deb.yml
vendored
@ -115,10 +115,16 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cargo deb --package socktop --target ${{ matrix.target }} --no-strip
|
cargo deb --package socktop --target ${{ matrix.target }} --no-strip
|
||||||
|
|
||||||
- name: Build socktop_agent .deb package
|
- name: Build socktop_agent .deb package (with GPU support)
|
||||||
|
if: matrix.target != 'riscv64gc-unknown-linux-gnu'
|
||||||
run: |
|
run: |
|
||||||
cargo deb --package socktop_agent --target ${{ matrix.target }} --no-strip
|
cargo deb --package socktop_agent --target ${{ matrix.target }} --no-strip
|
||||||
|
|
||||||
|
- name: Build socktop_agent .deb package (without GPU support for RISC-V)
|
||||||
|
if: matrix.target == 'riscv64gc-unknown-linux-gnu'
|
||||||
|
run: |
|
||||||
|
cargo deb --package socktop_agent --target ${{ matrix.target }} --no-strip --no-default-features
|
||||||
|
|
||||||
- name: Copy packages to debs directory
|
- name: Copy packages to debs directory
|
||||||
run: |
|
run: |
|
||||||
mkdir -p debs
|
mkdir -p debs
|
||||||
|
|||||||
@ -23,7 +23,7 @@ flate2 = { version = "1", default-features = false, features = ["rust_backend"]
|
|||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
tracing = { version = "0.1", optional = true }
|
tracing = { version = "0.1", optional = true }
|
||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true }
|
||||||
gfxinfo = "0.1.2"
|
gfxinfo = { version = "0.1.2", optional = true }
|
||||||
once_cell = "1.19"
|
once_cell = "1.19"
|
||||||
axum-server = { version = "0.7", features = ["tls-rustls"] }
|
axum-server = { version = "0.7", features = ["tls-rustls"] }
|
||||||
rustls = { version = "0.23", features = ["aws-lc-rs"] }
|
rustls = { version = "0.23", features = ["aws-lc-rs"] }
|
||||||
@ -35,7 +35,8 @@ prost = { workspace = true }
|
|||||||
time = { version = "0.3", default-features = false, features = ["formatting", "macros", "parsing" ] }
|
time = { version = "0.3", default-features = false, features = ["formatting", "macros", "parsing" ] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = ["gpu"]
|
||||||
|
gpu = ["gfxinfo"]
|
||||||
logging = ["tracing", "tracing-subscriber"]
|
logging = ["tracing", "tracing-subscriber"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
// gpu.rs
|
// gpu.rs
|
||||||
|
#[cfg(feature = "gpu")]
|
||||||
use gfxinfo::active_gpu;
|
use gfxinfo::active_gpu;
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize)]
|
#[derive(Debug, Clone, serde::Serialize)]
|
||||||
@ -9,6 +10,7 @@ pub struct GpuMetrics {
|
|||||||
pub mem_total_bytes: u64,
|
pub mem_total_bytes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gpu")]
|
||||||
pub fn collect_all_gpus() -> Result<Vec<GpuMetrics>, Box<dyn std::error::Error>> {
|
pub fn collect_all_gpus() -> Result<Vec<GpuMetrics>, Box<dyn std::error::Error>> {
|
||||||
let gpu = active_gpu()?; // Use ? to unwrap Result
|
let gpu = active_gpu()?; // Use ? to unwrap Result
|
||||||
let info = gpu.info();
|
let info = gpu.info();
|
||||||
@ -22,3 +24,9 @@ pub fn collect_all_gpus() -> Result<Vec<GpuMetrics>, Box<dyn std::error::Error>>
|
|||||||
|
|
||||||
Ok(vec![metrics])
|
Ok(vec![metrics])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "gpu"))]
|
||||||
|
pub fn collect_all_gpus() -> Result<Vec<GpuMetrics>, Box<dyn std::error::Error>> {
|
||||||
|
// GPU support not available on this platform
|
||||||
|
Ok(vec![])
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user