45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
use std::path::PathBuf;
|
|||
|
|
|
||
|
|
/// Library objects as listed in the upstream Makefile (SWEOBJ).
|
||
|
|
const SOURCES: &[&str] = &[
|
||
|
|
"swedate.c",
|
||
|
|
"swehouse.c",
|
||
|
|
"swejpl.c",
|
||
|
|
"swemmoon.c",
|
||
|
|
"swemplan.c",
|
||
|
|
"sweph.c",
|
||
|
|
"swephlib.c",
|
||
|
|
"swecl.c",
|
||
|
|
"swehel.c",
|
||
|
|
];
|
||
|
|
|
||
|
|
fn main() {
|
||
|
|
let dir = std::env::var_os("SWISSEPH_SRC_DIR")
|
||
|
|
.map(PathBuf::from)
|
||
|
|
.unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../vendor/swisseph"));
|
||
|
|
if !dir.join("sweph.c").exists() {
|
||
|
|
panic!(
|
||
|
|
"Swiss Ephemeris sources not found in {}. Run scripts/fetch-deps.sh first \
|
||
|
|
(or set SWISSEPH_SRC_DIR).",
|
||
|
|
dir.display()
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
let mut build = cc::Build::new();
|
||
|
|
build
|
||
|
|
.include(&dir)
|
||
|
|
// Globals are shared between threads; the Rust side serializes access.
|
||
|
|
.define("TLSOFF", None)
|
||
|
|
.opt_level(2)
|
||
|
|
.warnings(false);
|
||
|
|
for src in SOURCES {
|
||
|
|
let path = dir.join(src);
|
||
|
|
println!("cargo:rerun-if-changed={}", path.display());
|
||
|
|
build.file(path);
|
||
|
|
}
|
||
|
|
build.compile("swe");
|
||
|
|
|
||
|
|
println!("cargo:rerun-if-env-changed=SWISSEPH_SRC_DIR");
|
||
|
|
println!("cargo:rustc-link-lib=m");
|
||
|
|
}
|