From 66150cdcc5ef44d55bc464bc4c27eef62df9c09c Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 16 Feb 2024 11:33:18 -0500 Subject: [PATCH] Fixed some issues with the build scripts --- buildscripts/_build_getopts.sh | 11 +++-- buildscripts/get_platform.sh | 80 ---------------------------------- buildscripts/set_compilers.sh | 60 ++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 91 deletions(-) delete mode 100755 buildscripts/get_platform.sh diff --git a/buildscripts/_build_getopts.sh b/buildscripts/_build_getopts.sh index b2ace2e02..b218da594 100755 --- a/buildscripts/_build_getopts.sh +++ b/buildscripts/_build_getopts.sh @@ -13,10 +13,9 @@ set -a SCRIPT_DIR=$(realpath $(dirname $0)) ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) -echo "Getting the OS and ARCH values" # Get platform and architecture -read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) -echo "Gotem! OS: $OS, ARCH: $ARCH" +OS=$(uname -s) +ARCH=$(uname -m) # Parse arguments USTMT="Usage: ${0} [-d /path/to/dependency/source] [-p /prefix/path] [-m MACOSX_DEPLOYMENT_TARGET]" @@ -57,16 +56,16 @@ DEPENDENCY_DIR=${DEPENDENCY_DIR:-${BUILD_DIR}} case $OS in - Linux-gnu|Linux-ifx|Linux-ifort|Linux-mpiifort|MacOSX) + Linux*) . ${SCRIPT_DIR}/set_environment_linux.sh ;; - MacOSX) + MacOSX|Darwin) . ${SCRIPT_DIR}/set_environment_macos.sh ;; *) printf "Unknown compiler type: ${OS}\n" - echo "Valid options are Linux-gnu, Linux-ifort, Linux-ifx, or MacOSX" + echo "Valid options are Linux, MacOSX, or Darwin" printf $USTMT exit 1 ;; diff --git a/buildscripts/get_platform.sh b/buildscripts/get_platform.sh deleted file mode 100755 index 70aa0210d..000000000 --- a/buildscripts/get_platform.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# This script will determine the platform (OS and architecture) and format them in a way that other scripts can make use of. -# -# The following combinations are valid: -# Linux x86_64 -# Linux aarch64 -# MacOSX x86_64 -# MacOSX arm64 -# -# 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. - - -# Determine the platform and architecture -OS=$(uname -s) -ARCH=$(uname -m) - -case $ARCH in - x86_64) - ;; - amd64) - ARCH="x86_64" - ;; - arm64) - if [ "$OS" = "Linux" ]; then - ARCH="aarch64" - fi - ;; - aarch64) - if [ "$OS" = "Darwin" ]; then - ARCH="arm64" - fi - ;; - *) - echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" - exit 1 - ;; -esac - -case $OS in - Linux) - # Currently ifx support is not great - case $FC in - *ifx) - OS="Linux-ifx" - ;; - *mpiifort) - OS="Linux-mpiifort" - ;; - *ifort) - OS="Linux-ifort" - ;; - *gfortran) - OS="Linux-gnu" - ;; - *) - echo "No Fortran compiler found on Linux" - exit 1 - :: - esac - ;; - Darwin) - OS="MacOSX" - ;; - *MSYS*) - OS="Windows" - ;; - *) - echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" - exit 1 - ;; -esac - -echo $OS $ARCH diff --git a/buildscripts/set_compilers.sh b/buildscripts/set_compilers.sh index d3ce4358d..c2fb07f9f 100755 --- a/buildscripts/set_compilers.sh +++ b/buildscripts/set_compilers.sh @@ -15,17 +15,67 @@ # If not, see: https://www.gnu.org/licenses. SCRIPT_DIR=$(realpath $(dirname $0)) ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) -case "$OS" in - Linux-gnu|Linux-ifx|Linux-ifort|Linux-mpiifort|MacOSX) + +# Get platform and architecture +OS=$(uname -s) +ARCH=$(uname -m) + +case $ARCH in + x86_64) + ;; + amd64) + ARCH="x86_64" + ;; + arm64) + if [ "$OS" = "Linux" ]; then + ARCH="aarch64" + fi + ;; + aarch64) + if [ "$OS" = "Darwin" ]; then + ARCH="arm64" + fi ;; *) - echo "Unknown compiler type: $OS" - echo "Valid options are Linux-gnu, Linux-ifort, Linux-ifx, or MacOSX" - echo $USTMT + echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" + exit 1 + ;; +esac + +case $OS in + Darwin) + OS="MacOSX" + ;; + *MSYS*) + OS="Windows" + ;; + *) + echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" exit 1 ;; esac +if [[ $OS == "Linux" ]]; then + # Check if FC is set yet, and if so, use it instead of the default + # Currently ifx support is not great + case $FC in + *ifx) + OS="Linux-ifx" + ;; + *mpiifort) + OS="Linux-mpiifort" + ;; + *ifort) + OS="Linux-ifort" + ;; + *gfortran) + OS="Linux-gnu" + ;; + *) + OS="Linux-gnu" + ;; + esac +fi set -a case $OS in Linux-gnu)