proxmox-backup-qemu/build.rs
Stefan Reiter f93eb14256 return version via rust fn instead of header define
Otherwise the string gets included in the QEMU binary, not the library.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-11-25 08:27:29 +01:00

33 lines
901 B
Rust

// build.rs
extern crate cbindgen;
use std::env;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let header = std::fs::read_to_string("header-preamble.c").unwrap();
let crate_ver = env!("CARGO_PKG_VERSION");
let git_ver = match option_env!("GITVERSION") {
Some(ver) if !ver.is_empty() => ver,
_ => "UNKNOWN",
};
let version_string = format!(
"{} ({})",
crate_ver,
git_ver,
);
cbindgen::Builder::new()
.with_language(cbindgen::Language::C)
.with_crate(&crate_dir)
.with_header(header)
.with_include_guard("PROXMOX_BACKUP_QEMU_H")
.generate()
.unwrap()
.write_to_file("proxmox-backup-qemu.h");
println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,libproxmox_backup_qemu.so.0");
println!("cargo:rustc-env=PBS_LIB_VERSION={}", version_string);
}