From c2e98dcc9bac66dbec650b7f37ce2edfb5f326eb Mon Sep 17 00:00:00 2001 From: James Mayclin Date: Thu, 2 Jan 2025 11:49:48 -0800 Subject: [PATCH] fix: run install target during build (#273) * fix: run install target during build Signed-off-by: James Mayclin * try ci fix I think it's no longer necessary to append the "Release" path? But that's more of a guess Signed-off-by: James Mayclin * cargo fmt Signed-off-by: James Mayclin --------- Signed-off-by: James Mayclin --- oqs-sys/build.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/oqs-sys/build.rs b/oqs-sys/build.rs index 10445a08e5..f093370673 100644 --- a/oqs-sys/build.rs +++ b/oqs-sys/build.rs @@ -113,12 +113,21 @@ fn build_from_source() -> PathBuf { config.define(permit_unsupported, str); } - let outdir = config.build_target("oqs").build(); + // build the default (install) target. + let outdir = config.build(); + + // remove the build folder + let temp_build = outdir.join("build"); + if let Err(e) = std::fs::remove_dir_all(temp_build) { + println!( + "cargo:warning=unexpected error while cleaning build files:{}", + e + ); + } - // lib is put into $outdir/build/lib - let mut libdir = outdir.join("build").join("lib"); + // lib is installed to $outdir/lib + let libdir = outdir.join("lib"); if cfg!(windows) { - libdir.push("Release"); // Static linking doesn't work on Windows println!("cargo:rustc-link-lib=oqs"); } else { @@ -132,7 +141,7 @@ fn build_from_source() -> PathBuf { fn includedir_from_source() -> PathBuf { let outdir = build_from_source(); - outdir.join("build").join("include") + outdir.join("include") } fn probe_includedir() -> PathBuf {