From c8b5c4ec336e70dd50d61b71e45bc4533ed66b67 Mon Sep 17 00:00:00 2001 From: 0xderek Date: Fri, 20 Dec 2024 23:51:06 +0800 Subject: [PATCH] [fix](macOS) Fix build scripts for macOS - Replaced `nproc` with `sysctl -n hw.logicalcpu` to get CPU count on macOS. - Avoided lowercase parameter expansion due to macOS default Bash version (3.2). --- build.sh | 9 ++++++++- thirdparty/download-thirdparty.sh | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 5a09b7a0a165e3..9559e57a5fd357 100755 --- a/build.sh +++ b/build.sh @@ -148,7 +148,14 @@ fi eval set -- "${OPTS}" -PARALLEL="$(($(nproc) / 4 + 1))" +NUM_CORES=0 +if [[ "$(uname -s)" == 'Darwin' ]]; then + NUM_CORES=$(sysctl -n hw.logicalcpu) +else + NUM_CORES=$(nproc) +fi + +PARALLEL="$((${NUM_CORES} / 4 + 1))" BUILD_FE=0 BUILD_BE=0 BUILD_CLOUD=0 diff --git a/thirdparty/download-thirdparty.sh b/thirdparty/download-thirdparty.sh index 8f6a9fafc71757..8c982b6f432a2b 100755 --- a/thirdparty/download-thirdparty.sh +++ b/thirdparty/download-thirdparty.sh @@ -54,9 +54,11 @@ SPEC_ARCHIVES=( ) while [[ $# -gt 0 ]]; do GIVEN_LIB=$1 + GIVEN_LIB_LOWER="$(echo ${GIVEN_LIB} | awk '{print tolower($0)}')" SPEC_LIB= for TP_ARCH in "${TP_ARCHIVES[@]}"; do - if [[ "${GIVEN_LIB,,}" = "${TP_ARCH,,}" ]]; then + TP_ARCH_LOWER="$(echo ${TP_ARCH} | awk '{print tolower($0)}')" + if [[ "${GIVEN_LIB_LOWER}" = "${TP_ARCH_LOWER}" ]]; then SPEC_LIB=${TP_ARCH} break fi