瀏覽代碼

CI: Make processor count consistent

Code formatting script was using `sysctl -n hw.physicalcpu` on macOS
machines to get the CPU count. This command returns the physical CPUs.
`nproc`, however, returns logical CPU count on Linux machines. It
should be `sysctl -n hw.logicalcpu` to make it consistent with its
Linux counterpart. But there also another way. `getconf
_NPROCESSORS_ONLN` gives the number of logical CPUs on both Linux and
macOS.
yalpul 5 年之前
父節點
當前提交
6b3479108f
共有 1 個文件被更改,包括 2 次插入4 次删除
  1. 2 4
      formatcode.sh

+ 2 - 4
formatcode.sh

@@ -14,10 +14,8 @@ set -o nounset
 # Get CPU count
 OS=$(uname)
 NPROC=1
-if [[ $OS = "Linux" ]] ; then
-    NPROC=$(nproc)
-elif [[ ${OS} = "Darwin" ]] ; then
-    NPROC=$(sysctl -n hw.physicalcpu)
+if [[ $OS = "Linux" || $OS = "Darwin" ]] ; then
+    NPROC=$(getconf _NPROCESSORS_ONLN)
 fi
 
 # Discover clang-format