Skip to content

Commit 90c01b2

Browse files
committed
Allow to switch off OpenSSL
1 parent a339865 commit 90c01b2

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

oqs-sys/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ edition = "2018"
1111
[build-dependencies]
1212
cmake = "0.1"
1313
bindgen = "0.53"
14+
15+
[features]
16+
default = ["openssl"]
17+
openssl = []

oqs-sys/build.rs

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
use cmake;
21
use bindgen;
2+
use cmake;
33

44
use std::path::PathBuf;
55

66
fn generate_bindings(outdir: &PathBuf, headerfile: &str, filter: &str) {
77
let includedir = outdir.join("build").join("include");
88
bindgen::Builder::default()
99
.clang_arg(format!("-I{}", includedir.display()))
10-
.header(includedir.join("oqs").join(format!("{}.h", headerfile)).to_str().unwrap())
10+
.header(
11+
includedir
12+
.join("oqs")
13+
.join(format!("{}.h", headerfile))
14+
.to_str()
15+
.unwrap(),
16+
)
1117
// Tell cargo to invalidate the built crate whenever any of the
1218
// included header files changed.
1319
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
1420
// Options
15-
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false })
21+
.default_enum_style(bindgen::EnumVariation::Rust {
22+
non_exhaustive: false,
23+
})
1624
.size_t_is_usize(true)
1725
// Whitelist OQS stuff
1826
.whitelist_recursively(false)
@@ -24,15 +32,21 @@ fn generate_bindings(outdir: &PathBuf, headerfile: &str, filter: &str) {
2432
// Unwrap the Result and panic on failure.
2533
.expect("Unable to generate bindings")
2634
.write_to_file(outdir.join(format!("{}_bindings.rs", headerfile)))
27-
2835
.expect("Couldn't write bindings!");
2936
}
3037

3138
fn main() {
32-
let outdir = cmake::Config::new("liboqs")
33-
.profile("Optimized")
34-
.build_target("oqs")
35-
.build();
39+
let mut config = cmake::Config::new("liboqs");
40+
config.profile("Optimized");
41+
config.define(
42+
"OQS_USE_OPENSSL",
43+
if cfg!(feature = "openssl") {
44+
"Yes"
45+
} else {
46+
"No"
47+
},
48+
);
49+
let outdir = config.build_target("oqs").build();
3650

3751
// lib is put into $outdir/build/lib
3852
let libdir = outdir.join("build").join("lib");

oqs-sys/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#[allow(non_upper_case_globals)]
32
#[allow(non_camel_case_types)]
43
#[allow(non_snake_case)]

0 commit comments

Comments
 (0)