Skip to content
Merged
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
45 changes: 23 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: ${{matrix.command}}
args: "${{matrix.command == 'fmt' && '--all -- --check' || '--workspace --exclude hdf5-src -- -D warnings -D clippy::cargo'}}"
args: "${{matrix.command == 'fmt' && '--all -- --check' || '--workspace --exclude hdf5-src -- -D warnings -D clippy::cargo -A clippy::multiple-crate-versions'}}"

doc: # This task should mirror the procedure on docs.rs
runs-on: ubuntu-latest
Expand All @@ -58,8 +58,7 @@ jobs:
include:
- {version: hdf5@1.8}
- {version: hdf5@1.10}
- {version: hdf5@1.12}
- {version: hdf5-mpi, mpi: true}
# - {version: hdf5-mpi, mpi: true} # TODO: re-enable once 1.14 support is merged in
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -156,13 +155,13 @@ jobs:

apt:
name: apt
runs-on: ubuntu-${{matrix.ubuntu}}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- {ubuntu: 18.04, mpi: mpich, rust: beta}
- {ubuntu: 20.04, mpi: openmpi, rust: stable}
- {mpi: mpich, rust: beta}
- {mpi: openmpi, rust: stable}
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -236,7 +235,7 @@ jobs:

msrv:
name: Minimal Supported Rust Version
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
Expand All @@ -245,25 +244,27 @@ jobs:
with: {submodules: true}
- name: Install Rust
uses: actions-rs/toolchain@v1
with: {toolchain: 1.54, profile: minimal, override: true}
with: {toolchain: 1.64, profile: minimal, override: true}
- name: Build and test all crates
run:
cargo test --workspace -vv --features=hdf5-sys/static --exclude=hdf5-derive

wine:
name: wine
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with: {submodules: true}
- name: Install Rust
uses: actions-rs/toolchain@v1
with: {toolchain: stable, target: x86_64-pc-windows-gnu, profile: minimal, override: true}
- name: Install dependencies
run: sudo apt-get update && sudo apt install wine64 mingw-w64
- name: Build and test
run: env CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64 cargo test --features hdf5-sys/static --target x86_64-pc-windows-gnu -- --skip test_compile_fail
# # TODO: temporarily disabled until fixed (see https://github.com/aldanor/hdf5-rust/issues/241)
# wine:
# name: wine
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2
# with: {submodules: true}
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with: {toolchain: stable, target: x86_64-pc-windows-gnu, profile: minimal, override: true}
# - name: Install dependencies
# run: sudo apt-get update && sudo apt install wine64 mingw-w64
# - name: Build and test
# run: env CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64 cargo test --features hdf5-sys/static --target x86_64-pc-windows-gnu -- --skip test_compile_fail

addr_san:
name: Address sanitizer
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
### Changed

- The `H5Type` derive macro now uses `proc-macro-error` to emit error messages.
- MSRV is now `1.54` following a bump in a dependency.
- MSRV is now `1.64.0` and Rust edition has now been bumped to 2021.

### Fixed

Expand All @@ -21,6 +21,7 @@
- Fixed a missing symbol when building `hdf5-src` with `libz-sys`.
- Fixed a bug where errors were only silenced on the main thread.
- Fixed a memory leak when opening datasets.
- Avoid creating unaligned references in `H5Type` derive macro.

## 0.8.1

Expand Down
67 changes: 19 additions & 48 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,55 +1,26 @@
[package]
name = "hdf5"
[workspace]
members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys", "hdf5-src"]
default-members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys"]

[workspace.package]
version = "0.8.1" # !V
authors = ["Ivan Smirnov <i.s.smirnov@gmail.com>"]
rust-version = "1.64.0"
authors = ["Ivan Smirnov <aldanor@users.noreply.github.com>", "Magnus Ulimoen <mulimoen@users.noreply.github.com>"]
keywords = ["hdf5"]
license = "MIT OR Apache-2.0"
readme = "README.md"
description = "Thread-safe Rust bindings for the HDF5 library."
repository = "https://github.com/aldanor/hdf5-rust"
homepage = "https://github.com/aldanor/hdf5-rust"
build = "build.rs"
edition = "2018"
categories = ["science", "filesystem"]

