5e82aac4f8
It consists of two main steps:
1. Generating Bindings with `bindgen`:
- The `build.rs` script uses `bindgen` to generate Rust FFI (Foreign
Function Interface) bindings for the AMD SMI C library. This step
automatically exports all enums, structs, unions, and unsafe functions
from the C library into Rust. This provides a comprehensive low-level
interface to the AMD SMI library.
2. Implementing Safe Rust Wrappers:
- The generated bindings are then wrapped in safe Rust functions. These
safe wrappers handle error checking, resource management, and provide a
more idiomatic Rust interface. This ensures that users of the library
can interact with the AMD SMI functions without dealing with unsafe code
directly.
Change-Id: I7d5e49e59826164fc911ced04ef7ca5706b7cc05
Signed-off-by: Tim Huang <tim.huang@amd.com>
[ROCm/amdsmi commit: d32f2a109a]
31 行
676 B
TOML
31 行
676 B
TOML
[package]
|
|
name = "amdsmi"
|
|
version = "0.1.1"
|
|
edition = "2021"
|
|
description = "A rust binding for the AMD System Management Interface (AMD-SMI) library"
|
|
repository = "https://github.com/ROCm/amdsmi/rust-interface"
|
|
readme = "README.md"
|
|
keywords = ["amdsmi", "rust binding"]
|
|
license = "Copyright (c) 2019-2024 Advanced Micro Devices, Inc"
|
|
|
|
[build-dependencies]
|
|
bindgen = "0.70.1"
|
|
|
|
[lib]
|
|
name = "amdsmi"
|
|
path = "src/lib.rs"
|
|
|
|
[[example]]
|
|
name = "amdsmi_get_gpu_info"
|
|
crate-type = ["bin"]
|
|
|
|
[[example]]
|
|
name = "amdsmi_exporter"
|
|
crate-type = ["bin"]
|
|
|
|
[dev-dependencies]
|
|
prometheus-client = "0.22.3"
|
|
axum = "0.5"
|
|
hyper = "0.14"
|
|
clap = "3.0"
|
|
tokio = { version = "1", features = ["full"] } |