Changeset 1931


Ignore:
Timestamp:
Sep 20, 2012, 1:58:29 PM (7 years ago)
Author:
sam
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/build/lol-build

    r1704 r1931  
    4545    top_srcdir="`pwd`"
    4646
     47    # Try to count CPU cores. First obvious try: /proc/cpuinfo on Linux
    4748    case "$cpu_count" in
    4849      [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
    4950      *) if [ -r "/proc/cpuinfo" ]; then
    50            cpu_count="$(grep -c '^processor\>' /proc/cpuinfo)"
     51           cpu_count="$(grep -c '^processor\>' /proc/cpuinfo 2>/dev/null || true)"
    5152         fi ;;
    5253    esac
    53     case "$cpu_count" in
    54       [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
    55       *) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null)" ;;
    56     esac
     54    # If that didn't work, try sysctl (for OS X machines)
     55    case "$cpu_count" in
     56      [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
     57      *) cpu_count="$(sysctl -n hw.ncpu 2>/dev/null || true)" ;;
     58    esac
     59    # Otherwise, CPUInfo.exe (from Xoreax's XGE) may help on Windows
     60    case "$cpu_count" in
     61      [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
     62      *) cpu_count="$(CPUInfo.exe | sed -ne 's/CPU Cores.* \([0-9][0-9]*\)/\1/p')" ;;
     63    esac
     64    # Otherwise, be conservative and assume 1 CPU core
    5765    case "$cpu_count" in
    5866      [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) ;;
    5967      *) cpu_count=1 ;;
    6068    esac
     69    # Now decide how many parallel threads to launch
    6170    case "$cpu_count" in
    6271      1) LOL_PARALLEL=1 ;;
Note: See TracChangeset for help on using the changeset viewer.