use std::env;
use find_julia::{JuliaDir, Version, enable_version_cfgs};
use jlrs_compat::*;
fn main() {
println!("cargo::rerun-if-env-changed=PATH");
println!("cargo::rerun-if-env-changed=LD_LIBRARY_PATH");
println!("cargo::rerun-if-env-changed=DYLD_LIBRARY_PATH");
println!("cargo::rerun-if-env-changed=JLRS_JULIA_DIR");
enable_version_cfgs(MIN_MINOR_VERSION, MAX_MINOR_VERSION);
if building_docs() {
let version = Version::new(STABLE_MAJOR_VERSION, STABLE_MINOR_VERSION, 0, false);
version.emit_metadata_unchecked();
} else {
#[cfg(feature = "debug")]
let julia_dir = JuliaDir::find(true)
.expect("JLRS_JULIA_DIR is not set and no installed version of Julia can be found");
#[cfg(not(feature = "debug"))]
let julia_dir = JuliaDir::find(windows_build(), false)
.expect("JLRS_JULIA_DIR is not set and no installed version of Julia can be found");
julia_dir.emit_metadata(MIN_MINOR_VERSION, MAX_MINOR_VERSION);
julia_dir.link();
}
}
fn building_docs() -> bool {
if env::var("DOCS_RS").is_ok() {
return true;
}
#[cfg(feature = "docs")]
return true;
#[cfg(not(feature = "docs"))]
return false;
}
fn windows_build() -> bool {
#[cfg(any(target_os = "windows", feature = "windows"))]
return true;
#[cfg(not(any(target_os = "windows", feature = "windows")))]
return false;
}