mirror of
https://codeberg.org/Toasterson/solstice-ci.git
synced 2026-04-10 21:30:41 +00:00
15 lines
872 B
Rust
15 lines
872 B
Rust
|
|
fn main() {
|
||
|
|
// Only emit link directive for libvirt when building on Linux and the `libvirt` feature is enabled.
|
||
|
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||
|
|
let libvirt_enabled = std::env::var("CARGO_FEATURE_LIBVIRT").is_ok();
|
||
|
|
|
||
|
|
if target_os == "linux" && libvirt_enabled {
|
||
|
|
// Ensure the final link includes -lvirt. The virt crate should do this via bindgen/pkg-config,
|
||
|
|
// but in some minimal containers the link directive may be missing. This is a safe no-op if
|
||
|
|
// already present and fixes undefined references like virConnectOpen, virDomainDefineXML, etc.
|
||
|
|
println!("cargo:rustc-link-lib=virt");
|
||
|
|
// On Debian/Ubuntu the library resides in /usr/lib/{arch}-linux-gnu which the linker knows.
|
||
|
|
// If custom locations are ever needed, also emit cargo:rustc-link-search here.
|
||
|
|
}
|
||
|
|
}
|