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
206 changes: 206 additions & 0 deletions .github/workflows/test-build-c.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
name: C Build Tests

on:
push:
branches: [main, dev]
pull_request:
workflow_dispatch:

jobs:
# build different hdf5 artefacts
build-hdf5:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
include:
- name: system
prefix: /usr/local
artefact-name: hdf5-system
- name: custom
prefix: /opt/hdf5
artefact-name: hdf5-custom
container: gcc:7
name: Build HDF5 - ${{ matrix.name }}
steps:
- name: Use archive repositories for Debian Buster
run: |
sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list
sed -i '/buster-updates/d' /etc/apt/sources.list

- name: Install build dependencies
run: |
apt-get update
apt-get install -y wget

- name: Cache HDF5 build
id: cache-hdf5
uses: actions/cache@v4
with:
path: /tmp/${{ matrix.artefact-name }}
key: hdf5-1.14.6-${{ matrix.name }}-gcc7-${{ runner.os }}-v1
restore-keys: |
hdf5-1.14.6-${{ matrix.name }}-gcc7-${{ runner.os }}-
hdf5-1.14.6-${{ matrix.name }}-gcc7-

- name: Download and build HDF5
if: steps.cache-hdf5.outputs.cache-hit != 'true'
run: |
# use HDF5 1.14.x
wget https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.6/hdf5-1.14.6.tar.gz
tar -xzf hdf5-1.14.6.tar.gz
cd hdf5-1.14.6

# configure for specified prefix
./configure --prefix=${{ matrix.prefix }}
make -j$(nproc)

# staged for artefact
make install DESTDIR=/tmp/${{ matrix.artefact-name }}

- name: Create tarball artefact
run: |
cd /tmp/${{ matrix.artefact-name }}
tar -czf /tmp/${{ matrix.artefact-name }}.tar.gz .

- name: Upload HDF5 artefact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artefact-name }}
path: /tmp/${{ matrix.artefact-name }}.tar.gz
retention-days: 7
compression-level: 0

# test gcc 7-14
test-gcc-versions:
needs: build-hdf5
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
gcc-version: [7, 8, 9, 10, 11, 12, 13, 14]
container: gcc:${{ matrix.gcc-version }}
name: GCC ${{ matrix.gcc-version }} - system-wide installation
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Download HDF5 system artefact
uses: actions/download-artifact@v4
with:
name: hdf5-system

- name: Install HDF5 system-wide
run: |
tar -xzf hdf5-system.tar.gz -C /
ldconfig

- name: Use archive repositories for Debian Buster
if: matrix.gcc-version == 7 || matrix.gcc-version == 8
run: |
# gcc 7, 8 use debian buster which reached EOL
sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list
sed -i '/buster-updates/d' /etc/apt/sources.list

- name: Install build dependencies
run: |
apt-get update
apt-get install -y autoconf automake libtool pkg-config

- name: Generate configure script
run: autoreconf -i

- name: Run build test
run: |
./tests/test_build/test_build_c.sh --only system

- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: logs-gcc-${{ matrix.gcc-version }}-system
path: tests/test_build/logs/
retention-days: 7

# test different methods of specifying HDF5
test-hdf5-methods:
needs: build-hdf5
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
# system-wide
- method: system
artefact: hdf5-system
test-name: system
setup: ""
lib-path: ""
description: "system-wide HDF5 at /usr/local"

# explicit path
- method: explicit
artefact: hdf5-custom
test-name: explicit
setup: "export HDF5_TEST_PATH=/opt/hdf5"
lib-path: /opt/hdf5/lib
description: "explicit --with-hdf5=/opt/hdf5"

# via environment variable
- method: env_var
artefact: hdf5-custom
test-name: hdf5_root
setup: "export HDF5_ROOT=/opt/hdf5"
lib-path: /opt/hdf5/lib
description: "environment variable HDF5_ROOT"

container: gcc:11
name: HDF5 ${{ matrix.method }}
env:
LD_LIBRARY_PATH: ${{ matrix.lib-path }}
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Download HDF5 artefact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artefact }}

- name: Install HDF5
run: |
echo "Installing HDF5 for: ${{ matrix.description }}"
tar -xzf ${{ matrix.artefact }}.tar.gz -C /
# update library cache for system-wide installation
if [ "${{ matrix.method }}" = "system" ]; then
ldconfig
fi

- name: Install build dependencies
run: |
apt-get update
apt-get install -y autoconf automake libtool pkg-config

- name: Generate configure script
run: autoreconf -i

- name: Run build test
run: |
# set test-specific environment
${{ matrix.setup }}

# run test
echo "Testing: ${{ matrix.description }}"
./tests/test_build/test_build_c.sh --only ${{ matrix.test-name }}

- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: logs-hdf5-${{ matrix.method }}
path: tests/test_build/logs/
retention-days: 7
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ The configure script supports several options:

##### HDF5 Location

- `--with-hdf5=/path/to/hdf5`
- It also recognises the environment variables `HDF5_ROOT`, `HDF5_HOME`
and `HDF5_DIR`
- `--with-hdf5=/path/to/hdf5`: Specify HDF5 installation path
- If not specified, the configure script searches for HDF5 in the following
order:
1. System paths (standard locations)
2. `$HDF5_ROOT`
3. `$HDF5_HOME`
4. `$HDF5_DIR`

##### Compression Support

