Verified Commit 0c2a86cb authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

dep_scripts: Propagate compiler information

parent 82edc706
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -284,6 +284,53 @@ find_cmake() {
    echo "${CMAKE}"
}

determine_compiler() {

    compiler_is_gnu() {
        COMPILER_NAME="g++"

        if ! COMPILER_FULL_VERSION="$(g++ -dumpfullversion 2>&1)"; then
            echo -e "ERROR: Failed to determine compiler version."
            echo -e ">> ${COMPILER_FULL_VERSION}"
            exit 1
        fi

        COMPILER_MAJOR_VERSION="${COMPILER_FULL_VERSION%%.*}"
    }

    compiler_is_clang() {
        COMPILER_NAME="clang"

        if ! COMPILER_FULL_VERSION="$(clang -dumpversion 2>&1)"; then
            echo -e "ERROR: Failed to determine compiler version."
            echo -e ">> ${COMPILER_FULL_VERSION}"
            exit 1
        fi

        COMPILER_MAJOR_VERSION="${COMPILER_FULL_VERSION%%.*}"
    }

    # We honor the CXX environment variable if defined.
    # Otherwise, we try to find the compiler by using `command -v`.
    if [[ -n "${CXX}" && ! "${CXX}" =~ ^(g\+\+|clang)$ ]]; then
        echo "ERROR: Unknown compiler '${CXX}'"
        exit 1
    fi

    if [[ -n "${CXX}" && "${CXX}" =~ ^g\+\+$ ]]; then
        compiler_is_gnu
    elif [[ -n "${CXX}" && "$CXX" =~ ^clang$ ]]; then
        compiler_is_clang
    elif [[ $(command -v g++) ]]; then
        compiler_is_gnu
    elif [[ $(command -v clang) ]]; then
        compiler_is_clang
    else
        echo "ERROR: Unable to determine compiler."
        exit 1
    fi
}


POSITIONAL=()
while [[ $# -gt 0 ]]; do
@@ -471,6 +518,7 @@ for dep_name in "${PROFILE_DEP_LIST[@]}"; do
    fi

    if [[ "$DRY_RUN" == false ]]; then
        determine_compiler
        pkg_install

        [ "${PERFORM_TEST}" ] && pkg_check
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
##               downloaded
## - INSTALL_DIR: the directory where the package should be installed
## - CORES: the number of cores to use when building
## - COMPILER_NAME: the name of the compiler being used (e.g. g++, clang, etc.)
## - COMPILER_FULL_VERSION: the compiler's full version (e.g. 9.3.0)
## - COMPILER_MAJOR_VERSION: the compiler's major version (e.g. 9)
## - PERFORM_TEST: whether tests for the package should be executed
################################################################################

+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
##               downloaded
## - INSTALL_DIR: the directory where the package should be installed
## - CORES: the number of cores to use when building
## - COMPILER_NAME: the name of the compiler being used (e.g. g++, clang, etc.)
## - COMPILER_FULL_VERSION: the compiler's full version (e.g. 9.3.0)
## - COMPILER_MAJOR_VERSION: the compiler's major version (e.g. 9)
## - PERFORM_TEST: whether tests for the package should be executed
################################################################################

+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
##               downloaded
## - INSTALL_DIR: the directory where the package should be installed
## - CORES: the number of cores to use when building
## - COMPILER_NAME: the name of the compiler being used (e.g. g++, clang, etc.)
## - COMPILER_FULL_VERSION: the compiler's full version (e.g. 9.3.0)
## - COMPILER_MAJOR_VERSION: the compiler's major version (e.g. 9)
## - PERFORM_TEST: whether tests for the package should be executed
################################################################################

+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
##               downloaded
## - INSTALL_DIR: the directory where the package should be installed
## - CORES: the number of cores to use when building
## - COMPILER_NAME: the name of the compiler being used (e.g. g++, clang, etc.)
## - COMPILER_FULL_VERSION: the compiler's full version (e.g. 9.3.0)
## - COMPILER_MAJOR_VERSION: the compiler's major version (e.g. 9)
## - PERFORM_TEST: whether tests for the package should be executed
################################################################################

Loading