-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
57 lines (49 loc) · 1.72 KB
/
Copy pathbuild.rs
File metadata and controls
57 lines (49 loc) · 1.72 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
fn main() {
#[cfg(feature = "c-reference")]
build_misa77();
}
#[cfg(feature = "c-reference")]
fn build_misa77() {
let vendor = "vendor/misa77";
let mut base = cc::Build::new();
base.cpp(true)
.std("c++20")
.opt_level(3)
.include(format!("{vendor}/include"))
.include(format!("{vendor}/src"))
.warnings(false);
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
if arch == "x86_64" {
// Portable TU (no special flags)
let mut portable = base.clone();
portable
.file(format!("{vendor}/src/isa/target_portable.cpp"))
.compile("misa77_portable");
// SSE2 TU (baseline on x86-64)
let mut sse2 = base.clone();
sse2.flag("-msse2")
.file(format!("{vendor}/src/isa/target_sse2.cpp"))
.compile("misa77_sse2");
// AVX2 TU
let mut avx2 = base.clone();
avx2.flag("-mavx2")
.file(format!("{vendor}/src/isa/target_avx2.cpp"))
.compile("misa77_avx2");
} else {
// ARM64 / other: portable only
let mut portable = base.clone();
portable
.file(format!("{vendor}/src/isa/target_portable.cpp"))
.compile("misa77_portable");
}
// Main dispatch files (no special ISA flags needed)
let mut main_build = base.clone();
main_build
.file(format!("{vendor}/src/compress.cpp"))
.file(format!("{vendor}/src/decompress.cpp"))
.file("vendor/misa77_ffi.cpp")
.compile("misa77_main");
println!("cargo:rerun-if-changed=vendor/misa77_ffi.cpp");
println!("cargo:rerun-if-changed={vendor}/src");
println!("cargo:rerun-if-changed={vendor}/include");
}