hdf5: refactor to reduce downstream closure size

* Only build static libs by default when stdenv.hostPlatform.isStatic
* Add separate -bin output
* Move h5hlcc/c++ dev binaries to -dev output
* Default to building with C++ support to cut down
  on duplicated hdf5/hdf5-cpp in downstream closures
This commit is contained in:
Ryan Burns 2023-12-27 17:27:10 -08:00
parent ddd6c029b5
commit 9046690c73
3 changed files with 35 additions and 5 deletions

View File

@ -78,13 +78,15 @@ let
if hdf5-forced != null
then hdf5-forced
else
hdf5.override {
hdf5.override ({
usev110Api = useHdf5v110Api;
mpiSupport = enableMPI;
inherit mpi;
szipSupport = enableSzip;
inherit szip;
};
} // lib.optionalAttrs enableMPI {
cppSupport = false;
});
netcdf-custom =
if netcdf-forced != null
then netcdf-forced

View File

@ -3,7 +3,7 @@
, fetchurl
, cmake
, removeReferencesTo
, cppSupport ? false
, cppSupport ? true
, fortranSupport ? false
, fortran
, zlibSupport ? true
@ -13,6 +13,7 @@
, mpiSupport ? false
, mpi
, enableShared ? !stdenv.hostPlatform.isStatic
, enableStatic ? stdenv.hostPlatform.isStatic
, javaSupport ? false
, jdk
, usev110Api ? false
@ -58,7 +59,7 @@ stdenv.mkDerivation rec {
;
};
outputs = [ "out" "dev" ];
outputs = [ "out" "dev" "bin" ];
nativeBuildInputs = [ removeReferencesTo cmake ]
++ optional fortranSupport fortran;
@ -72,6 +73,7 @@ stdenv.mkDerivation rec {
cmakeFlags = [
"-DHDF5_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake"
"-DBUILD_STATIC_LIBS=${lib.boolToString enableStatic}"
] ++ lib.optional stdenv.isDarwin "-DHDF5_BUILD_WITH_INSTALL_NAME=ON"
++ lib.optional cppSupport "-DHDF5_BUILD_CPP_LIB=ON"
++ lib.optional fortranSupport "-DHDF5_BUILD_FORTRAN=ON"
@ -85,10 +87,33 @@ stdenv.mkDerivation rec {
postInstall = ''
find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
moveToOutput 'bin/' "''${!outputBin}"
moveToOutput 'bin/h5cc' "''${!outputDev}"
moveToOutput 'bin/h5c++' "''${!outputDev}"
moveToOutput 'bin/h5fc' "''${!outputDev}"
moveToOutput 'bin/h5pcc' "''${!outputDev}"
moveToOutput 'bin/h5hlcc' "''${!outputDev}"
moveToOutput 'bin/h5hlc++' "''${!outputDev}"
'' + lib.optionalString enableShared
# The shared build creates binaries with -shared suffixes,
# so we remove these suffixes.
''
mv ''${!outputBin}/bin/h5clear{-shared,}
mv ''${!outputBin}/bin/h5copy{-shared,}
mv ''${!outputBin}/bin/h5debug{-shared,}
mv ''${!outputBin}/bin/h5delete{-shared,}
mv ''${!outputBin}/bin/h5diff{-shared,}
mv ''${!outputBin}/bin/h5dump{-shared,}
mv ''${!outputBin}/bin/h5format_convert{-shared,}
mv ''${!outputBin}/bin/h5import{-shared,}
mv ''${!outputBin}/bin/h5jam{-shared,}
mv ''${!outputBin}/bin/h5ls{-shared,}
mv ''${!outputBin}/bin/h5mkgrp{-shared,}
mv ''${!outputBin}/bin/h5repack{-shared,}
mv ''${!outputBin}/bin/h5repart{-shared,}
mv ''${!outputBin}/bin/h5stat{-shared,}
mv ''${!outputBin}/bin/h5unjam{-shared,}
mv ''${!outputBin}/bin/h5watch{-shared,}
'';
enableParallelBuilding = true;

View File

@ -9195,7 +9195,10 @@ with pkgs;
hdf5_1_10 = callPackage ../tools/misc/hdf5/1.10.nix { };
hdf5-mpi = hdf5.override { mpiSupport = true; };
hdf5-mpi = hdf5.override {
mpiSupport = true;
cppSupport = false;
};
hdf5-cpp = hdf5.override { cppSupport = true; };