瀏覽代碼

build: try to detect the number of CPU cores on Windows.

legacy
Sam Hocevar sam 12 年之前
父節點
當前提交
d953508b81
共有 1 個檔案被更改,包括 11 行新增2 行删除
  1. +11
    -2
      build/lol-build

+ 11
- 2
build/lol-build 查看文件

@@ -44,20 +44,29 @@ __init__()
cd "$top_srcdir"
top_srcdir="`pwd`"

# Try to count CPU cores. First obvious try: /proc/cpuinfo on Linux
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) if [ -r "/proc/cpuinfo" ]; then
cpu_count="$(grep -c '^processor\>' /proc/cpuinfo)"
cpu_count="$(grep -c '^processor\>' /proc/cpuinfo 2>/dev/null || true)"
fi ;;
esac
# If that didn't work, try sysctl (for OS X machines)
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null)" ;;
*) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null || true)" ;;
esac
# Otherwise, CPUInfo.exe (from Xoreax's XGE) may help on Windows
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) cpu_count="$(CPUInfo.exe | sed -ne 's/CPU Cores.* \([0-9][0-9]*\)/\1/p')" ;;
esac
# Otherwise, be conservative and assume 1 CPU core
case "$cpu_count" in
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
*) cpu_count=1 ;;
esac
# Now decide how many parallel threads to launch
case "$cpu_count" in
1) LOL_PARALLEL=1 ;;
2) LOL_PARALLEL=3 ;;


Loading…
取消
儲存