X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=easy-builder;h=fb7cabc83bbeec7fab0089b8bfd6d0412bc80d09;hb=057480298a2d8b73f1a49c6e8d8d162b09c276d4;hp=18517b46a6f6cbf8b4a237817b28723c563d9b7a;hpb=7d2c6f1a6bc7d98320a0685aaac7239cd2ddc449;p=xonotic%2Fnetradiant.git diff --git a/easy-builder b/easy-builder index 18517b46..fb7cabc8 100755 --- a/easy-builder +++ b/easy-builder @@ -14,56 +14,42 @@ install_dir="${project_source_dir}/install${SUBDIR:+/${SUBDIR}}" install_target='install/strip' build_type='Release' -declare -a cmake_opts -case "$(uname -s)" in - 'Linux') - nproc='egrep "^processor" /proc/cpuinfo | wc -l' - ;; - 'FreeBSD') - nproc='sysctl -n hw.ncpu' - - if [ -f "$(ls '/usr/local/bin/g++'* | sort | tail -n1)" ] - then - gcc_version="$(ls '/usr/local/bin/g++'* | sort | tail -n1 | sed -e 's/.*[^0-9]\([0-9][0-9]*\)$/\1/')" - cmake_opts[${#cmake_opts[@]}]="-DCMAKE_C_COMPILER=/usr/local/bin/gcc${gcc_version}" - cmake_opts[${#cmake_opts[@]}]="-DCMAKE_CXX_COMPILER=/usr/local/bin/g++${gcc_version}" - else - printf "WARNING: GCC is recommended: if build fails, install GCC and retry\n" >&2 - fi - ;; - 'Darwin') - nproc='sysctl -n hw.ncpu' - - if [ -f "$(ls '/usr/local/bin/g++-'* | sort | tail -n1)" ] - then - gcc_version="$(ls '/usr/local/bin/g++-'* | sort | tail -n1 | sed -e 's/.*[^0-9]\([0-9][0-9]*\)$/\1/')" - cmake_opts[${#cmake_opts[@]}]="-DCMAKE_C_COMPILER=/usr/local/bin/gcc-${gcc_version}" - cmake_opts[${#cmake_opts[@]}]="-DCMAKE_CXX_COMPILER=/usr/local/bin/g++-${gcc_version}" - else - printf "WARNING: GCC is recommended: if build fails, install GCC and retry\n" >&2 - fi - ;; - 'MSYS_NT-'*) - nproc='echo "${NUMBER_OF_PROCESSORS}"' - ;; - 'CYGWIN_NT-'*|'MINGW'*'_NT-'*) - nproc='echo "${NUMBER_OF_PROCESSORS}"' - printf "WARNING: system is not tested: if build fails, use MSYS2 instead\n" >&2 - ;; - *) - nproc='true' - printf "WARNING: system is not tested\n" >&2 - ;; -esac +_job_count=4 -if command -v 'nproc' >/dev/null -then - job_count="$(nproc)" -else - job_count="$(sh -c "${nproc}")" -fi +_nproc () { + if command -v 'nproc' >/dev/null + then + nproc + else + case "$(uname -s)" in + 'Linux') + egrep "^processor" /proc/cpuinfo | wc -l + ;; + 'FreeBSD') + sysctl -n hw.ncpu + ;; + 'Darwin') + sysctl -n hw.logicalcpu \ + || sysctl -n hw.ncpu + ;; + 'MSYS_NT-'*|'CYGWIN_NT-'*|'MINGW'*'_NT-'*) + if command -v 'wmic' >/dev/null + then + wmic cpu get NumberOfLogicalProcessors/Format:List \ + | grep -m1 '=' | cut -f2 -d'=' + else + echo "${NUMBER_OF_PROCESSORS:-${_job_count}}" + fi + ;; + *) + echo "${_job_count}" + ;; + esac + fi +} -job_count="${job_count:-4}" +job_count="$(_nproc)" 2>/dev/null +job_count="${job_count:-${_job_count}}" declare -a cmake_user_opts while [ ! -z "${1}" ] @@ -95,20 +81,32 @@ do fi done +case "$(uname -s)" in + 'Darwin') + cmake_user_opts[${#cmake_user_opts[@]}]='-DBUILTIN_GTKGLEXT=ON -DBUILTIN_GTKTHEME_MOJAVE=ON' + ;; +esac + set -x "${fetch_submodules_cmd[@]}" +mkdir -pv "${build_dir}" +cd "${build_dir}" + cmake \ -G'Unix Makefiles' \ - -S"${project_source_dir}" \ - -B"${build_dir}" \ -D'CMAKE_INSTALL_PREFIX'="${install_dir}" \ -D'CMAKE_BUILD_TYPE'="${build_type}" \ - "${cmake_opts[@]}" \ "${cmake_user_opts[@]}" \ "${project_source_dir}" +cmake \ + --build "${build_dir}" \ + -- \ + -j"${job_count}" \ + 'builtins' + cmake \ --build "${build_dir}" \ -- \