Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Made several changes to get a working version of the code on MacOS 11…
Browse files Browse the repository at this point in the history
….0. Switched back to a shared library build for portability
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Aug 30, 2023
1 parent 93e69a4 commit 2c5b377
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 105 deletions.
24 changes: 19 additions & 5 deletions buildscripts/_build_getopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ SCRIPT_DIR=$(realpath $(dirname $0))
ROOT_DIR=$(realpath ${SCRIPT_DIR}/..)

# Parse arguments
USTMT="Usage: ${0} <-d /path/to/dependency/source> [-p /prefix/path|{/usr/local}] [-m MACOSX_DEPLOYMENT_TARGET|{10.9}]"
PREFIX=/usr/local
DEPENDENCY_DIR="${ROOT_DIR}/_dependencies"
MACOSX_DEPLOYMENT_TARGET="10.9"
USTMT="Usage: ${0} [-d /path/to/dependency/source] [-p /prefix/path] [-m MACOSX_DEPLOYMENT_TARGET|{11.0}]"
MACOSX_DEPLOYMENT_TARGET="11.0"

read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh)
BUILD_DIR=${BUILD_DIR:-$(mktemp -ut swiftest_build)}
if [ $OS = "MacOSX" ]; then
PREFIX=${PREFIX:-${BUILD_DIR}/${OS}${MACOSX_DEPLOYMENT_TARGET}/${ARCH}}
else
PREFIX=${PREFIX:-${BUILD_DIR}/${OS}/${ARCH}}
fi

DEPENDENCY_DIR=${DEPENDENCY_DIR:-${BUILD_DIR}/downloads}

while getopts ":d:p:m:h" ARG; do
case "${ARG}" in
d)
Expand Down Expand Up @@ -45,7 +54,12 @@ while getopts ":d:p:m:h" ARG; do
esac
done

read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh)
if [ $OS = "MacOSX" ]; then
printf "MACOSX_DEPLOYMENT_TARGET: ${MACOSX_DEPLOYMENT_TARGET}\n"
fi
printf "DEPENDENCY_DIR: ${DEPENDENCY_DIR}\n"
printf "PREFIX : ${PREFIX}\n"


if [ -z ${DEPENDENCY_ENV_VARS+x} ]; then
. ${SCRIPT_DIR}/set_compilers.sh
Expand Down
22 changes: 0 additions & 22 deletions buildscripts/build_all.sh

This file was deleted.

5 changes: 3 additions & 2 deletions buildscripts/build_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ARGS=$@

printf "\n"
printf "*********************************************************\n"
printf "* BUILDING HDF5 STATIC LIBRARY *\n"
printf "* BUILDING HDF5 LIBRARY *\n"
printf "*********************************************************\n"
printf "LIBS: ${LIBS}\n"
printf "CFLAGS: ${CFLAGS}\n"
Expand All @@ -35,7 +35,8 @@ if [ $OS = "MacOSX" ]; then
printf "echo arm-apple-darwin" > bin/config.sub
fi
fi
COPTS="--disable-shared --enable-build-mode=production --enable-tests=no --enable-tools=no --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}"
#COPTS="--disable-shared --enable-build-mode=production --enable-tests=no --enable-tools=no --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}"
COPTS="--enable-build-mode=production --enable-tests=no --enable-tools=no --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}"
./configure ${COPTS}
make
if [ -w ${PREFIX} ]; then
Expand Down
11 changes: 6 additions & 5 deletions buildscripts/build_netcdf-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ARGS=$@

printf "\n"
printf "*********************************************************\n"
printf "* BUILDING NETCDF-C STATIC LIBRARY *\n"
printf "* BUILDING NETCDF-C LIBRARY *\n"
printf "*********************************************************\n"
printf "LIBS: ${LIBS}\n"
printf "CFLAGS: ${CFLAGS}\n"
Expand All @@ -30,10 +30,11 @@ printf "HDF5_ROOT: ${HDF5_ROOT}\n"
printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/netcdf-c-*
COPTS="--disable-shared --disable-dap --disable-byterange --disable-testsets --prefix=${PREFIX}"
if [ ! $OS = "MacOSX" ]; then
COPTS="${COPTS} --disable-libxml2"
fi
#COPTS="--disable-shared --disable-dap --disable-byterange --disable-testsets --prefix=${PREFIX}"
COPTS="--disable-testsets --prefix=${PREFIX}"
#if [ ! $OS = "MacOSX" ]; then
# COPTS="${COPTS} --disable-libxml2"
#fi
printf "COPTS: ${COPTS}\n"
./configure $COPTS
make && make check
Expand Down
5 changes: 3 additions & 2 deletions buildscripts/build_netcdf-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LIBS="$(${PREFIX}/bin/nc-config --libs --static)"

printf "\n"
printf "*********************************************************\n"
printf "* BUILDING NETCDF-FORTRAN STATIC LIBRARY *\n"
printf "* BUILDING NETCDF-FORTRAN LIBRARY *\n"
printf "*********************************************************\n"
printf "LIBS: ${LIBS}\n"
printf "CFLAGS: ${CFLAGS}\n"
Expand All @@ -30,7 +30,8 @@ printf "LDFLAGS: ${LDFLAGS}\n"
printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/netcdf-fortran-*
./configure --disable-shared --with-pic --disable-zstandard-plugin --enable-large-file-tests=no --enable-filter-test=no --prefix=${PREFIX}
#./configure --disable-shared --with-pic --disable-zstandard-plugin --enable-large-file-tests=no --enable-filter-test=no --prefix=${PREFIX}
./configure --enable-large-file-tests=no --enable-filter-test=no --prefix=${PREFIX}
make && make check i
if [ -w ${PREFIX} ]; then
make install
Expand Down
9 changes: 6 additions & 3 deletions buildscripts/build_swiftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set -a
if [ -z ${SCRIPT_DIR+x} ]; then SCRIPT_DIR=$(realpath $(dirname $0)); fi
ARGS=$@
. ${SCRIPT_DIR}/_build_getopts.sh ${ARGS}
ARGS="-p ${PREFIX} -d ${DEPENDENCY_DIR} -m ${MACOSX_DEPLOYMENT_TARGET}"

