You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
552 B
11 lines
552 B
3 years ago
|
# Macros to constrain resource use during the build process
|
||
|
|
||
|
# m: memory limit in MBs per core; default is 1024
|
||
|
%limit_build(m:) \
|
||
|
_mem_per_process="%{-m:%{-m*}}%{!-m:1024}" \
|
||
|
_max_mem=$(awk '/MemTotal/ { print $2 }' /proc/meminfo) \
|
||
|
_max_jobs="$(($_max_mem / ($_mem_per_process * 1024)))" \
|
||
|
_cur_max_jobs="%{_smp_build_ncpus}" \
|
||
|
test "${_cur_max_jobs}" -gt "${_max_jobs}" && _cur_max_jobs="${_max_jobs}" && echo "Warning: Reducing build parallelism to -j${_max_jobs} because of memory limits" \
|
||
|
%global _smp_build_ncpus "${_cur_max_jobs}"
|