Skip to content

Commit 49b7b48

Browse files
committed
Use weak features
1 parent 122ecad commit 49b7b48

File tree

5 files changed

+38
-11
lines changed

5 files changed

+38
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Document workspace
4747
env:
4848
RUSTDOCFLAGS: "--cfg docsrs"
49-
run: cargo doc --features hdf5-sys/static,hdf5-sys/zlib,blosc,lzf
49+
run: cargo doc --features static,zlib,blosc,lzf
5050

5151
brew:
5252
name: brew

hdf5-src/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ edition.workspace = true
3030

3131
[features]
3232
hl = []
33-
zlib = ["libz-sys"]
33+
zlib = ["dep:libz-sys"]
3434
deprecated = []
3535
threadsafe = []
3636

hdf5-sys/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ hdf5-src = { workspace = true, optional = true }
2323
# Please see README for further explanation of these feature flags
2424
[features]
2525
default = []
26-
mpio = ["mpi-sys"]
27-
hl = ["hdf5-src/hl"]
28-
threadsafe = ["hdf5-src/threadsafe"]
29-
zlib = ["libz-sys", "hdf5-src/zlib"]
30-
static = ["hdf5-src"]
31-
deprecated = ["hdf5-src/deprecated"]
26+
mpio = ["dep:mpi-sys"]
27+
hl = ["hdf5-src?/hl"]
28+
threadsafe = ["hdf5-src?/threadsafe"]
29+
zlib = ["libz-sys", "hdf5-src?/zlib"]
30+
static = ["dep:hdf5-src"]
31+
deprecated = ["hdf5-src?/deprecated"]
3232

3333
[build-dependencies]
3434
libloading = "0.8"

hdf5-sys/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ pub struct Header {
175175
pub have_direct: bool,
176176
pub have_parallel: bool,
177177
pub have_threadsafe: bool,
178+
pub have_zlib: bool,
179+
pub have_no_deprecated: bool,
178180
pub version: Version,
179181
}
180182

@@ -200,6 +202,10 @@ impl Header {
200202
hdr.have_parallel = value > 0;
201203
} else if name == "H5_HAVE_THREADSAFE" {
202204
hdr.have_threadsafe = value > 0;
205+
} else if name == "H5_HAVE_FILTER_DEFLATE" {
206+
hdr.have_zlib = value > 0;
207+
} else if name == "H5_NO_DEPRECATED_SYMBOLS" {
208+
hdr.have_no_deprecated = value > 0;
203209
}
204210
}
205211

@@ -611,6 +617,7 @@ impl LibrarySearcher {
611617
if !(self.pkg_conf_found && cfg!(windows)) {
612618
validate_runtime_version(&config);
613619
}
620+
config.check_against_features_required();
614621
config
615622
} else {
616623
panic!("Unable to determine HDF5 location (set HDF5_DIR to specify it manually).");
@@ -675,6 +682,24 @@ impl Config {
675682
println!("cargo:have_threadsafe=1");
676683
}
677684
}
685+
686+
fn check_against_features_required(&self) {
687+
if feature_enabled("DEPRECATED") {
688+
assert!(!self.header.have_no_deprecated, "Required deprecated symbols are not present")
689+
}
690+
if feature_enabled("THREADSAFE") {
691+
assert!(
692+
self.header.have_threadsafe,
693+
"Required threadsafe but library was not build using the threadsafe option"
694+
);
695+
}
696+
if feature_enabled("ZLIB") {
697+
assert!(
698+
self.header.have_zlib,
699+
"Required zlib filter but library does not have builtin support for this options"
700+
);
701+
}
702+
}
678703
}
679704

680705
fn main() {

hdf5/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ edition.workspace = true
1515

1616
[features]
1717
default = []
18-
mpio = ["mpi-sys", "hdf5-sys/mpio"]
19-
lzf = ["lzf-sys", "errno"]
20-
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"]
2123
# The features with version numbers such as 1.10.3, 1.12.0 are metafeatures
2224
# and is only available when the HDF5 library is at least this version.
2325
# Features have_direct and have_parallel are also metafeatures and dependent

0 commit comments

Comments
 (0)