# Determine if we are in the correct directory (the script can either be run from the Swiftest project root directory or the
# buildscripts directory)
Expand All @@ -27,18 +28,20 @@ echo $OS $ARCH
printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n\n"
printf "Installing to ${PREFIX}\n"
printf "Dependency libraries in ${PREFIX}\n"
${SCRIPT_DIR}/build_dependencies.sh ${ARGS}

if [ $OS = "Linux" ]; then
cibuildwheel --platform linux
else
SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF"
SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=ON -DUSE_SIMD=OFF"
SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_CONFIGURE_OPTIONS} -DMACHINE_CODE_VALUE=\"generic\""
OMPROOT=${DEVTOOLDIR}/MacOSX${MACOSX_DEPLOYMENT_TARGET}/${ARCH}/usr/local
CPPFLAGS="${CPPFLAGS} -Xclang -fopenmp"
LIBS="${LIBS} -lomp"
LDFLAGS="-Wl,-rpath,${OMPROOT}/lib"
LDFLAGS="-Wl,-rpath,${OMPROOT}/lib -Wl,-rpath,${ROOT_DIR}/lib"
CPATH="${OMPROOT}/include:${CPATH}"
LD_LIBRARY_PATH="${OMPROOT}/lib:${LD_LIBRARY_PATH}"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
LIBRARY_PATH="${LD_LIBRARY_PATH}"
cd $ROOT_DIR

printf "\n"
Expand Down
5 changes: 3 additions & 2 deletions buildscripts/build_zlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ARGS=$@
. ${SCRIPT_DIR}/_build_getopts.sh ${ARGS}

printf "*********************************************************\n"
printf "* BUILDING ZLIB STATIC LIBRARY *\n"
printf "* BUILDING ZLIB LIBRARY *\n"
printf "*********************************************************\n"
printf "LIBS: ${LIBS}\n"
printf "CFLAGS: ${CFLAGS}\n"
Expand All @@ -27,7 +27,8 @@ printf "LDFLAGS: ${LDFLAGS}\n"
printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/zlib-*
./configure --prefix=${PREFIX} --static
#./configure --prefix=${PREFIX} --static
./configure --prefix=${PREFIX}
make
if [ -w ${PREFIX} ]; then
make install
Expand Down
56 changes: 1 addition & 55 deletions buildscripts/set_compilers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# If not, see: https://www.gnu.org/licenses.
# Parse arguments
case "$OS" in
Intel|Linux|MacOSX)
Linux|MacOSX)
;;
*)
echo "Unknown compiler type: $OS"
Expand All @@ -28,60 +28,6 @@ esac
set -a
# Only replace compiler definitions if they are not already set
case $OS in
Intel)
if [ ! -v FC ]; then
if command -v ifx &> /dev/null; then
FC=$(command -v ifx)
elif command -v ifort &> /dev/null; then
FC=$(command -v mpiifort)
else
printf "Error. Cannot find valid Intel Fortran compiler.\n"
exit 1
fi
fi
if [ ! -v F77 ]; then
F77="${FC}"
fi

if [ ! -v CC ]; then
if command -v icx &> /dev/null; then
CC=$(command -v icx)
elif command -v icc &> /dev/null; then
CC=$(command -v icc)
else
printf "Error. Cannot find valid Intel C compiler.\n"
exit 1
fi
fi

if [ ! -v CXX ]; then
if command -v icpx &> /dev/null; then
CXX=$(command -v icpx)
elif command -v icpc &> /dev/null; then
CXX=$(command -v icpc)
else
printf "Error. Cannot find valid Intel C++ compiler.\n"
exit 1
fi
fi

if command -v mpiifort &> /dev/null; then
I_MPI_F90=${FC}
FC=$(command -v mpiifort)
fi

if command -v mpiicc &> /dev/null; then
I_MPI_CC =${CC}
CC=$(command -v mpiicc)
fi

if command -v mpiicpc &> /dev/null; then
I_MPI_CXX =${CXX}
CXX=$(command -v mpiicpc)
fi

CPP=${CPP:-$HOMEBRE_PREFIX/bin/cpp-13}
;;
Linux)
FC=${FC:-$(command -v gfortran)}
CC=${CC:-$(command -v gcc)}
Expand Down
11 changes: 2 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ requires = [
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
environment = {SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF"}
environment = {SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=ON"}
test-command = "pytest {package}/tests"
test-requires = ['pytest','cython']
test-skip = "cp312-*"
Expand All @@ -20,12 +20,5 @@ skip = "pp* *i686 *-manylinux_i686 *_ppc64le *_s390x *-musllinux* *-win32"
environment = {FFLAGS="${FFLAGS} -fPIC", CFLAGS="${CFLAGS} -fPIC", LDFLAGS="${LDFLAGS} -fPIE", LIBS="-lgomp"}
before-all = [
"yum install doxygen -y || apt-get install doxygen -y",
"buildscripts/build_dependencies.sh -d /_dependencies -p /usr/local",
"buildscripts/build_dependencies.sh -p /usr/local",
]

[tool.cibuildwheel.macos]
before-all = [
"buildscripts/build_dependencies.sh -d ${TMPDIR} -p ${TMPDIR} -m ${MACOSX_DEPLOYMENT_TARGET}"
]


0 comments on commit 2c5b377

Please sign in to comment.