NEW: BuildLinux.sh add parallel count limit

JIRA:no

Detecting the free memory(GB)/2.5 set to the number of parallels

Change-Id: I171807071af9819e2a3aad0e27355d95975dbaa0
(cherry picked from commit 898ccf372931c09ae653cbb004a66223d5662817)
This commit is contained in:
Mack 2024-07-12 15:25:33 +08:00 committed by Lane.Wei
parent fe359394f3
commit ce360ce9eb
3 changed files with 20 additions and 3 deletions

View File

@ -238,7 +238,7 @@ jobs:
if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04'
shell: bash
run: |
./BuildLinux.sh -isr
./BuildLinux.sh -isfr
mv -n ./build/BambuStudio_ubu64.AppImage ./build/Bambu_Studio_${{inputs.os}}_${{ env.ver }}.AppImage
# - name: Build orca_custom_preset_tests

View File

@ -100,7 +100,7 @@ jobs:
run: |
sudo ./BuildLinux.sh -ur
sudo chown $USER -R ./
./BuildLinux.sh -dr
./BuildLinux.sh -dfr
cd deps/build
tar -czvf BambuStudio_dep_${{ inputs.os }}_$(date +"%Y%m%d").tar.gz destdir

View File

@ -27,6 +27,7 @@ function check_available_memory_and_disk() {
function usage() {
echo "Usage: ./BuildLinux.sh [-1][-b][-c][-d][-i][-r][-s][-u]"
echo " -1: limit builds to 1 core (where possible)"
echo " -f: disable safe parallel number limit(By default, the maximum number of parallels is set to free memory/2.5)"
echo " -b: build in debug mode"
echo " -c: force a clean build"
echo " -d: build deps (optional)"
@ -40,11 +41,14 @@ function usage() {
}
unset name
while getopts ":1bcdghirsu" opt; do
while getopts ":1fbcdghirsu" opt; do
case ${opt} in
1 )
export CMAKE_BUILD_PARALLEL_LEVEL=1
;;
f )
DISABLE_PARALLEL_LIMIT=1
;;
b )
BUILD_DEBUG="1"
;;
@ -112,6 +116,19 @@ then
check_available_memory_and_disk
fi
if ! [[ -n "${DISABLE_PARALLEL_LIMIT}" ]]
then
FREE_MEM_GB=$(free -g -t | grep 'Mem' | rev | cut -d" " -f1 | rev)
MAX_THREADS=$(echo "scale=0; $FREE_MEM_GB / 2.5" | bc)
if [ "$MAX_THREADS" -lt 1 ]; then
export CMAKE_BUILD_PARALLEL_LEVEL=1
else
export CMAKE_BUILD_PARALLEL_LEVEL=${MAX_THREADS}
fi
echo "System free memory: ${FREE_MEM_GB} GB"
echo "Setting CMAKE_BUILD_PARALLEL_LEVEL: ${CMAKE_BUILD_PARALLEL_LEVEL}"
fi
if [[ -n "${BUILD_DEPS}" ]]
then
echo "Configuring dependencies..."