-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
44 lines (39 loc) · 1.32 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! This is the main function for the build script.
//!
//! Currently, it only instructs Cargo to re-run this build script if `build.rs` is changed.
#[rustfmt::skip]
fn main() {
#[cfg(not(feature = "wasm"))]
{
#[cfg(feature = "avx2")]
{
const FILES: [&str; 5] = ["basemul", "fq", "invntt", "ntt", "shuffle"];
#[cfg(feature = "nasm")]
{
const ROOT: &str = "src/avx2/nasm/";
let paths = FILES.iter().map(|file| format!("{}{}.asm", ROOT, file));
let mut nasm = nasm_rs::Build::new();
let mut linker = cc::Build::new();
nasm.files(paths);
nasm.include(ROOT);
for o in nasm.compile_objects().expect("
Compiling NASM files:
Ensure it is installed and in your path
https://www.nasm.us/",
) {
linker.object(o);
}
linker.compile("kyberlib");
}
#[cfg(not(feature = "nasm"))]
{
const ROOT: &str = "src/avx2/";
let paths = FILES.iter().map(|file| format!("{}{}.S", ROOT, file));
cc::Build::new()
.include(ROOT)
.files(paths)
.compile("kyberlib");
}
}
}
}