Skip to content

Commit

Permalink
spdm-utils: add build system support
Browse files Browse the repository at this point in the history
This can be used by external build-system to compile spdm-utils
correctly.

Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
  • Loading branch information
twilfredo authored and alistair23 committed Feb 23, 2024
1 parent b49bb7a commit 07d62b7
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
println!("cargo:rustc-link-arg=-lspdm_transport_mctp_lib");

// Link SPDM Test Libraries
let builder = if cfg!(libspdm_tests) {
let mut builder = if cfg!(libspdm_tests) {
println!("cargo:rustc-link-arg=-lcommon_test_utility_lib");
println!("cargo:rustc-link-arg=-lspdm_responder_conformance_test_lib");

Expand All @@ -55,10 +55,20 @@ fn main() {
.clang_arg("-Ithird-party/libspdm")
};

println!("cargo:rustc-link-search=third-party/libspdm/build/lib/");
#[cfg(libspdm_tests)]
{
println!("cargo:rustc-link-search=third-party/SPDM-Responder-Validator/build/lib/");
if let Ok(sysroot) = env::var("STAGING_DIR") {
let sysroot_arg = format!("--sysroot={sysroot}");
builder = builder.clang_arg(sysroot_arg);

let include_arg = format!("-I{sysroot}/usr/include/libspdm");
builder = builder.clang_arg(include_arg);

println!("cargo:rustc-link-search={sysroot}/usr/lib/");
} else {
println!("cargo:rustc-link-search=third-party/libspdm/build/lib/");
#[cfg(libspdm_tests)]
{
println!("cargo:rustc-link-search=third-party/SPDM-Responder-Validator/build/lib/");
}
}

let bindings = builder
Expand Down

0 comments on commit 07d62b7

Please sign in to comment.