ENH: reproducible build naming for openmpi

- configure with the arch + package only for the prefix.
  When OPAL_PREFIX is unset, yields this type of information:

      Prefix: /linux64Gcc/openmpi-4.0.3
      Libdir: /linux64Gcc/openmpi-4.0.3/lib

  This ensures that the final binaries do not have the original build
  location, which makes for more reliable testing before shipping.

ENH: improve handling of header-only CGAL

- test for existence now also checks our cached build information
  for header-only configuration

- cleanup build artifacts from boost (in-source build).
  Skip install of generated man, info, doc pages.
  These are usually browsed/searched elsewhere anyhow.
This commit is contained in:
Mark Olesen
2021-10-22 18:02:04 +02:00
parent 325e3e230d
commit 0d0f439dde
6 changed files with 188 additions and 33 deletions

127
makeCGAL
View File

@ -37,27 +37,56 @@ then
dir="${2%/}" # <- *_ARCH_PATH
[ -d "$dir/include" ] || exit 2
# 2020-08-10: Needs reworking for header-only installations!
if [ -r "$dir/lib$WM_COMPILER_LIB_ARCH/libCGAL$EXT_SO" ]
# CGAL
[ -f "$dir"/include/CGAL/version.h ] || exit 2
unset _my_cgal_libdir
_cacheinfo="$dir"/share/openfoam-build
if [ -f "$_cacheinfo" ]
then
echo " CGAL include: $dir/include"
echo " CGAL library: $dir/lib$WM_COMPILER_LIB_ARCH"
# Additional information about boost
dir="${3%/}" # <- BOOST_ARCH_PATH
for root in "$dir" /usr
_my_cgal_libdir="$(sed -ne 's#^CGAL_HEADER_ONLY=##p' "$_cacheinfo" 2>/dev/null)"
if [ "$_my_cgal_libdir" = true ]
then
_my_cgal_libdir=header
fi
fi
if [ "$_my_cgal_libdir" != header ]
then
unset _my_cgal_libdir
libName="libCGAL"
for libdirName in "lib$WM_COMPILER_LIB_ARCH" lib
do
if [ -d "$root/include/boost" ] \
&& [ -r "$root/lib$WM_COMPILER_LIB_ARCH/libboost_system$EXT_SO" ]
if [ -r "$dir/$libdirName/$libName$EXT_SO" ]
then
echo " boost include: $root/include"
echo " boost library: $root/lib$WM_COMPILER_LIB_ARCH"
_my_cgal_libdir="$dir/$libdirName"
break
fi
done
exit 0
else
exit 2
fi
[ -n "$_my_cgal_libdir" ] || exit 2
echo " CGAL include: $dir/include"
echo " CGAL library: $_my_cgal_libdir"
# Additional information about boost
dir="${3%/}" # <- BOOST_ARCH_PATH
libName="libboost_system"
for root in "$dir" /usr
do
[ -d "$root/include/boost" ] || continue
for libdirName in "lib$WM_COMPILER_LIB_ARCH" lib
do
if [ -r "$root/$libdirName/$libName$EXT_SO" ]
then
echo " boost include: $root/include"
echo " boost library: $root/$libdirName"
exit 0 # Success
break 2
fi
done
done
exit 2
fi
#------------------------------------------------------------------------------
if : # Run from third-party directory
@ -350,6 +379,34 @@ else
exit 1
}
# Cleanup in-source build artifacts
(
set +e # Ignore errors
cd "$BOOST_SOURCE" 2>/dev/null || exit 0
echo "Cleanup in-source build artifacts: $BOOST_PACKAGE"
rm -f project-config.jam* user-config.jam*
rm -f b2 bjam bootstrap.log
rm -rf \
bin.v2 stage \
libs/config/checks/architecture/bin \
tools/build/src/engine/bootstrap \
tools/build/src/engine/bin.* \
;
true
)
# Unneeded generated files
for dir in share/doc share/info share/man
do
if [ -d "$BOOST_PREFIX/$dir" ]
then
echo "Discard $dir files to save space: $BOOST_PACKAGE"
rm -rf "$BOOST_PREFIX/$dir"
fi
done
rmdir "$BOOST_PREFIX"/share 2>/dev/null || true
fi
@ -463,6 +520,28 @@ recordCGALinfo()
{
CGAL_VERSION=$(sed -ne 's/^ *# *define *CGAL_VERSION_NR *\([0-9][0-9]*\).*$/\1/p' $CGAL_PREFIX/include/CGAL/version.h 2>/dev/null)
# which libdirName?
_my_cgal_libdir=unknown
for libdirName in "lib$WM_COMPILER_LIB_ARCH" lib
do
if [ -d "$CGAL_PREFIX/$libdirName" ]
then
_my_cgal_libdir="$libdirName"
break
fi
done
# which libdirName?
_my_boost_libdir=unknown
for libdirName in "lib$WM_COMPILER_LIB_ARCH" lib
do
if [ -d "$BOOST_PREFIX/$libdirName" ]
then
_my_boost_libdir="$libdirName"
break
fi
done
cat<<BUILD_INFO > "$buildInfoFile"
# Information from OpenFOAM build on '$(date)'
#
@ -473,8 +552,8 @@ MPFR=${MPFR_ARCH_PATH##*/}
CGAL_VERSION=$CGAL_VERSION
BOOST_VERSION=$BOOST_VERSION
CGAL_lib=lib$WM_COMPILER_LIB_ARCH
BOOST_lib=lib$WM_COMPILER_LIB_ARCH
CGAL_lib=$_my_cgal_libdir
BOOST_lib=$_my_boost_libdir
CGAL_HEADER_ONLY=${optHeadersOnly:-default}
BUILD_INFO
}
@ -503,11 +582,14 @@ cgalIsCurrent()
local info=$(sed -n -e '/^[A-Z]/p' $buildInfoFile 2>/dev/null)
[ -n "$info" ] || return 1
# Check of lib/ vs lib64/ could be spurious...
local libDirName="lib$WM_COMPILER_LIB_ARCH"
echo "checking information from existing build ..."
echo " ${CGAL_PREFIX}"
[ -f "$CGAL_PREFIX"/include/CGAL/version.h ] || return 1
infoValueEq CGAL "${CGAL_PREFIX##*/}" "$info" || return 1
infoValueEq BOOST "${BOOST_PREFIX##*/}" "$info" || return 1
infoValueEq GMP "${GMP_ARCH_PATH##*/}" "$info" || return 1
@ -660,6 +742,7 @@ CMAKE_OPTIONS
# For CGAL < 4.9, for installation into lib64/, not lib/
# Name only (not path) for CGAL_INSTALL_LIB_DIR
echo "----"
rm -rf "$CGAL_PREFIX"
set -x && \
${cmake:?} \
-DCMAKE_INSTALL_PREFIX="$CGAL_PREFIX" \
@ -677,7 +760,7 @@ CMAKE_OPTIONS
&& make install || exit 1
echo "----"
echo "create '\$CGAL_PREFIX/share/files'"
echo "create '\$CGAL_ARCH_PATH/share/files'"
echo "----"
mkdir -p "$CGAL_PREFIX"/share/src
rm -f "$CGAL_PREFIX"/share/files
@ -691,6 +774,16 @@ CMAKE_OPTIONS
fi
done
# Unneeded generated files
for dir in share/doc share/info share/man
do
if [ -d "$CGAL_PREFIX/$dir" ]
then
echo "Discard $dir files to save space: $CGAL_PACKAGE"
rm -rf "$CGAL_PREFIX/$dir"
fi
done
## Leave: rmdir "$CGAL_PREFIX"/share 2>/dev/null || true
# Record our build-status
recordCGALinfo

View File

@ -127,9 +127,6 @@ fi
#
# For 64-bit
# - FFTW itself will normally build into 'lib64',
# but provide --libdir on configure to be 100% certain
# - Third-Party builds into 'lib64'
# - system is normally built into 'lib64'
PKG_SOURCE="$(findSourceDir "$PACKAGE")"
PACKAGE="$(basename "$PKG_SOURCE")"
@ -186,7 +183,6 @@ else
cd "$PKG_BUILD" && set -x && \
"$PKG_SOURCE"/configure \
--prefix="$PKG_PREFIX" \
--libdir="$PKG_PREFIX/lib$WM_COMPILER_LIB_ARCH" \
--enable-shared --disable-static \
--disable-fortran \
$configOpt \
@ -200,6 +196,17 @@ else
exit 1
}
# Unneeded generated files
for dir in share/doc share/info share/man
do
if [ -d "$PKG_PREFIX/$dir" ]
then
echo "Discard $dir files to save space: $PACKAGE"
rm -rf "$PKG_PREFIX/$dir"
fi
done
rmdir "$PKG_PREFIX"/share 2>/dev/null || true
fi
#------------------------------------------------------------------------------

