Skip to content

Commit 5698b17

Browse files
committed
Use weak features
1 parent fb96296 commit 5698b17

File tree

6 files changed

+51
-20
lines changed

6 files changed

+51
-20
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
uses: actions-rs/toolchain@v1
4848
with: {toolchain: nightly, profile: minimal, override: true}
4949
- name: Document workspace
50-
run: env RUSTDOCFLAGS="--cfg docsrs" cargo doc --features hdf5-sys/static,hdf5-sys/zlib,blosc,lzf
50+
run: env RUSTDOCFLAGS="--cfg docsrs" cargo doc --features static,zlib,blosc,lzf
5151

5252
brew:
5353
name: brew
@@ -144,14 +144,14 @@ jobs:
144144
uses: actions-rs/toolchain@v1
145145
with: {toolchain: '${{matrix.rust}}', profile: minimal, override: true}
146146
- name: Build and test all crates
147-
run: cargo test --workspace -v --features hdf5-sys/static,hdf5-sys/zlib --exclude hdf5-derive
147+
run: cargo test --workspace -v --features static,zlib --exclude hdf5-derive
148148
- name: Build and test with filters
149-
run: cargo test --workspace -v --features hdf5-sys/static,hdf5-sys/zlib,lzf,blosc --exclude hdf5-derive
149+
run: cargo test --workspace -v --features static,zlib,lzf,blosc --exclude hdf5-derive
150150
if: matrix.rust != 'stable-gnu'
151151
- name: Run examples
152152
run: |
153-
cargo r --example simple --features hdf5-sys/static,hdf5-sys/zlib,lzf,blosc
154-
cargo r --example chunking --features hdf5-sys/static,hdf5-sys/zlib,lzf,blosc
153+
cargo r --example simple --features static,zlib,lzf,blosc
154+
cargo r --example chunking --features static,zlib,lzf,blosc
155155
if: matrix.rust != 'stable-gnu'
156156

157157
apt:
@@ -245,10 +245,10 @@ jobs:
245245
with: {submodules: true}
246246
- name: Install Rust
247247
uses: actions-rs/toolchain@v1
248-
with: {toolchain: 1.54, profile: minimal, override: true}
248+
with: {toolchain: "1.60", profile: minimal, override: true}
249249
- name: Build and test all crates
250250
run:
251-
cargo test --workspace -vv --features=hdf5-sys/static --exclude=hdf5-derive
251+
cargo test -- --workspace -vv --features static --exclude=hdf5-derive
252252

253253
wine:
254254
name: wine
@@ -263,7 +263,7 @@ jobs:
263263
- name: Install dependencies
264264
run: sudo apt-get update && sudo apt install wine64 mingw-w64
265265
- name: Build and test
266-
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
266+
run: env CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64 cargo test --features static --target x86_64-pc-windows-gnu -- --skip test_compile_fail
267267
addr_san:
268268
name: Address sanitizer
269269
runs-on: ubuntu-latest
@@ -275,4 +275,4 @@ jobs:
275275
uses: actions-rs/toolchain@v1
276276
with: {toolchain: nightly, profile: minimal, override: true}
277277
- name: Run test with sanitizer
278-
run: env RUSTFLAGS="-Z sanitizer=address" cargo test --features hdf5-sys/static --target x86_64-unknown-linux-gnu --workspace --exclude hdf5-derive
278+
run: env RUSTFLAGS="-Z sanitizer=address" cargo test --features static --target x86_64-unknown-linux-gnu --workspace --exclude hdf5-derive

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
### Changed
1313

1414
- The `H5Type` derive macro now uses `proc-macro-error` to emit error messages.
15-
- MSRV is now `1.54` following a bump in a dependency.
15+
- Features have been reworked to use the new dependency resolution. This bumps MSRV.
16+
- MSRV is increased to `1.60`.
1617

1718
### Fixed
1819

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ homepage = "https://github.com/aldanor/hdf5-rust"
1111
build = "build.rs"
1212
edition = "2018"
1313
categories = ["science", "filesystem"]
14+
rust-version = "1.60"
1415