[features]
default = []
mpio = ["mpi-sys", "hdf5-sys/mpio"]
lzf = ["lzf-sys", "errno"]
blosc = ["blosc-sys"]
# The features with version numbers such as 1.10.3, 1.12.0 are metafeatures
# and is only available when the HDF5 library is at least this version.
# Features have_direct and have_parallel are also metafeatures and dependent
# on the HDF5 library which is linked against.

[workspace]
members = [".", "hdf5-types", "hdf5-derive", "hdf5-sys", "hdf5-src"]
default-members = [".", "hdf5-types", "hdf5-derive", "hdf5-sys"]
edition = "2021"

[dependencies]
bitflags = "1.2"
lazy_static = "1.4"
libc = "0.2"
parking_lot = "0.11"
ndarray = "0.15"
paste = "1.0"
mpi-sys = { version = "0.1", optional = true }
errno = { version = "0.2", optional = true }
hdf5-sys = { path = "hdf5-sys", version = "0.8.1" } # !V
hdf5-types = { path = "hdf5-types", version = "0.8.1" } # !V
hdf5-derive = { path = "hdf5-derive", version = "0.8.1" } # !V
blosc-sys = { version = "0.1.1", package = "blosc-src", optional = true }
lzf-sys = { version = "0.1", optional = true }
[workspace.dependencies]
# external
cfg-if = "1.0"

[dev-dependencies]
paste = "1.0"
pretty_assertions = "1.0"
rand = { version = "0.8", features = ["small_rng"] }
regex = "1.3"
scopeguard = "1.0"
tempfile = "3.2"

[package.metadata.docs.rs]
features = ["hdf5-sys/static", "hdf5-sys/zlib", "blosc", "lzf"]
rustdoc-args = ["--cfg", "docsrs"]
libc = "0.2"
libz-sys = { version = "1.1", default-features = false }
mpi-sys = "0.2"
regex = "1.8"
# internal
hdf5-derive = { version = "0.8.1", path = "hdf5-derive" } # !V
hdf5-src = { version = "0.8.1", path = "hdf5-src" } # !V
hdf5-sys = { version = "0.8.1", path = "hdf5-sys" } # !V
hdf5-types = { version = "0.8.1", path = "hdf5-types" } # !V
25 changes: 13 additions & 12 deletions hdf5-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
[package]
name = "hdf5-derive"
version = "0.8.1" # !V
authors = ["Ivan Smirnov <i.s.smirnov@gmail.com>"]
keywords = ["hdf5"]
license = "MIT OR Apache-2.0"
description = "Derive macro for HDF5 structs and enums."
repository = "https://github.com/aldanor/hdf5-rust"
homepage = "https://github.com/aldanor/hdf5-rust"
edition = "2018"
readme = "README.md"
categories = ["procedural-macro-helpers"]
readme = "README.md"
version.workspace = true
rust-version.workspace = true
authors.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
edition.workspace = true

[lib]
proc-macro = true

[dependencies]
proc-macro-error = { version = "1.0.4", default-features = false }
proc-macro-error = { version = "1.0", default-features = false }
proc-macro2 = "1.0"
quote = "^1.0.2"
syn = { version = "^1.0.5", features = ["derive", "extra-traits"]}
quote = "1.0"
syn = { version = "2.0", features = ["derive", "extra-traits"]}

