1
- use cmake;
2
1
use bindgen;
2
+ use cmake;
3
3
4
4
use std:: path:: PathBuf ;
5
5
6
6
fn generate_bindings ( outdir : & PathBuf , headerfile : & str , filter : & str ) {
7
7
let includedir = outdir. join ( "build" ) . join ( "include" ) ;
8
8
bindgen:: Builder :: default ( )
9
9
. 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
+ )
11
17
// Tell cargo to invalidate the built crate whenever any of the
12
18
// included header files changed.
13
19
. parse_callbacks ( Box :: new ( bindgen:: CargoCallbacks ) )
14
20
// Options
15
- . default_enum_style ( bindgen:: EnumVariation :: Rust { non_exhaustive : false } )
21
+ . default_enum_style ( bindgen:: EnumVariation :: Rust {
22
+ non_exhaustive : false ,
23
+ } )
16
24
. size_t_is_usize ( true )
17
25
// Whitelist OQS stuff
18
26
. whitelist_recursively ( false )
@@ -24,15 +32,21 @@ fn generate_bindings(outdir: &PathBuf, headerfile: &str, filter: &str) {
24
32
// Unwrap the Result and panic on failure.
25
33
. expect ( "Unable to generate bindings" )
26
34
. write_to_file ( outdir. join ( format ! ( "{}_bindings.rs" , headerfile) ) )
27
-
28
35
. expect ( "Couldn't write bindings!" ) ;
29
36
}
30
37
31
38
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 ( ) ;
36
50
37
51
// lib is put into $outdir/build/lib
38
52
let libdir = outdir. join ( "build" ) . join ( "lib" ) ;
0 commit comments