Skip to content

Commit a64c141

Browse files
authored
Merge pull request #29 from aldanor/feature/bindgen-pubconf
Rewrite build system, fix hbool_t, remove libhdf5-lib crate
2 parents 2dfbd19 + 0cc67bf commit a64c141

File tree

15 files changed

+916
-240
lines changed

15 files changed

+916
-240
lines changed

.travis.yml

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,56 @@
11
sudo: false
22
language: rust
3-
rust:
4-
- stable
5-
- beta
6-
- nightly
3+
notifications:
4+
email:
5+
on_success: never
6+
addons:
7+
apt:
8+
packages:
9+
- pkg-config
10+
11+
matrix:
12+
include:
13+
- name: xenial-stable-conda-1.10.4
14+
os: linux
15+
dist: xenial
16+
rust: stable
17+
env:
18+
- H5_CONDA=1.10.4
19+
- name: xenial-beta-apt-1.8.13
20+
os: linux
21+
dist: xenial
22+
rust: beta
23+
addons:
24+
apt:
25+
packages:
26+
- libhdf5-dev
27+
env:
28+
- HDF5_VERSION=1.8.16
29+
- name: trusty-nightly-apt-1.8.11
30+
os: linux
31+
dist: trusty
32+
rust: nightly
33+
addons:
34+
apt:
35+
packages:
36+
- libhdf5-serial-dev
37+
- name: macos-stable-brew-1.10.*
38+
os: osx
39+
rust: stable
40+
env:
41+
- H5_BREW=1.8
42+
- name: macos-beta-brew-1.8.*
43+
os: osx
44+
rust: beta
45+
env:
46+
- H5_BREW=1.10
47+
- name: macos-nightly-conda-1.8.9
48+
os: osx
49+
rust: nightly
50+
env:
51+
- H5_CONDA=1.8.9
52+
- HDF5_VERSION=1.8.9
53+
754
before_script:
855
- |
956
if [ $TRAVIS_RUST_VERSION = "nightly" ]; then
@@ -18,32 +65,48 @@ script:
1865
fi
1966
fi
2067
- cargo clean
21-
- cargo test -v -p hdf5-derive
22-
- cargo clean
23-
- cargo build -v
68+
- cargo build -vv
2469
- cargo test -v --no-run --all --exclude hdf5-derive
2570
- cargo test -v --all --exclude hdf5-derive
71+
- cargo clean
72+
- cargo test -v -p hdf5-derive
2673
- |
27-
if [ $TRAVIS_RUST_VERSION = "stable" ] && [ `uname` = "Linux" ]; then
74+
if [ $TRAVIS_RUST_VERSION = "stable" ] && [ `uname` = "Linux" ] &&\
75+
[ $TRAVIS_BRANCH = "master" ] && [ $TRAVIS_PULL_REQUEST = "false" ]; then
76+
cargo clean;
2877
cargo doc --no-deps;
2978
fi
30-
addons:
31-
apt:
32-
packages:
33-
- libhdf5-serial-dev
34-
- pkg-config
35-
notifications:
36-
email:
37-
on_success: never
38-
os:
39-
- linux
40-
- osx
4179
before_install:
42-
- if [ `uname` = "Darwin" ]; then
80+
- |
81+
if [ `uname` = "Darwin" ] && [ ! -z "$H5_BREW" ]; then
4382
brew update >/dev/null;
4483
brew tap homebrew/science;
45-
brew install hdf5;
84+
brew install hdf5@${H5_BREW};
85+
fi
86+
- |
87+
if [ ! -z "$H5_CONDA" ]; then
88+
if [ `uname` = "Darwin" ]; then
89+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;
90+
# note: this is only required for older HDF5 installations on OS X
91+
export DYLD_FALLBACK_LIBRARY_PATH="$HOME/miniconda/envs/testenv/lib";
92+
else
93+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
94+
fi
95+
bash miniconda.sh -b -p $HOME/miniconda;
96+
export PATH="$HOME/miniconda/bin:$PATH";
97+
hash -r;
98+
conda config --set always_yes yes --set changeps1 no;
99+
conda info -a;
100+
conda create -q -n testenv hdf5=${H5_CONDA};
101+
export HDF5_DIR="$HOME/miniconda/envs/testenv";
102+
export RUSTFLAGS="-C link-args=-Wl,-rpath,$HOME/miniconda/envs/testenv/lib";
103+
fi
104+
- |
105+
if [ $TRAVIS_OS_NAME = "linux" ]; then
106+
pkg-config hdf5 --modversion || true;
46107
fi
108+
- find /usr -name '*hdf5*' || true
109+
- find /usr -name 'H5*.h' || true
47110
after_success: |
48111
[ $TRAVIS_BRANCH = "master" ] &&
49112
[ $TRAVIS_PULL_REQUEST = "false" ] &&

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ members = [
44
"hdf5-types",
55
"hdf5-derive",
66
"libhdf5-sys",
7-
"libhdf5-lib",
87
]
98
exclude = [
109
"*.yml"

README.md

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ fn main() -> h5::Result<()> {
6767

6868
### Platforms
6969

70-
`hdf5-rs` is known to run on these platforms:
71-
72-
- Linux (tested on Travis CI, HDF5 v1.8.4)
73-
- OS X (tested on Travis CI, HDF5 v1.8.16)
74-
- Windows (tested on AppVeyor, MSVC target, HDF5 v1.8.16, VS2015 x64)
70+
`hdf5-rs` is known to run on these platforms: Linux, macOS, Windows (tested on Travis CI and
71+
AppVeyor, HDF5 1.8 and 1.10, system installations and conda environments).
7572

7673
### Rust
7774

78-
`hdf5-rs` is tested for all three official release channels, and requires Rust compiler
79-
of version 1.13 or newer.
75+
`hdf5-rs` is tested continuously for all three official release channels, and requires
76+
a modern Rust compiler (e.g. of version 1.31 or later).
77+
78+
### HDF5
79+
80+
Required HDF5 version is 1.8.4 or newer. The library doesn't have to be built with
81+
threadsafe option enabled.
8082

8183
## Building
8284

@@ -88,38 +90,56 @@ enabled or disabled at compile time. While this allows supporting multiple versi
8890
in a single codebase, this is something the library user should be aware of in case they
8991
choose to use the low level FFI bindings.
9092

91-
### Linux, OS X
93+
### Environment variables
94+
95+
If `HDF5_DIR` is set, the build script will look there (and nowhere else) for HDF5
96+
headers and binaries (i.e., it will look for headers under `$HDF5_DIR/include`).
97+
98+
If `HDF5_VERSION` is set, the build script will check that the library version matches
99+
the specified version string; in some cases it may also be used by the build script to
100+
help locating the library (e.g. when both 1.8 and 1.10 are installed via Homebrew on macOS).
101+
102+
### conda
103+
104+
It is possible to link against `hdf5` conda package; a few notes and tips:
105+
106+
- Point `HDF5_DIR` to conda environment root.
107+
- The build script knows about conda environment layout specifics and will adjust
108+
paths accordingly (e.g. `Library` subfolder in Windows environments).
109+
- On Windows, environment's `bin` folder must be in `PATH` (or the environment can
110+
be activated prior to running cargo).
111+
- On Linux / macOS, it is recommended to set rpath, e.g. by setting
112+
`RUSTFLAGS="-C link-args=-Wl,-rpath,$HDF5_DIR/lib"`.
113+
- For old versions of HDF5 conda packages on macOS, it may also be necessary to set
114+
`DYLD_FALLBACK_LIBRARY_PATH="$HDF5_DIR/lib"`.
92115

93-
The build script of `libhdf5-lib` crate will try to use `pkg-config` if it's available
94-
to deduce HDF5 library location. This is sufficient for most standard setups.
116+
### Linux
95117

96-
There are also two environment variables that may be of use if the library location and/or name
97-
is unconventional:
118+
The build script will attempt to use pkg-config first, which will likely work out without
119+
further tweaking for the more recent versions of HDF5. The build script will then also look
120+
in some standard locations where HDF5 can be found after being apt-installed on Ubuntu.
98121

99-
- `HDF5_LIBDIR` – added to library search path during the build step
100-
- `HDF5_LIBNAME` – library name (defaults to `hdf5`)
122+
### macOS
101123

102-
Note that `cargo clean` is requred before rebuilding if any of those variables are changed.
124+
On macOS, the build script will attempt to locate HDF5 via Homebrew if it's available.
125+
If both 1.8 and 1.10 are installed and available, the default (1.10) will be used
126+
unless `HDF5_VERSION` is set.
103127

104128
### Windows
105129

106130
`hdf5-rs` fully supports MSVC toolchain, which allows using the
107131
[official releases](https://www.hdfgroup.org/downloads/index.html) of
108-
HDF5 and is generally the recommended way to go. That being said, previous experiments have shown
109-
that all tests pass on the `gnu` target as well, one just needs to be careful with building the
110-
HDF5 binary itself and configuring the build environment.
132+
HDF5 and is generally the recommended way to go. That being said, previous experiments have
133+
shown that all tests pass on the `gnu` target as well, one just needs to be careful with
134+
building the HDF5 binary itself and configuring the build environment.
111135

112136
Few things to note when building on Windows:
113137

114138
- `hdf5.dll` should be available in the search path at build time and runtime (both `gnu` and `msvc`).
115139
This normally requires adding the `bin` folder of HDF5 installation to `PATH`. If using an official
116-
HDF5 release (`msvc` only), this will be done automatically by the installer.
117-
- If `HDF5_LIBDIR` or `HDF5_LIBNAME` change, `cargo clean` is required before rebuilding.
140+
HDF5 release (`msvc` only), this will typically be done automatically by the installer.
118141
- `msvc`: installed Visual Studio version should match the HDF5 binary (2013 or 2015). Note that it
119142
is not necessary to run `vcvars` scripts; Rust build system will take care of that.
120-
- In most cases, it is not necessary to manually set `HDF5_LIBDIR` as it would be inferred from the
121-
search path (both `gnu` and `msvc`). This also implies that the official releases should work
122-
out of the box.
123143
- When building for either target, make sure that there are no conflicts in the search path (e.g.,
124144
some binaries from MinGW toolchain may shadow MSVS executables or vice versa).
125145
- The recommended platform for `gnu` target is [TDM distribution](http://tdm-gcc.tdragon.net/) of

appveyor.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,29 @@ platform:
33
- x64
44
os: Visual Studio 2015
55
matrix:
6-
fast_finish: true
6+
fast_finish: false
77
skip_tags: true
8-
build: false
8+
build: off
9+
init:
10+
- set CONDA=C:\Miniconda36-x64
11+
- set PATH=%CONDA%;%CONDA%\Scripts;%CONDA%\Library\bin;C:\Rust\bin;%PATH%
912

1013
environment:
11-
TARGET: x86_64-pc-windows-msvc
12-
HDF5_BINDIR: "C:\\Program Files\\HDF_Group\\HDF5\\1.8.17\\bin"
13-
HDF5_URL: "https://support.hdfgroup.org/ftp/HDF5/prev-releases/hdf5-1.8/hdf5-1.8.17/bin/windows/extra/hdf5-1.8.17-win64-vs2015-shared.zip"
1414
matrix:
15-
- CHANNEL: 1.31.0
15+
- CHANNEL: 1.32.0
16+
H5_VERSION: 1.8.21
17+
H5_SOURCE: msi
1618
- CHANNEL: beta
19+
H5_VERSION: 1.10.0
20+
H5_SOURCE: msi
21+
H5_PIN: yes
1722
- CHANNEL: nightly
23+
H5_VERSION: 1.10.4
24+
H5_SOURCE: conda
25+
1826
install:
19-
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:CHANNEL}-${env:TARGET}.msi"
20-
- ps: Start-Process -FilePath msiexec -ArgumentList /i, rust-${env:CHANNEL}-${env:TARGET}.msi, INSTALLDIR="C:\Rust", /quiet -Wait
21-
- set PATH=%PATH%;C:\Rust\bin;%HDF5_BINDIR%
22-
- rustc -vV
23-
- cargo -vV
24-
- ps: Invoke-WebRequest ${env:HDF5_URL} -OutFile hdf5.zip
25-
- 7z x hdf5.zip -y
26-
- ps: Start-Process -FilePath msiexec -ArgumentList /i, "hdf5\HDF5-1.8.17-win64.msi", /quiet -Wait
27+
- python scripts\appveyor.py install-rust
28+
- python scripts\appveyor.py install-hdf5
2729

2830
test_script:
29-
- cd %APPVEYOR_BUILD_FOLDER%
30-
- cargo build -v
31-
- cargo test -v --no-run
32-
- cargo test -v --all --exclude hdf5-derive
31+
- python scripts\appveyor.py run-tests

hdf5-rs/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ parking_lot = "0.7"
2222
ndarray = "0.12"
2323
num-integer = "0.1"
2424
num-traits = "0.2"
25-
libhdf5-lib = { path = "../libhdf5-lib", version = "0.2.0" }
2625
libhdf5-sys = { path = "../libhdf5-sys", version = "0.2.0" }
2726
hdf5-types = { path = "../hdf5-types", version = "0.2.0" }
2827
hdf5-derive = { path = "../hdf5-derive", version = "0.2.0" }
@@ -34,4 +33,4 @@ scopeguard = "1.0"
3433
tempdir = "0.3"
3534

3635
[build-dependencies]
37-
libhdf5-lib = { path = "../libhdf5-lib", version = "0.2.0" }
36+
libhdf5-sys = { path = "../libhdf5-sys", version = "0.2.0" }

hdf5-rs/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn main() {
2-
libhdf5_lib::dump_build_flags();
2+
libhdf5_sys::emit_cfg_flags();
33
}

hdf5-rs/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ mod internal_prelude {
9595
#[cfg(test)]
9696
pub mod test;
9797

98-
/// Returns the version of the HDF5 library that the crate was compiled against.
98+
/// Returns the runtime version of the HDF5 library.
9999
pub fn hdf5_version() -> (u8, u8, u8) {
100-
h5lock!(libhdf5_lib::hdf5_version()).unwrap_or((0, 0, 0))
100+
use self::internal_prelude::c_uint;
101+
use libhdf5_sys::h5::H5get_libversion;
102+
let mut v: (c_uint, c_uint, c_uint) = (0, 0, 0);
103+
h5call!(H5get_libversion(&mut v.0, &mut v.1, &mut v.2))
104+
.map(|_| (v.0 as _, v.1 as _, v.2 as _))
105+
.unwrap_or((0, 0, 0))
101106
}
102107

103108
#[cfg(test)]
@@ -106,6 +111,6 @@ pub mod tests {
106111

107112
#[test]
108113
pub fn test_hdf5_version() {
109-
assert!(hdf5_version() >= (1, 8, 0));
114+
assert!(hdf5_version() >= (1, 8, 4));
110115
}
111116
}

libhdf5-lib/Cargo.toml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)