View File

@ -132,6 +132,17 @@ else
exit 1
}
# Unneeded generated files
for dir in share/doc share/info share/man
do
if [ -d "$PKG_PREFIX/$dir" ]
then
echo "Discard $dir files to save space: $PACKAGE"
rm -rf "$PKG_PREFIX/$dir"
fi
done
rmdir "$PKG_PREFIX"/share 2>/dev/null || true
fi
#------------------------------------------------------------------------------

View File

@ -178,23 +178,42 @@ else
rm -rf "$PKG_BUILD"
mkdir -p "$PKG_BUILD"
# reproducible build naming
local_destdir="$(dirname $PKG_PREFIX)"
local_prefix="/$(basename $local_destdir)/$(basename $PKG_PREFIX)"
local_destdir="$(dirname $local_destdir)"
echo
echo "configured prefix: $local_prefix"
echo "install directory: $local_destdir"
echo
cd "$PKG_BUILD" && set -x && \
"$PKG_SOURCE"/configure \
--prefix="$PKG_PREFIX" \
--libdir="$PKG_PREFIX/lib$WM_COMPILER_LIB_ARCH" \
--prefix="$local_prefix" \
--disable-fortran --disable-g \
--enable-shared --disable-static \
$configOpt \
&& set +x \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built: $PACKAGE" \
&& pkgconfigAdjust "$PKG_PREFIX"
&& make install DESTDIR="$local_destdir" \
&& echo "Built: $PACKAGE"
) || {
echo "Error building: $PACKAGE"
exit 1
}
# Unneeded generated files
for dir in share/doc share/info share/man
do
if [ -d "$PKG_PREFIX/$dir" ]
then
echo "Discard $dir files to save space: $PACKAGE"
rm -rf "$PKG_PREFIX/$dir"
fi
done
rmdir "$PKG_PREFIX"/share 2>/dev/null || true
fi
#------------------------------------------------------------------------------

