From 9af17e5a76c5a552fe32415d0de583de88655d26 Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Aug 2023 14:42:33 -0400 Subject: [PATCH] More tweaks to build scripts --- Dockerfile | 6 +-- buildscripts/build_all.sh | 4 ++ buildscripts/build_swiftest.sh | 67 ++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100755 buildscripts/build_swiftest.sh diff --git a/Dockerfile b/Dockerfile index bc08c09b1..a89fe35ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,8 +43,4 @@ COPY ./environment.yml ./ COPY ./pyproject.toml ./ COPY ./requirements.txt ./ COPY ./version.txt ./ -ENV CPATH="/swiftest/lib" -ENV LD_LIBRARY_PATH="${CPATH}/lib:${LD_LIBRARY_PATH}" -ENV LIBS="-lhdf5_hl -lhdf5 -lz" -ENV CMAKE_ARGS="-DBUILD_SHARED_LIBS=OFF" -RUN pip install . \ No newline at end of file +RUN /bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh" \ No newline at end of file diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh index fdcceb037..02dfb8cdf 100755 --- a/buildscripts/build_all.sh +++ b/buildscripts/build_all.sh @@ -64,5 +64,9 @@ case $OS in ;; esac +${SCRIPT_DIR}/fetch_dependencies.sh +${SCRIPT_DIR}/make_build_environment.sh +${SCRIPT_DIR}/build_dependencies.sh +${SCRIPT_DIR}/build_swiftest.sh diff --git a/buildscripts/build_swiftest.sh b/buildscripts/build_swiftest.sh new file mode 100755 index 000000000..bb4dc18f5 --- /dev/null +++ b/buildscripts/build_swiftest.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# This script will build the Swiftest package. It is assumed that compatible dependencies have been built already before this is run +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# 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)) +ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) +USTMT="Usage: $0 <{Intel}|GNU> [/path/to/nf-nc-hdf5]" +if [[ ( $@ == "--help") || $@ == "-h" ]]; then + echo $USTMT + exit 0 +fi +COMPILER=${1:-Intel} +DEPDIR={$2:-$(realpath ${ROOT_DIR}/build)} + +case $COMPILER in + Intel) + if command -v ifx &> /dev/null; then + export FC=$(command -v ifx) + export CC=$(command -v icx) + export CXX=$(command -v icpx) + elif command -v ifort &> /dev/null; then + export FC=$(command -v ifort) + export CC=$(command -v icc) + export CXX=$(command -v icpc) + else + echo "Error. Cannot find valid Intel fortran compiler." + exit 1 + fi + export F77="${FC}" + ;; + GNU) + export FC=$(command -v gfortran) + export CC=$(command -v gcc) + export CXX=$(command -v g++) + ;; + *) + echo "Unknown compiler type: ${COMPILER}" + echo $USTMT + exit 1 + ;; +esac +export F77=${FC} +echo "Using $COMPILER compilers:\nFC: $FC\nCC: $CC\nCXX: $CXX\n" + +export CPATH=$DEPDIR +export LD_LIBRARY_PATH="${CPATH}/lib:${LD_LIBRARY_PATH}" +export LIBS="-lhdf5_hl -lhdf5 -lz" +export LDFLAGS="-L${DEPDIR}/lib" +export CFLAGS="-fPIC" +export CMAKE_ARGS="-DBUILD_SHARED_LIBS=OFF" + +if [ $COMPILER = "Intel" ]; then + export FCFLAGS="${CFLAGS} -standard-semantics" + export FFLAGS=${CFLAGS} +else + export FCFLAGS="${CFLAGS}" + export FFLAGS="${CFLAGS}" +fi +cd $ROOT_DIR +pip install .