-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
krun-sys: find libkrun using pkg-config
This enables the use of non-system-wide installations of libkrun by exporting the right PKG_CONFIG_PATH. Signed-off-by: Sergio Lopez <[email protected]>
- Loading branch information
Showing
3 changed files
with
16 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
fn main() -> Result<(), pkg_config::Error> { | ||
println!("cargo::rerun-if-changed=wrapper.h"); | ||
println!("cargo::rustc-link-lib=krun"); | ||
|
||
let library = pkg_config::probe_library("libkrun")?; | ||
|
||
let bindings = bindgen::Builder::default() | ||
.header("wrapper.h") | ||
.clang_args( | ||
library | ||
.include_paths | ||
.iter() | ||
.map(|path| format!("-I{}", path.to_string_lossy())), | ||
) | ||
.clang_arg("-fretain-comments-from-system-headers") | ||
.header("wrapper.h") | ||
.generate() | ||
.expect("Unable to generate bindings"); | ||
|
||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
bindings | ||
.write_to_file(out_path.join("bindings.rs")) | ||
.expect("Couldn't write bindings!"); | ||
|
||
Ok(()) | ||
} |