1516
[features]
1617
default = []
17-
mpio = ["mpi-sys", "hdf5-sys/mpio"]
18-
lzf = ["lzf-sys", "errno"]
19-
blosc = ["blosc-sys"]
18+
mpio = ["dep:mpi-sys", "hdf5-sys/mpio"]
19+
lzf = ["dep:lzf-sys", "dep:errno"]
20+
blosc = ["dep:blosc-sys"]
21+
static = ["hdf5-sys/static"]
22+
zlib = ["hdf5-sys/zlib"]
2023
# The features with version numbers such as 1.10.3, 1.12.0 are metafeatures
2124
# and is only available when the HDF5 library is at least this version.
2225
# Features have_direct and have_parallel are also metafeatures and dependent

hdf5-src/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ edition = "2018"
1212
links = "hdf5src"
1313
readme = "README.md"
1414
categories = ["ffi"]
15+
rust-version = "1.60"
1516
exclude = [
1617
"ext/hdf5/bin/**",
1718
"ext/hdf5/c++/**",
@@ -29,7 +30,7 @@ exclude = [
2930

3031
[features]
3132
hl = []
32-
zlib = ["libz-sys"]
33+
zlib = ["dep:libz-sys"]
3334
deprecated = []
3435
threadsafe = []
3536

hdf5-sys/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ edition = "2018"
1212
links = "hdf5"
1313
readme = "README.md"
1414
categories = ["ffi", "filesystem", "science"]
15+
rust-version = "1.60"
1516

1617
[dependencies]
1718
libc = "0.2"
@@ -22,12 +23,12 @@ hdf5-src = { path = "../hdf5-src", version = "0.8.1", optional = true } # !V
2223
# Please see README for further explanation of these feature flags
2324
[features]
2425
default = []
25-
mpio = ["mpi-sys"]
26-
hl = ["hdf5-src/hl"]
27-
threadsafe = ["hdf5-src/threadsafe"]
28-
zlib = ["libz-sys", "hdf5-src/zlib"]
29-
static = ["hdf5-src"]
30-
deprecated = ["hdf5-src/deprecated"]
26+
mpio = ["dep:mpi-sys"]
27+
hl = ["hdf5-src?/hl"]
28+
threadsafe = ["hdf5-src?/threadsafe"]
29+
zlib = ["dep:libz-sys", "hdf5-src?/zlib"]
30+
static = ["dep:hdf5-src"]
31+
deprecated = ["hdf5-src?/deprecated"]
3132

3233
[build-dependencies]
3334
libloading = "0.7"

hdf5-sys/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ pub struct Header {
168168
pub have_direct: bool,
169169
pub have_parallel: bool,
170170
pub have_threadsafe: bool,
171+
pub have_zlib: bool,
172+
pub have_no_deprecated: bool,
171173
pub version: Version,
172174
}
173175

@@ -193,6 +195,10 @@ impl Header {
193195
hdr.have_parallel = value > 0;
194196
} else if name == "H5_HAVE_THREADSAFE" {
195197
hdr.have_threadsafe = value > 0;
198+
} else if name == "H5_HAVE_FILTER_DEFLATE" {
199+
hdr.have_zlib = value > 0;
200+
} else if name == "H5_NO_DEPRECATED_SYMBOLS" {
201+
hdr.have_no_deprecated = value > 0;
196202
}
197203
}
198204

@@ -571,6 +577,7 @@ impl LibrarySearcher {
571577
}
572578
let config = Config { inc_dir: inc_dir.clone(), link_paths, header };
573579
validate_runtime_version(&config);
580+
config.check_against_features_required();
574581
config
575582
} else {
576583
panic!("Unable to determine HDF5 location (set HDF5_DIR to specify it manually).");
@@ -634,6 +641,24 @@ impl Config {
634641
println!("cargo:have_threadsafe=1");
635642
}
636643
}
644+
645+
fn check_against_features_required(&self) {
646+
if feature_enabled("DEPRECATED") {
647+
assert!(!self.header.have_no_deprecated, "Required deprecated symbols are not present")
648+
}
649+
if feature_enabled("THREADSAFE") {
650+
assert!(
651+
self.header.have_threadsafe,
652+
"Required threadsafe but library was not build using the threadsafe option"
653+
);
654+
}
655+
if feature_enabled("ZLIB") {
656+
assert!(
657+
self.header.have_zlib,
658+
"Required zlib filter but library does not have builtin support for this options"
659+
);
660+
}
661+
}
637662
}
638663

639664
fn main() {

0 commit comments

Comments
 (0)