Skip to content

Commit

Permalink
#120: generalize nproc command to work on on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Sep 22, 2024
1 parent 8a66113 commit b8c0e93
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ function on_off() {
esac
}

# A function to determine the number of available processors
get_num_processors() {
case "$(uname)" in
Linux)
nproc
;;
Darwin)
sysctl -n hw.ncpu
;;
*)
getconf _NPROCESSORS_ONLN
;;
esac
}

# Configuration
# > Build variables
# >> Path
Expand All @@ -33,7 +48,7 @@ VT_TV_OUTPUT_DIR="${VT_TV_OUTPUT_DIR:-$CURRENT_DIR/output}"
# >> Build settings
VT_TV_BUILD=$(on_off ${VT_TV_BUILD:-ON}) # option to turn off the build to only run tests
VT_TV_BUILD_TYPE=${VT_TV_BUILD_TYPE:-Release}
VT_TV_CMAKE_JOBS=${VT_TV_CMAKE_JOBS:-$(nproc)}
VT_TV_CMAKE_JOBS=${VT_TV_CMAKE_JOBS:-$(get_num_processors)}
VT_TV_TESTS_ENABLED=$(on_off ${VT_TV_TESTS_ENABLED:-ON})
VT_TV_TEST_REPORT=${VT_TV_TEST_REPORT:-"$VT_TV_OUTPUT_DIR/junit-report.xml"}
VT_TV_COVERAGE_ENABLED=$(on_off ${VT_TV_COVERAGE_ENABLED:-OFF})
Expand Down

0 comments on commit b8c0e93

Please sign in to comment.