forked from metno/hdf5-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15ec644
commit ade1e18
Showing
17 changed files
with
234 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "hdf5"] | ||
path = hdf5-src/ext/hdf5 | ||
url = https://github.com/HDFGroup/hdf5.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
use std::env; | ||
|
||
fn main() { | ||
hdf5_sys::emit_cfg_flags(); | ||
for (key, _) in env::vars() { | ||
let key = match key.as_str() { | ||
"DEP_HDF5_HAVE_DIRECT" => "h5_have_direct".into(), | ||
"DEP_HDF5_HAVE_STDBOOL" => "h5_have_stdbool".into(), | ||
"DEP_HDF5_HAVE_PARALLEL" => "h5_have_parallel".into(), | ||
"DEP_HDF5_HAVE_THREADSAFE" => "h5_have_threadsafe".into(), | ||
"DEP_HDF5_MSVC_DLL_INDIRECTION" => "h5_dll_indirection".into(), | ||
key if key.starts_with("DEP_HDF5_VERSION_") => { | ||
let version = key.trim_start_matches("DEP_HDF5_VERSION_"); | ||
format!("hdf5_{}", version) | ||
} | ||
_ => continue, | ||
}; | ||
println!("cargo:rustc-cfg={}", key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "hdf5-src" | ||
version = "0.6.1" # !V | ||
authors = ["Ivan Smirnov <[email protected]>"] | ||
keywords = ["hdf5"] | ||
license-file = "ext/hdf5/COPYING" | ||
build = "build.rs" | ||
repository = "https://github.com/aldanor/hdf5-rust" | ||
homepage = "https://github.com/aldanor/hdf5-rust" | ||
description = "Build script for compiling hdf5 from source" | ||
edition = "2018" | ||
links = "hdf5src" | ||
exclude = [ | ||
"ext/hdf5/bin/**", | ||
"ext/hdf5/c++/**", | ||
"ext/hdf5/examples/**", | ||
"ext/hdf5/fortran/**", | ||
"ext/hdf5/java/**", | ||
"ext/hdf5/release_docs/**", | ||
"ext/hdf5/test/**", | ||
"ext/hdf5/testpar/**", | ||
"ext/hdf5/tools/**", | ||
"ext/hdf5/hl/test/**", | ||
"ext/hdf5/hl/tools/**", | ||
"ext/hdf5/hl/examples/**", | ||
] | ||
|
||
[features] | ||
hl = [] | ||
zlib = ["libz-sys"] | ||
deprecated = [] | ||
threadsafe = [] | ||
|
||
[dependencies] | ||
libz-sys = { version = "1.0.25", features = ["static"], optional = true } | ||
|
||
[build-dependencies] | ||
cmake = "0.1.44" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
use std::env; | ||
|
||
fn feature_enabled(feature: &str) -> bool { | ||
env::var(format!("CARGO_FEATURE_{}", feature)).is_ok() | ||
} | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
let mut cfg = cmake::Config::new("ext/hdf5"); | ||
|
||
// only build the static c library, disable everything else | ||
cfg.define("HDF5_NO_PACKAGES", "ON"); | ||
for option in &[ | ||
"BUILD_SHARED_LIBS", | ||
"BUILD_TESTING", | ||
"HDF5_BUILD_TOOLS", | ||
"HDF5_BUILD_EXAMPLES", | ||
"HDF5_BUILD_JAVA", | ||
"HDF5_BUILD_FORTRAN", | ||
"HDF5_BUILD_CPP_LIB", | ||
"HDF5_ENABLE_PARALLEL", | ||
] { | ||
cfg.define(option, "OFF"); | ||
} | ||
|
||
// disable these by default, can be enabled via features | ||
for option in &[ | ||
"HDF5_ENABLE_DEPRECATED_SYMBOLS", | ||
"HDF5_ENABLE_THREADSAFE", | ||
"ALLOW_UNSUPPORTED", | ||
"HDF5_BUILD_HL_LIB", | ||
] { | ||
cfg.define(option, "OFF"); | ||
} | ||
|
||
if feature_enabled("ZLIB") { | ||
let zlib_include_dir = env::var_os("DEP_Z_INCLUDE").unwrap(); | ||
let mut zlib_header = env::split_paths(&zlib_include_dir).next().unwrap(); | ||
zlib_header.push("zlib.h"); | ||
let zlib_lib = "z"; | ||
cfg.define("HDF5_ENABLE_Z_LIB_SUPPORT", "ON") | ||
.define("H5_ZLIB_HEADER", &zlib_header) | ||
.define("ZLIB_STATIC_LIBRARY", &zlib_lib); | ||
println!("cargo:zlib_header={}", zlib_header.to_str().unwrap()); | ||
println!("cargo:zlib={}", zlib_lib); | ||
} | ||
|
||
if feature_enabled("DEPRECATED") { | ||
cfg.define("HDF5_ENABLE_DEPRECATED_SYMBOLS", "ON"); | ||
} | ||
|
||
if feature_enabled("THREADSAFE") { | ||
cfg.define("HDF5_ENABLE_THREADSAFE", "ON"); | ||
if feature_enabled("HL") { | ||
println!("cargo:warning=Unsupported HDF5 options: hl with threadsafe."); | ||
cfg.define("ALLOW_UNSUPPORTED", "ON"); | ||
} | ||
} | ||
|
||
let debug_postfix = if cfg!(target_os = "windows") { "_D" } else { "_debug" }; | ||
|
||
if feature_enabled("HL") { | ||
cfg.define("HDF5_BUILD_HL_LIB", "ON"); | ||
let mut hdf5_hl_lib = | ||
if cfg!(target_env = "msvc") { "libhdf5_hl" } else { "hdf5_hl" }.to_owned(); | ||
if let Ok(opt_level) = env::var("OPT_LEVEL") { | ||
if opt_level == "0" { | ||
hdf5_hl_lib.push_str(debug_postfix); | ||
} | ||
} | ||
println!("cargo:hl_library={}", hdf5_hl_lib); | ||
} | ||
|
||
let dst = cfg.build(); | ||
println!("cargo:root={}", dst.display()); | ||
|
||
let hdf5_incdir = format!("{}/include", dst.display()); | ||
println!("cargo:include={}", hdf5_incdir); | ||
|
||
let mut hdf5_lib = if cfg!(target_env = "msvc") { "libhdf5" } else { "hdf5" }.to_owned(); | ||
if let Ok(opt_level) = env::var("OPT_LEVEL") { | ||
if opt_level == "0" { | ||
hdf5_lib.push_str(debug_postfix); | ||
} | ||
} | ||
println!("cargo:library={}", hdf5_lib); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//! Dummy crate for building `hdf5` from source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.