Verified Commit 25fd2f35 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

dep_scripts: Allow install scripts to easily check the provided dependencies

parent 8a0867c8
Loading
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -330,6 +330,41 @@ determine_compiler() {
    fi
}

# Check whether the loaded profile defines a particular dependency name.
# The function requires a valid bash regex argument to do the search. The
# function is meant to be used in a conditional context.
#
# Examples:
#   1. Check whether any flavor of 'libfabric' is defined by the profile:
#
#     if profile_has_dependency "^libfabric%.*$"; then
#        echo "libfabric found"
#     fi
#
#   2. Check whether a specific flavor of 'libfabric' is defined by the profile:
#
#     if profile_has_dependency "^libfabric%experimental$"; then
#        echo "libfabric.experimental found"
#     fi
profile_has_dependency() {

    if [[ "$#" -ne 1 ]]; then
        >&2 echo "FATAL: Missing argument in profile_has_dependency()"
        exit 1
    fi

    regex="$1"

    for name in "${PROFILE_DEP_LIST[@]}"; do

        if [[ "${name}" =~ ${regex} ]]; then
            return 0
        fi
    done

    return 1
}


POSITIONAL=()
while [[ $# -gt 0 ]]; do
+2 −4
Original line number Diff line number Diff line
@@ -45,8 +45,6 @@

pkg_install() {

    set -x

    # if the profile compiles bmi, enable it
    if [[ -n "${PROFILE_DEP_NAMES['bmi']}" ]]; then
        USE_BMI="-DNA_USE_BMI:BOOL=ON"
@@ -54,8 +52,8 @@ pkg_install() {
        USE_BMI="-DNA_USE_BMI:BOOL=OFF"
    fi

    # if the profile compiles libfabric, enable it
    if [[ -n "${PROFILE_DEP_NAMES['libfabric']}" ]]; then
    # if the profile provides any flavour of libfabric, enable it
    if profile_has_dependency "^libfabric.*$"; then
        USE_OFI="-DNA_USE_OFI:BOOL=ON"
    else
        USE_OFI="-DNA_USE_OFI:BOOL=OFF"