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

Commit

Permalink
Streamlined the dependency building scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Aug 17, 2023
1 parent 09e107c commit 9eb9c5d
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 52 deletions.
8 changes: 7 additions & 1 deletion buildscripts/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ case $OS in
;;
esac

${SCRIPT_DIR}/fetch_dependencies.sh -d ${BUILD_DIR} && \
mkdir -p ${BUILD_DIR}
cd $BUILD_DIR
wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz
wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz
wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz
wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz | tar xvz

${SCRIPT_DIR}/build_dependencies.sh -c $COMPILER -p ${PREFIX} && \
${SCRIPT_DIR}/build_swiftest.sh -c $COMPILER -p ${PREFIX}

Expand Down
70 changes: 53 additions & 17 deletions buildscripts/build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.
SCRIPT_DIR=$(realpath $(dirname $0))
BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build)

mkdir -p ${BUILD_DIR}
cd $BUILD_DIR
# Determine the platform and architecture
SCRIPT_DIR=$(realpath $(dirname $0))
ROOT_DIR=$(realpath ${SCRIPT_DIR}/..)
DEPENDENCY_DIR="${ROOT_DIR}/_dependencies"
PREFIX=/usr/local

# Parse arguments
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]"
IFORT=false
PREFIX=/usr/local
USTMT="Usage: ${0} [-d /path/to/dependancy/build] [-p {/usr/local}|/prefix/path]"
COMPILER=""
while getopts ":c:p:" ARG; do
while getopts ":d:p:" ARG; do
case "${ARG}" in
c)
COMPILER="${OPTARG}"
d)
DEPENDENCY_DIR="${OPTARG}"
;;
p)
PREFIX="${OPTARG}"
Expand All @@ -38,6 +37,46 @@ while getopts ":c:p:" ARG; do
;;
esac
done

mkdir -p ${DEPENDENCY_DIR}
read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh)

# Determine if we are in the correct directory (the script can either be run from the Swiftest project root directory or the
# buildscripts directory)
if [ ! -f "${ROOT_DIR}/setup.py" ]; then
echo "Error: setup.py not found"
exit 1
fi
cd ${ROOT_DIR}
VERSION=$( cat version.txt )
echo "Building Swiftest version ${VERSION} for ${OS}-${ARCH}"

case $OS in
MacOSX)
COMPILER="GNU-Mac"
;;
Linux)
COMPILER="GNU-Linux"
;;
*)
echo "This script is not tested for ${OS}-${ARCH}"
;;
esac

printf "*********************************************************\n"
printf "* FETCHING DEPENCENCY SOURCES *\n"
printf "*********************************************************\n"
printf "Copying files to ${DEPENDENCY_DIR}\n"
mkdir -p ${DEPENDENCY_DIR}
cd $DEPENDENCY_DIR
wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz
wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz
wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz
wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz | tar xvz

printf "*********************************************************\n"
printf "* STARTING DEPENDENCY BUILD *\n"
printf "*********************************************************\n"
CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER"
read -r CC CXX FC F77 CPP < <($CMD)
export CC=${CC}
Expand All @@ -46,17 +85,14 @@ export FC=${FC}
export F77=${F77}
export CPP=${CPP}

printf "*********************************************************\n"
printf "* STARTING DEPENDENCY BUILD *\n"
printf "*********************************************************\n"
printf "Using ${COMPILER} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n"
printf "Installing to ${PREFIX}\n"
printf "\n"

${SCRIPT_DIR}/build_zlib.sh -c $COMPILER -p $PREFIX
${SCRIPT_DIR}/build_hdf5.sh -c $COMPILER -p $PREFIX
${SCRIPT_DIR}/build_netcdf-c.sh -c $COMPILER -p $PREFIX
${SCRIPT_DIR}/build_netcdf-fortran.sh -c $COMPILER -p $PREFIX
${SCRIPT_DIR}/build_zlib.sh -c $COMPILER -p $PREFIX -d $DEPENDENCY_DIR
${SCRIPT_DIR}/build_hdf5.sh -c $COMPILER -p $PREFIX -d $DEPENDENCY_DIR
${SCRIPT_DIR}/build_netcdf-c.sh -c $COMPILER -p $PREFIX -d $DEPENDENCY_DIR
${SCRIPT_DIR}/build_netcdf-fortran.sh -c $COMPILER -p $PREFIX -d $DEPENDENCY_DIR

printf "\n"
printf "*********************************************************\n"
Expand Down
16 changes: 8 additions & 8 deletions buildscripts/build_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.
SCRIPT_DIR=$(realpath $(dirname $0))
BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build)

mkdir -p ${BUILD_DIR}
cd $BUILD_DIR

# Parse arguments
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]"
IFORT=false
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> <-d /path/to/dependency/source> [-p {/usr/local}|/prefix/path] "
PREFIX=/usr/local
COMPILER=""
DEPENCENCY_DIR=""
CARG=""
while getopts ":c:p:" ARG; do
while getopts ":c:p:d:" ARG; do
case "${ARG}" in
c)
COMPILER="${OPTARG}"
;;
p)
PREFIX="${OPTARG}"
;;
d)
DEPENDENCY_DIR="${OPTARG}"
;;
:)
echo "Error: -${OPTARG} requires an argument."
echo $USTMT
Expand All @@ -39,6 +38,7 @@ while getopts ":c:p:" ARG; do
;;
esac
done

CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER"
read -r CC CXX FC F77 CPP < <($CMD)
export CC=${CC}
Expand Down Expand Up @@ -77,7 +77,7 @@ printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n"
printf "LDFLAGS: ${LDFLAGS}\n"
printf "*********************************************************\n"

cd ${BUILD_DIR}/hdf5-*
cd ${DEPENDENCY_DIR}/hdf5-*
if [ $COMPILER = "GNU-Mac" ]; then
read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh)
if [ $ARCH = "arm64" ]; then
Expand Down
16 changes: 8 additions & 8 deletions buildscripts/build_netcdf-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.
SCRIPT_DIR=$(realpath $(dirname $0))
BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build)

mkdir -p ${BUILD_DIR}
cd $BUILD_DIR

# Parse arguments
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]"
IFORT=false
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> <-d /path/to/dependency/source> [-p {/usr/local}|/prefix/path] "
PREFIX=/usr/local
COMPILER=""
DEPENCENCY_DIR=""
CARG=""
while getopts ":c:p:" ARG; do
while getopts ":c:p:d:" ARG; do
case "${ARG}" in
c)
COMPILER="${OPTARG}"
;;
p)
PREFIX="${OPTARG}"
;;
d)
DEPENDENCY_DIR="${OPTARG}"
;;
:)
echo "Error: -${OPTARG} requires an argument."
echo $USTMT
Expand All @@ -39,6 +38,7 @@ while getopts ":c:p:" ARG; do
;;
esac
done

CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER"
read -r CC CXX FC F77 CPP < <($CMD)
export CC=${CC}
Expand Down Expand Up @@ -78,7 +78,7 @@ printf "LDFLAGS: ${LDFLAGS}\n"
printf "HDF5_ROOT: ${HDF5_ROOT}\n"
printf "*********************************************************\n"

cd ${BUILD_DIR}/netcdf-c-*
cd ${DEPENDENCY_DIR}/netcdf-c-*
COPTS="--disable-shared --disable-dap --disable-byterange --prefix=${PREFIX}"
if [ ! $COMPILER = "GNU-Mac" ]; then
COPTS="${COPTS} --disable-libxml2"
Expand Down
16 changes: 8 additions & 8 deletions buildscripts/build_netcdf-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.
SCRIPT_DIR=$(realpath $(dirname $0))
BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build)

mkdir -p ${BUILD_DIR}
cd $BUILD_DIR

# Parse arguments
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]"
IFORT=false
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> <-d /path/to/dependency/source> [-p {/usr/local}|/prefix/path] "
PREFIX=/usr/local
COMPILER=""
DEPENCENCY_DIR=""
CARG=""
while getopts ":c:p:" ARG; do
while getopts ":c:p:d:" ARG; do
case "${ARG}" in
c)
COMPILER="${OPTARG}"
;;
p)
PREFIX="${OPTARG}"
;;
d)
DEPENDENCY_DIR="${OPTARG}"
;;
:)
echo "Error: -${OPTARG} requires an argument."
echo $USTMT
Expand All @@ -39,6 +38,7 @@ while getopts ":c:p:" ARG; do
;;
esac
done

CMD="${SCRIPT_DIR}/set_compilers.sh -c $COMPILER"
read -r CC CXX FC F77 CPP < <($CMD)
export CC=${CC}
Expand Down Expand Up @@ -80,7 +80,7 @@ printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n"
printf "LDFLAGS: ${LDFLAGS}\n"
printf "*********************************************************\n"

cd ${BUILD_DIR}/netcdf-fortran-*
cd ${DEPENDENCY_DIR}/netcdf-fortran-*
./configure --disable-shared --with-pic --disable-zstandard-plugin --prefix=${PREFIX}
make && make check i
if [ -w ${PREFIX} ]; then
Expand Down
15 changes: 7 additions & 8 deletions buildscripts/build_zlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.
SCRIPT_DIR=$(realpath $(dirname $0))
BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build)

mkdir -p ${BUILD_DIR}
cd $BUILD_DIR

# Parse arguments
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> [-p {/usr/local}|/prefix/path]"
IFORT=false
USTMT="Usage: ${0} <-c Intel|GNU-Linux|GNU-Mac> <-d /path/to/dependency/source> [-p {/usr/local}|/prefix/path] "
PREFIX=/usr/local
COMPILER=""
DEPENCENCY_DIR=""
CARG=""
while getopts ":c:p:" ARG; do
while getopts ":c:p:d:" ARG; do
case "${ARG}" in
c)
COMPILER="${OPTARG}"
;;
p)
PREFIX="${OPTARG}"
;;
d)
DEPENDENCY_DIR="${OPTARG}"
;;
:)
echo "Error: -${OPTARG} requires an argument."
echo $USTMT
Expand Down Expand Up @@ -70,7 +69,7 @@ printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n"
printf "LDFLAGS: ${LDFLAGS}\n"
printf "*********************************************************\n"

cd ${BUILD_DIR}/zlib-*
cd ${DEPENDENCY_DIR}/zlib-*
./configure --prefix=${PREFIX} --static
make

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
environment = {SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF", FFLAGS="${FFLAGS} -fPIC"}
before-all = [
"yum install wget m4 doxygen -y",
"buildscripts/fetch_dependencies.sh -d build",
"buildscripts/build_dependencies.sh -c GNU-Linux -p /usr/local"
"buildscripts/build_dependencies.sh",
"buildscripts/build_swiftest.sh -c GNU-Linux -p /usr/local"
]

0 comments on commit 9eb9c5d

Please sign in to comment.