Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Add caching and Ninja builds
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber committed Jul 16, 2024
1 parent 2b33b25 commit bc66f38
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 22 deletions.
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ FROM quay.io/pypa/manylinux2014_${TARGET_ARCH}:2024-07-15-c746fd8

ARG BOOST_VERSION=1.85.0
ARG HDF5_VERSION=1.14.2
ARG NINJA_VERSION=1.12.1

ENV HDF5_VERSION=${HDF5_VERSION} \
HDF5_DIR=/usr/local \
BOOST_DIR=/usr/local \
BOOST_VERSION=${BOOST_VERSION}

COPY install_libaec.sh install_hdf5.sh install_boost.sh /tmp/
RUN bash /tmp/install_libaec.sh
RUN bash /tmp/install_hdf5.sh
RUN bash /tmp/install_boost.sh
RUN --mount=type=cache,target=/cache \
if [[ "$TARGET_ARCH" == "aarch64" ]]; then NINJA_ARCH="-aarch64"; else NINJA_ARCH=""; fi \
&& curl -fsSL -o /cache/ninja-linux.zip https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-linux${NINJA_ARCH}.zip \
&& unzip /cache/ninja-linux.zip -d /usr/local/bin
COPY install_libaec.sh libaec_cmakelists.patch install_hdf5.sh install_boost.sh /tmp/
RUN --mount=type=cache,target=/cache \
bash /tmp/install_libaec.sh
RUN --mount=type=cache,target=/cache \
bash /tmp/install_hdf5.sh
RUN --mount=type=cache,target=/cache \
bash /tmp/install_boost.sh
10 changes: 6 additions & 4 deletions install_boost.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
set -euo pipefail

BOOST_DOWNLOAD_FILE="boost-cmake.tar.xz"
pushd /tmp

BOOST_DOWNLOAD_FILE="/cache/boost-cmake.tar.xz"
curl -fsSL -o $BOOST_DOWNLOAD_FILE https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz
tar -xvf $BOOST_DOWNLOAD_FILE
tar -xf $BOOST_DOWNLOAD_FILE -C /tmp
pushd boost-${BOOST_VERSION}

./boostrap.sh --prefix=${BOOST_DIR}
./bootstrap.sh --prefix=${BOOST_DIR}
# We have to explicitly include cmakedir here so that cmake files are installed
./b2 variant=release toolset=gcc --with-headers --cmakedir=${BOOST_DIR}/lib/cmake install

popd

rm -rf boost-${BOOST_VERSION} ${BOOST_DOWNLOAD_FILE}
rm -rf boost-${BOOST_VERSION}
22 changes: 14 additions & 8 deletions install_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ pushd /tmp
ldconfig

echo "Downloading & unpacking HDF5 ${HDF5_VERSION}"
HDF5_DOWNLOAD_FILE="/cache/hdf5-${HDF5_VERSION}.tar.gz"
# Remove trailing .*, to get e.g. '1.12' ↓
curl -fsSLO "https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_VERSION%.*}/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.gz"
tar -xzvf hdf5-$HDF5_VERSION.tar.gz
pushd hdf5-$HDF5_VERSION
chmod u+x autogen.sh
curl -fsSL -o $HDF5_DOWNLOAD_FILE "https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_VERSION%.*}/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.gz"
tar -xzf $HDF5_DOWNLOAD_FILE -C /tmp
mkdir -p hdf5-${HDF5_VERSION}/build
pushd hdf5-$HDF5_VERSION/build

echo "Configuring, building & installing HDF5 ${HDF5_VERSION} to ${HDF5_DIR}"
./configure --prefix $HDF5_DIR --enable-build-mode=production --with-szlib
make -j $(nproc)
make install
cmake -G "Ninja" \
-DCMAKE_INSTALL_PREFIX=${HDF5_DIR} \
-DHDF5_BUILD_CPP_LIB=ON \
-DHDF5_ENABLE_Z_LIB_SUPPORT=ON \
-DHDF5_ENABLE_SZIP_SUPPORT=ON \
-DHDF5_BUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
..
ninja install
popd

# Clean up to limit the size of the Docker image
echo "Cleaning up unnecessary files"
rm -r hdf5-$HDF5_VERSION
rm hdf5-$HDF5_VERSION.tar.gz

yum -y erase zlib-devel
17 changes: 11 additions & 6 deletions install_libaec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ pushd /tmp
aec_version="1.0.6"

echo "Downloading libaec"
LIBAEC_DOWNLOAD_FILE="/cache/libaec-${aec_version}.tar.gz"
# The URL includes a hash, so it needs to change if the version does
curl -fsSLO https://gitlab.dkrz.de/k202009/libaec/uploads/45b10e42123edd26ab7b3ad92bcf7be2/libaec-${aec_version}.tar.gz
tar zxf libaec-$aec_version.tar.gz
curl -fsSL -o $LIBAEC_DOWNLOAD_FILE https://gitlab.dkrz.de/k202009/libaec/uploads/45b10e42123edd26ab7b3ad92bcf7be2/libaec-${aec_version}.tar.gz
tar -zxf $LIBAEC_DOWNLOAD_FILE -C /tmp

echo "Building & installing libaec"
mkdir -p libaec-${aec_version}/build
pushd libaec-$aec_version
./configure
make
make install
patch -p0 < /tmp/libaec_cmakelists.patch
pushd build
cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTING=OFF ..
ninja install

popd

# Clean up the files from the build
popd
rm -r libaec-$aec_version libaec-$aec_version.tar.gz
rm -r libaec-$aec_version
11 changes: 11 additions & 0 deletions libaec_cmakelists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- CMakeLists.txt 2024-07-16 15:43:44.268427707 +0000
+++ CMakeLists.txt.new 2024-07-16 15:43:38.540403952 +0000
@@ -12,6 +12,8 @@
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
+
# Check for __builtin_clzll for faster decoding
include(CheckCSourceCompiles)
check_c_source_compiles(

0 comments on commit bc66f38

Please sign in to comment.