chore: remove deprecated flow_boundary and update docs to match new architecture
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//! Build script for coolprop-sys.
|
||||
//!
|
||||
//! This compiles the CoolProp C++ library statically.
|
||||
//! Supports macOS, Linux, and Windows.
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
@@ -9,10 +10,12 @@ fn coolprop_src_path() -> Option<PathBuf> {
|
||||
// Try to find CoolProp source in common locations
|
||||
let possible_paths = vec![
|
||||
// Vendor directory (recommended)
|
||||
PathBuf::from("../../vendor/coolprop").canonicalize().unwrap_or(PathBuf::from("../../../vendor/coolprop")),
|
||||
PathBuf::from("../../vendor/coolprop")
|
||||
.canonicalize()
|
||||
.unwrap_or(PathBuf::from("../../../vendor/coolprop")),
|
||||
// External directory
|
||||
PathBuf::from("external/coolprop"),
|
||||
// System paths
|
||||
// System paths (Unix)
|
||||
PathBuf::from("/usr/local/src/CoolProp"),
|
||||
PathBuf::from("/opt/CoolProp"),
|
||||
];
|
||||
@@ -23,7 +26,7 @@ fn coolprop_src_path() -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let static_linking = env::var("CARGO_FEATURE_STATIC").is_ok() || true; // Force static linking for python wheels
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
|
||||
// Check if CoolProp source is available
|
||||
if let Some(coolprop_path) = coolprop_src_path() {
|
||||
@@ -40,41 +43,67 @@ fn main() {
|
||||
|
||||
println!("cargo:rustc-link-search=native={}/build", dst.display());
|
||||
println!("cargo:rustc-link-search=native={}/lib", dst.display());
|
||||
println!("cargo:rustc-link-search=native={}/build", coolprop_path.display()); // Fallback
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}/build",
|
||||
coolprop_path.display()
|
||||
); // Fallback
|
||||
|
||||
// Link against CoolProp statically
|
||||
println!("cargo:rustc-link-lib=static=CoolProp");
|
||||
|
||||
|
||||
// On macOS, force load the static library so its symbols are exported in the final cdylib
|
||||
if cfg!(target_os = "macos") {
|
||||
println!("cargo:rustc-link-arg=-Wl,-force_load,{}/build/libCoolProp.a", dst.display());
|
||||
if target_os == "macos" {
|
||||
println!(
|
||||
"cargo:rustc-link-arg=-Wl,-force_load,{}/build/libCoolProp.a",
|
||||
dst.display()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
println!(
|
||||
"cargo:warning=CoolProp source not found in vendor/.
|
||||
For full static build, run:
|
||||
git clone https://github.com/CoolProp/CoolProp.git vendor/coolprop"
|
||||
"cargo:warning=CoolProp source not found in vendor/. \
|
||||
For full static build, run: \
|
||||
git clone https://github.com/CoolProp/CoolProp.git vendor/coolprop"
|
||||
);
|
||||
// Fallback for system library
|
||||
if static_linking {
|
||||
println!("cargo:rustc-link-lib=static=CoolProp");
|
||||
if target_os == "windows" {
|
||||
// On Windows, try to find CoolProp as a system library
|
||||
println!("cargo:rustc-link-lib=CoolProp");
|
||||
} else {
|
||||
println!("cargo:rustc-link-lib=dylib=CoolProp");
|
||||
println!("cargo:rustc-link-lib=static=CoolProp");
|
||||
}
|
||||
}
|
||||
|
||||
// Link required system libraries for C++ standard library
|
||||
#[cfg(target_os = "macos")]
|
||||
println!("cargo:rustc-link-lib=dylib=c++");
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
println!("cargo:rustc-link-lib=dylib=stdc++");
|
||||
match target_os.as_str() {
|
||||
"macos" => {
|
||||
println!("cargo:rustc-link-lib=dylib=c++");
|
||||
}
|
||||
"linux" | "freebsd" | "openbsd" | "netbsd" => {
|
||||
println!("cargo:rustc-link-lib=dylib=stdc++");
|
||||
}
|
||||
"windows" => {
|
||||
// MSVC links the C++ runtime automatically; nothing to do.
|
||||
// For MinGW, stdc++ is needed but MinGW is less common.
|
||||
}
|
||||
_ => {
|
||||
// Best guess for unknown Unix-like targets
|
||||
println!("cargo:rustc-link-lib=dylib=stdc++");
|
||||
}
|
||||
}
|
||||
|
||||
println!("cargo:rustc-link-lib=dylib=m");
|
||||
// Link libm (only on Unix; on Windows it's part of the CRT)
|
||||
if target_os != "windows" {
|
||||
println!("cargo:rustc-link-lib=dylib=m");
|
||||
}
|
||||
|
||||
// Force export symbols for Python extension (macOS only)
|
||||
if target_os == "macos" {
|
||||
println!("cargo:rustc-link-arg=-Wl,-all_load");
|
||||
}
|
||||
// Linux equivalent (only for shared library builds, e.g., Python wheels)
|
||||
// Note: --whole-archive must bracket the static lib; the linker handles this
|
||||
// automatically for Rust cdylib targets, so we don't need it here.
|
||||
|
||||
// Tell Cargo to rerun if build.rs changes
|
||||
|
||||
// Force export symbols on macOS for static building into a dynamic python extension
|
||||
println!("cargo:rustc-link-arg=-Wl,-all_load");
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ extern "C" {
|
||||
fn Props1SI(Fluid: *const c_char, Output: *const c_char) -> c_double;
|
||||
|
||||
/// Get CoolProp version string
|
||||
#[cfg_attr(target_os = "macos", link_name = "\x01__Z23get_global_param_stringNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE")]
|
||||
#[cfg_attr(target_os = "macos", link_name = "\x01__Z23get_global_param_stringPKcPci")]
|
||||
#[cfg_attr(not(target_os = "macos"), link_name = "get_global_param_string")]
|
||||
fn get_global_param_string(
|
||||
Param: *const c_char,
|
||||
@@ -158,7 +158,7 @@ extern "C" {
|
||||
) -> c_int;
|
||||
|
||||
/// Get fluid info
|
||||
#[cfg_attr(target_os = "macos", link_name = "\x01__Z22get_fluid_param_stringNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES5_")]
|
||||
#[cfg_attr(target_os = "macos", link_name = "\x01__Z22get_fluid_param_stringPKcS0_Pci")]
|
||||
#[cfg_attr(not(target_os = "macos"), link_name = "get_fluid_param_string")]
|
||||
fn get_fluid_param_string(
|
||||
Fluid: *const c_char,
|
||||
|
||||
Reference in New Issue
Block a user