-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
84 lines (76 loc) · 3.26 KB
/
build.rs
File metadata and controls
84 lines (76 loc) · 3.26 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// SPDX-License-Identifier: PMPL-1.0-or-later
//! Build script for ECHIDNA
//!
//! Chapel: Chapel (.chpl) → Zig bridge → Rust
//! SPARK: Ada/SPARK (echidna_spark.gpr) → Zig bridge → Rust
//!
//! SPARK build order:
//! 1. gprbuild -P src/ada/spark/echidna_spark.gpr
//! 2. cd src/zig && zig build -Dspark
//! 3. cargo build --features spark
fn main() {
// SPARK axiom-policy bridge (requires GPRbuild + Zig; see just spark-all)
#[cfg(feature = "spark")]
{
let spark_zig_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("src")
.join("zig")
.join("zig-out")
.join("lib");
let spark_ada_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("lib")
.join("spark");
if spark_zig_dir.exists() {
println!("cargo:rustc-link-search=native={}", spark_zig_dir.display());
println!("cargo:rustc-link-lib=static=echidna_spark_zig");
} else {
println!(
"cargo:warning=SPARK Zig bridge not found. \
Build with: cd src/zig && zig build -Dspark"
);
}
if spark_ada_dir.exists() {
println!("cargo:rustc-link-search=native={}", spark_ada_dir.display());
println!("cargo:rustc-link-lib=static=echidna_spark");
println!("cargo:rustc-link-lib=dylib=gnat");
} else {
println!(
"cargo:warning=SPARK Ada library not found. \
Build with: gprbuild -P src/ada/spark/echidna_spark.gpr"
);
}
println!("cargo:rustc-link-lib=dylib=c");
println!("cargo:rerun-if-changed=src/ada/spark/axiom_policy.adb");
println!("cargo:rerun-if-changed=src/ada/spark/axiom_policy.ads");
println!("cargo:rerun-if-changed=src/zig/ffi/axiom_spark_bridge.zig");
}
// Chapel parallel proof search bridge
#[cfg(feature = "chapel")]
{
// Look for the Zig-built library in src/zig_ffi/zig-out/lib/
let zig_ffi_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("src")
.join("zig_ffi")
.join("zig-out")
.join("lib");
if zig_ffi_dir.exists() {
println!("cargo:rustc-link-search=native={}", zig_ffi_dir.display());
println!("cargo:rustc-link-lib=static=echidna_chapel_ffi");
println!("cargo:rustc-link-lib=dylib=c");
} else {
// Also check standard install location
let alt_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib");
if alt_dir.exists() {
println!("cargo:rustc-link-search=native={}", alt_dir.display());
println!("cargo:rustc-link-lib=static=echidna_chapel_ffi");
println!("cargo:rustc-link-lib=dylib=c");
} else {
println!("cargo:warning=Chapel FFI library not found. Build it first with: just build-chapel-ffi");
println!("cargo:warning=Looked in: {}", zig_ffi_dir.display());
}
}
// Re-run if FFI source changes
println!("cargo:rerun-if-changed=src/zig_ffi/chapel_bridge.zig");
println!("cargo:rerun-if-changed=src/zig_ffi/build.zig");
}
}