Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use netCDF-c v4.9.3 #148

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ jobs:
- name: Check formatting
run: cargo fmt -- --check
- name: Documentation
run: cargo doc --workspace --features netcdf/derive
run: cargo doc --workspace --features netcdf/derive --exclude netcdf-src
- name: Clippy
run: cargo clippy --features netcdf/derive --workspace -- -D warnings
run: cargo clippy --features netcdf/derive --workspace --exclude netcdf-src -- -D warnings

test_apt:
name: test apt
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
- {os: ubuntu-latest, rust: stable}
- {os: windows-latest, rust: stable-msvc}
- {os: windows-latest, rust: stable-gnu}
- {os: macos-12, rust: stable}
- {os: macos-13, rust: stable}
- {os: macos-latest, rust: stable}
defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "netcdf-src/source"]
path = netcdf-src/source
url = https://github.com/magnusuMET/netcdf-c
url = https://github.com/Unidata/netcdf-c
2 changes: 1 addition & 1 deletion netcdf-src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dap = ["dep:link-cplusplus"]
mpi = []

[dependencies]
hdf5-sys = { workspace = true, features = ["hl", "deprecated", "zlib"] }
hdf5-sys = { workspace = true, features = ["hl", "deprecated", "zlib", "static"] }
libz-sys = { version = "1.0.25" }
link-cplusplus = { version = "1.0.9", optional = true }

Expand Down
75 changes: 20 additions & 55 deletions netcdf-src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,48 @@ macro_rules! feature {
};
}

fn get_hdf5_version() -> String {
let (major, minor, patch) = std::env::vars()
.filter_map(|(key, value)| {
key.strip_prefix("DEP_HDF5_VERSION_").map(|key| {
assert_eq!(value, "1");
let mut version = key.split('_');
let major: usize = version.next().unwrap().parse().unwrap();
let minor: usize = version.next().unwrap().parse().unwrap();
let patch: usize = version.next().unwrap().parse().unwrap();

(major, minor, patch)
})
})
.max()
.expect("Crate hdf5 should have emitted a hdf5 version");

format!("{major}.{minor}.{patch}")
}

fn main() {
println!("cargo::rerun-if-changed=build.rs");

let hdf5_incdir = std::env::var("DEP_HDF5_INCLUDE").unwrap();
let mut hdf5_lib = std::env::var("DEP_HDF5_LIBRARY").unwrap();
let mut hdf5_hl_lib = std::env::var("DEP_HDF5_HL_LIBRARY").unwrap();

#[cfg(unix)]
{
let hdf5_root = format!("{hdf5_incdir}/../");
let mut hdf5_libdir = format!("{hdf5_root}/lib/");
if !std::path::Path::new(&hdf5_libdir).exists() {
hdf5_libdir = format!("{hdf5_root}/lib64/");
}
hdf5_lib = format!("{hdf5_libdir}/{hdf5_lib}.a");
hdf5_hl_lib = format!("{hdf5_libdir}/{hdf5_hl_lib}.a");
}

let hdf5_version = get_hdf5_version();
let hdf5_root = format!("{hdf5_incdir}/../");

let mut netcdf_config = cmake::Config::new("source");
netcdf_config
.define("BUILD_SHARED_LIBS", "OFF")
.define("NC_FIND_SHARED_LIBS", "OFF")
.define("BUILD_UTILITIES", "OFF")
.define("ENABLE_EXAMPLES", "OFF")
.define("ENABLE_DAP_REMOTE_TESTS", "OFF")
.define("ENABLE_TESTS", "OFF")
.define("ENABLE_EXTREME_NUMBERS", "OFF")
.define("ENABLE_PARALLEL_TESTS", "OFF")
.define("ENABLE_FILTER_TESTING", "OFF")
.define("NETCDF_FIND_SHARED_LIBS", "OFF")
.define("NETCDF_BUILD_UTILITIES", "OFF")
.define("NETCDF_ENABLE_EXAMPLES", "OFF")
.define("NETCDF_ENABLE_DAP_REMOTE_TESTS", "OFF")
.define("NETCDF_ENABLE_TESTS", "OFF")
.define("NETCDF_ENABLE_EXTREME_NUMBERS", "OFF")
.define("NETCDF_ENABLE_FILTER_TESTING", "OFF")
.define("NETCDF_ENABLE_PARALLEL_TESTS", "OFF")
.define("NETCDF_ENABLE_FILTER_TESTING", "OFF")
.define("ENABLE_BASH_SCRIPT_TESTING", "OFF")
.define("ENABLE_PLUGINS", "OFF")
.define("NETCDF_NETCDF_ENABLE_PLUGINS", "OFF")
.define("PLUGIN_INSTALL_DIR", "OFF")
//
.define("HDF5_VERSION", &hdf5_version)
.define("HDF5_C_LIBRARY", &hdf5_lib)
.define("HDF5_HL_LIBRARY", &hdf5_hl_lib)
.define("HDF5_INCLUDE_DIR", hdf5_incdir)
.define("HDF5_ROOT", &hdf5_root)
.define("HDF5_USE_STATIC_LIBRARIES", "ON")
//
.define("ENABLE_LIBXML2", "OFF") // Use bundled xml2
.define("NETCDF_ENABLE_LIBXML2", "OFF") // Use bundled xml2
//
.define("ENABLE_PARALLEL4", "OFF") // TODO: Enable mpi support
.define("NETCDF_ENABLE_PARALLEL4", "OFF") // TODO: Enable mpi support
//
.define("ENABLE_NCZARR", "OFF") // TODO: requires a bunch of deps
.define("NETCDF_ENABLE_NCZARR", "OFF") // TODO: requires a bunch of deps
//
.define("ENABLE_DAP", "OFF") // TODO: feature flag, requires curl
.define("ENABLE_BYTERANGE", "OFF") // TODO: feature flag, requires curl
.define("ENABLE_DAP_REMOTE_TESTS", "OFF")
.define("NETCDF_ENABLE_DAP", "OFF") // TODO: feature flag, requires curl
.define("NETCDF_ENABLE_BYTERANGE", "OFF") // TODO: feature flag, requires curl
//
.profile("RelWithDebInfo"); // TODO: detect opt-level

let zlib_include_dir = std::env::var("DEP_Z_INCLUDE").unwrap();
netcdf_config.define("ZLIB_ROOT", format!("{zlib_include_dir}/.."));

if feature!("DAP").is_ok() {
netcdf_config.define("ENABLE_DAP", "ON");
netcdf_config.define("ENABLE_BYTERANGE", "ON");
netcdf_config.define("NETCDF_ENABLE_DAP", "ON");
netcdf_config.define("NETCDF_ENABLE_BYTERANGE", "ON");
}

if feature!("MPI").is_ok() {
Expand Down
2 changes: 1 addition & 1 deletion netcdf-src/source
Submodule source updated 1307 files
1 change: 1 addition & 0 deletions netcdf-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ fn main() {
Version::new(4, 9, 0),
Version::new(4, 9, 1),
Version::new(4, 9, 2),
Version::new(4, 9, 3),
// Keep this list up to date with netcdf/build.rs
];

Expand Down
1 change: 1 addition & 0 deletions netcdf/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn main() {
Version::new(4, 9, 0),
Version::new(4, 9, 1),
Version::new(4, 9, 2),
Version::new(4, 9, 3),
// Keep this list up to date with netcdf-sys/build.rs
];

Expand Down
Loading