Fix build on macOS

This commit is contained in:
Abdelrahman Said
2025-09-01 22:10:41 +01:00
parent 26fd329caa
commit 9cbd0b29ef
2 changed files with 12 additions and 6 deletions

16
build
View File

@@ -6,7 +6,7 @@ BOLD="\033[1m"
NC="\033[0m" # No Color
BUILD_TYPE="Debug"
ACCEPTED_BUILD_TYPES=("RelWithDebInfo" "Debug" "Release")
ACCEPTED_BUILD_TYPES=("Debug" "RelWithDebInfo" "Release")
KERNEL="$(uname -s)"
ARGS=""
@@ -15,6 +15,15 @@ join_array_elements() {
echo "$*"
}
contains() {
local item="$1"; shift
local e
for e; do
[[ "$e" == "$item" ]] && return 0
done
return 1
}
print_usage() {
echo -e "Usage: build [-b build_type] ..."
echo -e " Options:"
@@ -40,10 +49,7 @@ while [[ $# > 0 ]];do
esac
done
# Compare build type against array
# From this: https://www.baeldung.com/linux/check-bash-array-contains-value#using-anifcondition-with-aregex-pattern
build_regex="\<${BUILD_TYPE}\>"
if [[ ! ${ACCEPTED_BUILD_TYPES[@]} =~ $build_regex ]]; then
if ! contains ${BUILD_TYPE} "${ACCEPTED_BUILD_TYPES[@]}"; then
echo -e "${RED}${BOLD}Unknown build type: ${BUILD_TYPE}${NC}\n"
print_usage
exit 1