View File

@ -64,7 +64,7 @@ _foamAddMan() { true; }
_foamAddPath() { true; }
#------------------------------------------------------------------------------
# Obtain version from OpenFOAM etc/config.sh file:
WM_MPLIB=MV2MPI # Ensure we get the correct MPI
WM_MPLIB=MVA2MPI # Ensure we get the correct MPI
_foamConfig mpi
PACKAGE="${FOAM_MPI:-system}"
@ -185,7 +185,6 @@ else
cd "$PKG_BUILD" && set -x && \
"$PKG_SOURCE"/configure \
--prefix="$PKG_PREFIX" \
--libdir="$PKG_PREFIX/lib$WM_COMPILER_LIB_ARCH" \
--disable-fortran --disable-g \
--enable-shared --disable-static \
$configOpt \

View File

@ -196,24 +196,50 @@ else
rm -rf "$PKG_BUILD"
mkdir -p "$PKG_BUILD"
# The real prefix is /path/ThirdParty/platforms/arch/openmpi-x.y.z
# but configure with prefix="/arch/openmpi-x.y.z"
# and install into "/path/ThirdParty/platforms"
# The final binaries are then independent of the build location and
# will always require OPAL_PREFIX to run
local_destdir="$(dirname $PKG_PREFIX)"
local_prefix="/$(basename $local_destdir)/$(basename $PKG_PREFIX)"
local_destdir="$(dirname $local_destdir)"
echo
echo "configured prefix: $local_prefix"
echo "install directory: $local_destdir"
echo
# Do not specify '--libdir' or relocating becomes difficult
cd "$PKG_BUILD" && set -x && \
"$PKG_SOURCE"/configure \
--prefix="$PKG_PREFIX" \
--libdir="$PKG_PREFIX/lib$WM_COMPILER_LIB_ARCH" \
--prefix="$local_prefix" \
--disable-orterun-prefix-by-default \
--enable-shared --disable-static \
--enable-mpi-fortran=none \
$configOpt \
&& set +x \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built: $PACKAGE" \
&& pkgconfigAdjust "$PKG_PREFIX"
&& make install DESTDIR="$local_destdir" \
&& echo "Built: $PACKAGE"
) || {
echo "Error building: $PACKAGE"
exit 1
}
# Unneeded generated files
for dir in share/doc share/info share/man
do
if [ -d "$PKG_PREFIX/$dir" ]
then
echo "Discard $dir files to save space: $PACKAGE"
rm -rf "$PKG_PREFIX/$dir"
fi
done
rmdir "$PKG_PREFIX"/share 2>/dev/null || true
fi
#------------------------------------------------------------------------------