Expand Down
29 changes: 17 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ AC_ARG_ENABLE([asan],
# --- Check for HDF5 ---

AC_ARG_WITH([hdf5],
[AS_HELP_STRING([--with-hdf5=PATH], [Path to HDF5 installation])],
[AS_HELP_STRING([--with-hdf5=PATH],
[Path to HDF5 installation. If not specified, searches in order: system paths, $HDF5_ROOT, $HDF5_HOME, $HDF5_DIR])],
[HDFDIR="$withval"],
[])

HDF5_OK=no

AS_IF([test -n "$HDFDIR"], [
AC_MSG_NOTICE([Test HDFDIR provided])
AC_MSG_NOTICE([Testing HDF5 at $HDFDIR])
CPPFLAGS="$CPPFLAGS -I$HDFDIR/include"
LDFLAGS="$LDFLAGS -L$HDFDIR/lib"

Expand All @@ -37,16 +38,10 @@ AS_IF([test -n "$HDFDIR"], [
AC_DEFINE([HAVE_HDF5], [1], [Define if HDF5 is available])
HDF5_OK=yes
], [
AC_MSG_NOTICE([libhdf5 not found on HDFDIR])
AS_VAR_SET([CPPFLAGS], [`echo "$CPPFLAGS" | sed "s|-I$HDFDIR/include||g"`])
AS_VAR_SET([LDFLAGS], [`echo "$LDFLAGS" | sed "s|-L$HDFDIR/lib||g"`])
HDF5_OK=no
AC_MSG_ERROR([libhdf5 not found at $HDFDIR/lib])
])
], [
AC_MSG_NOTICE([hdf5.h not found on HDFDIR])
AS_VAR_SET([CPPFLAGS], [`echo "$CPPFLAGS" | sed "s|-I$HDFDIR/include||g"`])
AS_VAR_SET([LDFLAGS], [`echo "$LDFLAGS" | sed "s|-L$HDFDIR/lib||g"`])
HDF5_OK=no
AC_MSG_ERROR([hdf5.h not found at $HDFDIR/include])
])
])

Expand All @@ -69,7 +64,6 @@ AS_IF([test "x$HDF5_OK" != xyes], [
])

if test "x$HDF5_OK" != xyes; then
AC_MSG_NOTICE([--with-hdf5 not provided, checking common HDF5 environment variables...])
for var in HDF5_ROOT HDF5_HOME HDF5_DIR; do
eval dir=\$$var
if test -n "$dir"; then
Expand All @@ -84,11 +78,13 @@ if test "x$HDF5_OK" != xyes; then
HDFDIR="$dir"
AC_MSG_NOTICE([HDF5 found in $HDFDIR])
], [
AC_MSG_NOTICE([libhdf5 not found at $dir/lib])
AS_VAR_SET([CPPFLAGS], [`echo "$CPPFLAGS" | sed "s|-I$dir/include||g"`])
AS_VAR_SET([LDFLAGS], [`echo "$LDFLAGS" | sed "s|-L$dir/lib||g; s|-Wl,-rpath,$dir/lib||g"`])
HDF5_OK=no
])
], [
AC_MSG_NOTICE([hdf5.h not found at $dir/include])
AS_VAR_SET([CPPFLAGS], [`echo "$CPPFLAGS" | sed "s|-I$dir/include||g"`])
AS_VAR_SET([LDFLAGS], [`echo "$LDFLAGS" | sed "s|-L$dir/lib||g; s|-Wl,-rpath,$dir/lib||g"`])
HDF5_OK=no
Expand All @@ -99,7 +95,7 @@ if test "x$HDF5_OK" != xyes; then
fi

AS_IF([test "x$HDF5_OK" != xyes], [
AC_MSG_ERROR([HDF5 not found])
AC_MSG_ERROR([HDF5 not found. Use --with-hdf5=/path or set HDF5_ROOT, HDF5_HOME, or HDF5_DIR])
])

# ---------------- Compression Option ----------------
Expand Down Expand Up @@ -216,3 +212,12 @@ AS_IF([test "x$asan_build" = "xyes"], [

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

# --- Configuration Summary ---
AS_IF([test "x$HDF5_OK" = xyes], [
AS_IF([test -n "$HDFDIR"], [
AC_MSG_NOTICE([HDF5 library found at: $HDFDIR])
], [
AC_MSG_NOTICE([HDF5 library found in system paths])
])
])
8 changes: 7 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// long options structure for getopt_long
static const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"no-metadata", no_argument, NULL, 'N'},
{"with-metadata", no_argument, NULL, 'M'},
{"output-dir", required_argument, NULL, 'o'},
Expand Down Expand Up @@ -40,6 +41,7 @@ static void print_usage(const char *program_name)
fprintf(stderr, " - NOT YET IMPLEMENTED\n");
fprintf(stderr, " -t, --timeout SECS Timeout in seconds\n");
fprintf(stderr, " - NOT YET IMPLEMENTED\n");
fprintf(stderr, " -v, --version Display the version\n");
fprintf(stderr, " -h, --help Show this help message\n");
fprintf(stderr, "\nEnvironment variables:\n");
fprintf(stderr, " MIB2H5_SHUFFLE Shuffle level for Blosc compression (default: 2)\n");
Expand All @@ -61,7 +63,7 @@ int main(int argc, char *argv[])

// parse options
int option_index = 0;
while ((opt = getopt_long(argc, argv, "o:d:k:r:t:cMNh", long_options,
while ((opt = getopt_long(argc, argv, "o:d:k:r:t:cMNvh", long_options,
&option_index)) != -1) {
switch (opt) {
case 'o':
Expand Down Expand Up @@ -94,6 +96,10 @@ int main(int argc, char *argv[])
case 'N':
include_metadata = false;
break;
case 'v':
printf("%d.%d.%d\n", MIB2H5_VERSION_MAJOR, MIB2H5_VERSION_MINOR,
MIB2H5_VERSION_PATCH);
return 0;
case 'h':
print_usage(argv[0]);
return 0;
Expand Down
Loading