tools/corrosion/.github/scripts/determine_compiler.sh
branchtransitional_engine
changeset 16021 6a3dc15b78b9
equal deleted inserted replaced
16009:7544a7d7c819 16021:6a3dc15b78b9
       
     1 #!/usr/bin/env bash
       
     2 
       
     3 compiler_kind="$1"
       
     4 runner_os="$2"
       
     5 target_abi="$3"
       
     6 target_system_name="$4"
       
     7 target_arch="$5"
       
     8 
       
     9 set -e
       
    10 
       
    11 if [[ -z "$GITHUB_OUTPUT" ]]; then
       
    12   echo "Error: This script should only be run in github actions environment"
       
    13   exit 1
       
    14 fi
       
    15 if [[ -z "${runner_os}" || -z "${target_abi}" || -z  "${target_arch}" ]]; then
       
    16   echo "Error: Not all required parameters where set"
       
    17   exit 1
       
    18 fi
       
    19 if [[ -z "${compiler_kind}" || "${compiler_kind}" == "default" ]]; then
       
    20   echo "compiler option was not set. Determining default compiler."
       
    21   if [[ "${runner_os}" == "Windows" ]]; then
       
    22     if [[ "${target_abi}" == "msvc" ]]; then
       
    23       compiler_kind=msvc
       
    24     elif [[ "${target_abi}" == "gnu" ]]; then
       
    25       compiler_kind=gcc
       
    26     else
       
    27       echo "Unknown abi for Windows: ${target_abi}"
       
    28       exit 1
       
    29     fi
       
    30   elif [[ "${runner_os}" == "macOS" ]]; then
       
    31     compiler_kind="clang"
       
    32   elif [[ "${runner_os}" == "Linux" ]]; then
       
    33     compiler_kind="gcc"
       
    34   else
       
    35     echo "Unknown Runner OS: ${runner_os}"
       
    36     exit 1
       
    37   fi
       
    38 fi
       
    39 echo "Compiler Family: '${compiler_kind}'"
       
    40 
       
    41 if [[ "${compiler_kind}" == "clang" ]]; then
       
    42   c_compiler="clang"
       
    43   cxx_compiler="clang++"
       
    44 elif [[ "${compiler_kind}" == "msvc" ]]; then
       
    45   c_compiler="cl"
       
    46   cxx_compiler="cl"
       
    47 elif [[ "${compiler_kind}" == "gcc" ]]; then
       
    48   if [[ -z "${target_system_name}" ]]; then
       
    49     c_compiler="gcc"
       
    50     cxx_compiler="g++"
       
    51   else
       
    52     c_compiler="${target_arch}-linux-gnu-gcc"
       
    53     cxx_compiler="${target_arch}-linux-gnu-g++"
       
    54   fi
       
    55 fi
       
    56 echo "Chose C compiler: '${c_compiler}'"
       
    57 echo "Chose C++ compiler: '${cxx_compiler}'"
       
    58 echo "c_compiler=-DCMAKE_C_COMPILER=${c_compiler}" >> $GITHUB_OUTPUT
       
    59 echo "cxx_compiler=-DCMAKE_CXX_COMPILER=${cxx_compiler}" >> $GITHUB_OUTPUT