[dev-dependencies]
trybuild = "1.0"
hdf5 = { version = ">=0.7.1", path = ".." }
hdf5 = { version = ">=0.7.1", path = "../hdf5" }
63 changes: 24 additions & 39 deletions hdf5-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use proc_macro2::{Ident, Span, TokenStream};
use proc_macro_error::{abort, proc_macro_error};
use quote::{quote, ToTokens};
use syn::{
parse_macro_input, AttrStyle, Attribute, Data, DeriveInput, Expr, Fields, Index, Lit, Meta,
NestedMeta, Type, TypeGenerics, TypePath,
parse_macro_input, AttrStyle, Attribute, Data, DeriveInput, Expr, Fields, Index, LitStr, Type,
TypeGenerics, TypePath,
};

#[proc_macro_derive(H5Type, attributes(hdf5))]
Expand Down Expand Up @@ -107,55 +107,40 @@ fn is_phantom_data(ty: &Type) -> bool {
}

fn find_repr(attrs: &[Attribute], expected: &[&str]) -> Option<Ident> {
let mut repr = None;
for attr in attrs.iter() {
if attr.style != AttrStyle::Outer {
continue;
}
let list = match attr.parse_meta() {
Ok(Meta::List(list)) => list,
_ => continue,
};
if !list.path.get_ident().map_or(false, |ident| ident == "repr") {
if !attr.path().is_ident("repr") {
continue;
}
for item in list.nested.iter() {
let path = match item {
NestedMeta::Meta(Meta::Path(ref path)) => path,
_ => continue,
};
let ident = match path.get_ident() {
Some(ident) => ident,
_ => continue,
};
if expected.iter().any(|&s| ident == s) {
return Some(Ident::new(&ident.to_string(), Span::call_site()));
attr.parse_nested_meta(|meta| {
if expected.iter().any(|s| meta.path.is_ident(s)) {
if repr.is_some() {
abort!(meta.path, "ambiguous repr attribute");
} else {
repr = meta.path.get_ident().cloned();
}
}
}
Ok(())
})
.ok()?;
}

None
repr
}

fn find_hdf5_rename(attrs: &[Attribute]) -> Option<String> {
if let Some(attr) = attrs.iter().find(|a| a.path.is_ident("hdf5")) {
if let Ok(Meta::List(meta_list)) = attr.parse_meta() {
let rename_literal = meta_list.nested.iter().find_map(|n| {
if let NestedMeta::Meta(Meta::NameValue(name_value)) = n {
if name_value.path.is_ident("rename") {
return Some(&name_value.lit);
}
}

None
});

if let Some(Lit::Str(renamed)) = rename_literal {
return Some(renamed.value());
}
let mut rename = None;
let attr = attrs.iter().find(|a| a.path().is_ident("hdf5"))?;
attr.parse_nested_meta(|meta| {
if meta.path.is_ident("rename") && rename.is_none() {
rename = Some(meta.value()?.parse::<LitStr>()?.value());
}
}

None
Ok(())
})
.ok()?;
rename
}

fn pluck<'a, I, F, T, S>(iter: I, func: F) -> Vec<S>
Expand Down
17 changes: 9 additions & 8 deletions hdf5-src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
[package]
name = "hdf5-src"
version = "0.8.1" # !V
authors = ["Ivan Smirnov <i.s.smirnov@gmail.com>"]
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 C library from source."
edition = "2018"
links = "hdf5src"
readme = "README.md"
categories = ["ffi"]
Expand All @@ -26,6 +20,13 @@ exclude = [
"ext/hdf5/hl/tools/**",
"ext/hdf5/hl/examples/**",
]
version.workspace = true
rust-version.workspace = true
authors.workspace = true
keywords.workspace = true
repository.workspace = true
homepage.workspace = true
edition.workspace = true

[features]
hl = []
Expand All @@ -34,7 +35,7 @@ deprecated = []
threadsafe = []

[dependencies]
libz-sys = { version = "1.0.25", features = ["static", "libc"], optional = true, default-features=false }
libz-sys = { workspace = true, optional = true, features = ["static", "libc"] }

[build-dependencies]
cmake = "0.1.44"
cmake = "0.1"
Loading