Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add LIBOQS_NO_VENDOR env variable #238

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ By default `oqs-sys` attempts to find a system-provided version of `liboqs` and
falling back to vendored from-source build otherwise.
You can opt into forcing the vendored build by enabling the `vendored` feature.

Otherwise, if you want to force using the system-provided `liboqs`,
you can set the `LIBOQS_NO_VENDOR=1` environment variable and the build will fail if the library is not found.

Serde support
-------------

Expand Down
11 changes: 10 additions & 1 deletion oqs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ fn probe_includedir() -> PathBuf {
return includedir_from_source();
}

println!("cargo:rerun-if-env-changed=LIBOQS_NO_VENDOR");
let force_no_vendor = std::env::var_os("LIBOQS_NO_VENDOR").map_or(false, |v| v != "0");

let major_version: usize = env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap();
let minor_version: usize = env!("CARGO_PKG_VERSION_MINOR").parse().unwrap();
let patch_version = env!("CARGO_PKG_VERSION_PATCH");
Expand All @@ -148,7 +151,13 @@ fn probe_includedir() -> PathBuf {

match config {
Ok(lib) => lib.include_paths.first().cloned().unwrap(),
_ => includedir_from_source(),
_ => {
if force_no_vendor {
panic!("The env variable LIBOQS_NO_VENDOR has been set but a suitable system liboqs could not be found.");
}

includedir_from_source()
}
}
}

Expand Down