From 0917c997e53b2bfac87b622ed10110d8fa3f9829 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Wed, 17 Jul 2024 09:00:22 +0800 Subject: [PATCH 1/4] ENH: build: turn on build_all Change-Id: I69baf0712a68abe1965075d9fc18825eb23c0ff8 --- .github/workflows/build_all.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index e91326282..e53485d8c 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -15,7 +15,7 @@ on: pull_request: branches: - - main + - master paths: - 'deps/**' - 'src/**' @@ -53,4 +53,4 @@ jobs: os: ${{ matrix.os }} arch: ${{ matrix.arch }} build-deps-only: ${{ inputs.build-deps-only || false }} - secrets: inherit \ No newline at end of file + secrets: inherit From 61fbef4a843f643323c7098e50b119287da72fc4 Mon Sep 17 00:00:00 2001 From: Mack Date: Thu, 27 Jun 2024 14:19:57 +0800 Subject: [PATCH 2/4] ENH: ubuntu 24.04 build using libwebkit2gtk-4.1-dev JIRA: STUDIO-4377 GITHUB: #2429 Change-Id: Ia153a6d387e8ebc7da19d5ba7bd5012aea8ed93c (cherry picked from commit ce5ff82781bde579acaeb2d8cae69e9825549983) --- BuildLinux.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/BuildLinux.sh b/BuildLinux.sh index 2496a2ac9..66d4647df 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -101,20 +101,23 @@ then echo -e "\nFind libgtk-3, installing: libgtk-3-dev libglew-dev libudev-dev libdbus-1-dev cmake git\n" apt install -y libgtk-3-dev libglew-dev libudev-dev libdbus-1-dev cmake git fi - # for ubuntu 22.04: + # for ubuntu: ubu_version="$(cat /etc/issue)" if [[ $ubu_version == "Ubuntu 22.04"* ]] then - apt install -y curl libssl-dev libcurl4-openssl-dev m4 + apt install -y curl libssl-dev libcurl4-openssl-dev m4 libwebkit2gtk-4.0-dev elif [[ $ubu_version == "Ubuntu 24.04"* ]] then - NEW_SOURCE="deb http://gb.archive.ubuntu.com/ubuntu jammy main" - if grep -qF -- "$NEW_SOURCE" /etc/apt/sources.list; then - echo "source exist: $NEW_SOURCE" - else - echo "$NEW_SOURCE" | sudo tee -a /etc/apt/sources.list > /dev/null - fi - apt update + # NEW_SOURCE="deb http://gb.archive.ubuntu.com/ubuntu jammy main" + # if grep -qF -- "$NEW_SOURCE" /etc/apt/sources.list; then + # echo "source exist: $NEW_SOURCE" + # else + # echo "$NEW_SOURCE" | sudo tee -a /etc/apt/sources.list > /dev/null + # fi + # apt update + apt install -y libwebkit2gtk-4.1-dev + else + apt install -y libwebkit2gtk-4.0-dev fi if [[ -n "$BUILD_DEBUG" ]] then @@ -123,7 +126,7 @@ then fi # Addtional Dev packages for BambuStudio - export REQUIRED_DEV_PACKAGES="libgstreamerd-3-dev libsecret-1-dev libwebkit2gtk-4.0-dev libosmesa6-dev libssl-dev libcurl4-openssl-dev eglexternalplatform-dev libudev-dev libdbus-1-dev extra-cmake-modules" + export REQUIRED_DEV_PACKAGES="libgstreamerd-3-dev libsecret-1-dev libosmesa6-dev libssl-dev libcurl4-openssl-dev eglexternalplatform-dev libudev-dev libdbus-1-dev extra-cmake-modules" # libwebkit2gtk-4.1-dev ?? export DEV_PACKAGES_COUNT=$(echo ${REQUIRED_DEV_PACKAGES} | wc -w) if [ $(dpkg --get-selections | grep -E "$(echo ${REQUIRED_DEV_PACKAGES} | tr ' ' '|')" | wc -l) -lt ${DEV_PACKAGES_COUNT} ]; then From b6715f352d71f94d6585a68e4efa32fcda4a330a Mon Sep 17 00:00:00 2001 From: MackBambu Date: Thu, 11 Jul 2024 11:01:10 +0800 Subject: [PATCH 3/4] ENH: Refactor BuildLinux.sh to support fedora JIRA: STUDIO-4377 STUDIO-7461 GITHUB: #2429 Change-Id: Ib4f14a88d04e789a58b1f83425a1708ce4934b0e (cherry picked from commit a7c9e9e288694fe72665e45977f0676d827c767f) --- .github/workflows/build_bambu.yml | 7 - .github/workflows/build_deps.yml | 4 - BuildLinux.sh | 270 ++++++++++-------------------- linux.d/debian | 59 +++++++ linux.d/fedora | 61 +++++++ 5 files changed, 210 insertions(+), 191 deletions(-) create mode 100644 linux.d/debian create mode 100644 linux.d/fedora diff --git a/.github/workflows/build_bambu.yml b/.github/workflows/build_bambu.yml index 194bb774f..ba7eb0a0a 100644 --- a/.github/workflows/build_bambu.yml +++ b/.github/workflows/build_bambu.yml @@ -224,13 +224,6 @@ jobs: # max_releases: 1 # Ubuntu - - name: Install dependencies - if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' - run: | - sudo apt-get update - sudo apt-get install -y autoconf build-essential cmake curl wget file git \ - libgl1-mesa-dev libgtk-3-dev libxkbcommon-dev libunwind-dev libfuse2 - - name: Install dependencies from BuildLinux.sh if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' shell: bash diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index d4ead356b..7f2e00381 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -98,10 +98,6 @@ jobs: if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' working-directory: ${{ github.workspace }} run: | - sudo apt-get update - sudo apt-get install libgl1-mesa-dev libgtk-3-dev libxkbcommon-dev libunwind-dev libfuse2 -y - mkdir -p ${{ github.workspace }}/deps/build - mkdir -p ${{ github.workspace }}/deps/build/destdir sudo ./BuildLinux.sh -ur sudo chown $USER -R ./ ./BuildLinux.sh -dr diff --git a/BuildLinux.sh b/BuildLinux.sh index 66d4647df..d3c79e106 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -1,11 +1,8 @@ #!/bin/bash -set -e # exit on first error -export ROOT=`pwd` -export NCORES=`nproc --all` -export CMAKE_BUILD_PARALLEL_LEVEL=${NCORES} -FOUND_GTK2=$(dpkg -l libgtk* | grep gtk2) -FOUND_GTK3=$(dpkg -l libgtk* | grep gtk-3) +export ROOT=$(dirname $(readlink -f ${0})) + +set -e # exit on first error function check_available_memory_and_disk() { FREE_MEM_GB=$(free -g -t | grep 'Mem' | rev | cut -d" " -f1 | rev) @@ -27,246 +24,159 @@ function check_available_memory_and_disk() { fi } +function usage() { + echo "Usage: ./BuildLinux.sh [-1][-b][-c][-d][-i][-r][-s][-u]" + echo " -1: limit builds to 1 core (where possible)" + echo " -b: build in debug mode" + echo " -c: force a clean build" + echo " -d: build deps (optional)" + echo " -h: this help output" + echo " -i: Generate appimage (optional)" + echo " -r: skip ram and disk checks (low ram compiling)" + echo " -s: build bambu-studio (optional)" + echo " -u: update and build dependencies (optional and need sudo)" + echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'" + echo " and then './BuildLinux.sh -dsi'" +} + unset name -while getopts ":dsiuhgbr" opt; do +while getopts ":1bcdghirsu" opt; do case ${opt} in - u ) - UPDATE_LIB="1" + 1 ) + export CMAKE_BUILD_PARALLEL_LEVEL=1 ;; - i ) - BUILD_IMAGE="1" + b ) + BUILD_DEBUG="1" + ;; + c ) + CLEAN_BUILD=1 ;; d ) BUILD_DEPS="1" ;; - s ) - BUILD_BAMBU_STUDIO="1" - ;; - b ) - BUILD_DEBUG="1" + h ) usage + exit 0 ;; - g ) - FOUND_GTK3="" + i ) + BUILD_IMAGE="1" ;; r ) - SKIP_RAM_CHECK="1" + SKIP_RAM_CHECK="1" ;; - h ) echo "Usage: ./BuildLinux.sh [-i][-u][-d][-s][-b][-g]" - echo " -i: Generate appimage (optional)" - echo " -g: force gtk2 build" - echo " -b: build in debug mode" - echo " -d: build deps (optional)" - echo " -s: build bambu-studio (optional)" - echo " -u: only update clock & dependency packets (optional and need sudo)" - echo " -r: skip free ram check (low ram compiling)" - echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'" - echo " and then './BuildLinux.sh -dsi'" - exit 0 + s ) + BUILD_BAMBU_STUDIO="1" + ;; + u ) + UPDATE_LIB="1" ;; esac done -if [ $OPTIND -eq 1 ] +if [ ${OPTIND} -eq 1 ] then - echo "Usage: ./BuildLinux.sh [-i][-u][-d][-s][-b][-g]" - echo " -i: Generate appimage (optional)" - echo " -g: force gtk2 build" - echo " -b: build in debug mode" - echo " -d: build deps (optional)" - echo " -s: build bambu-studio (optional)" - echo " -u: only update clock & dependency packets (optional and need sudo)" - echo " -r: skip free ram check (low ram compiling)" - echo "For a first use, you want to 'sudo ./BuildLinux.sh -u'" - echo " and then './BuildLinux.sh -dsi'" + usage exit 0 fi -# mkdir build -if [ ! -d "build" ] +DISTRIBUTION=$(awk -F= '/^ID=/ {print $2}' /etc/os-release) +VERSION=$(awk -F= '/^VERSION_ID=/ {print $2}' /etc/os-release) +# treat ubuntu as debian +if [ "${DISTRIBUTION}" == "ubuntu" ] then - mkdir build + DISTRIBUTION="debian" fi - -#FIXME: require root for -u option -if [[ -n "$UPDATE_LIB" ]] +if [ ! -f ./linux.d/${DISTRIBUTION} ] then - echo -n -e "Updating linux ...\n" - # hwclock -s # DeftDawg: Why does SuperSlicer want to do this? - apt update - if [[ -z "$FOUND_GTK3" ]] - then - echo -e "\nInstalling: libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev cmake git\n" - apt install -y libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev cmake git - else - echo -e "\nFind libgtk-3, installing: libgtk-3-dev libglew-dev libudev-dev libdbus-1-dev cmake git\n" - apt install -y libgtk-3-dev libglew-dev libudev-dev libdbus-1-dev cmake git - fi - # for ubuntu: - ubu_version="$(cat /etc/issue)" - if [[ $ubu_version == "Ubuntu 22.04"* ]] - then - apt install -y curl libssl-dev libcurl4-openssl-dev m4 libwebkit2gtk-4.0-dev - elif [[ $ubu_version == "Ubuntu 24.04"* ]] - then - # NEW_SOURCE="deb http://gb.archive.ubuntu.com/ubuntu jammy main" - # if grep -qF -- "$NEW_SOURCE" /etc/apt/sources.list; then - # echo "source exist: $NEW_SOURCE" - # else - # echo "$NEW_SOURCE" | sudo tee -a /etc/apt/sources.list > /dev/null - # fi - # apt update - apt install -y libwebkit2gtk-4.1-dev - else - apt install -y libwebkit2gtk-4.0-dev - fi - if [[ -n "$BUILD_DEBUG" ]] - then - echo -e "\nInstalling: libssl-dev libcurl4-openssl-dev\n" - apt install -y libssl-dev libcurl4-openssl-dev - fi - - # Addtional Dev packages for BambuStudio - export REQUIRED_DEV_PACKAGES="libgstreamerd-3-dev libsecret-1-dev libosmesa6-dev libssl-dev libcurl4-openssl-dev eglexternalplatform-dev libudev-dev libdbus-1-dev extra-cmake-modules" - # libwebkit2gtk-4.1-dev ?? - export DEV_PACKAGES_COUNT=$(echo ${REQUIRED_DEV_PACKAGES} | wc -w) - if [ $(dpkg --get-selections | grep -E "$(echo ${REQUIRED_DEV_PACKAGES} | tr ' ' '|')" | wc -l) -lt ${DEV_PACKAGES_COUNT} ]; then - sudo apt install -y ${REQUIRED_DEV_PACKAGES} git cmake wget file - fi - echo -e "done\n" - exit 0 + echo "Your distribution does not appear to be currently supported by these build scripts" + exit 1 fi +source ./linux.d/${DISTRIBUTION} -FOUND_GTK2_DEV=$(dpkg -l libgtk* | grep gtk2.0-dev || echo '') -FOUND_GTK3_DEV=$(dpkg -l libgtk* | grep gtk-3-dev || echo '') -echo "FOUND_GTK2=$FOUND_GTK2)" -if [[ -z "$FOUND_GTK2_DEV" ]] -then -if [[ -z "$FOUND_GTK3_DEV" ]] +echo "FOUND_GTK3=${FOUND_GTK3}" +if [[ -z "${FOUND_GTK3_DEV}" ]] then echo "Error, you must install the dependencies before." echo "Use option -u with sudo" - exit 0 -fi + exit 1 fi -echo "[1/9] Updating submodules..." -{ - # update submodule profiles - pushd resources/profiles - git submodule update --init - popd -} - -echo "[2/9] Changing date in version..." +echo "Changing date in version..." { # change date in version sed -i "s/+UNKNOWN/_$(date '+%F')/" version.inc } echo "done" -# mkdir in deps -if [ ! -d "deps/build" ] -then - mkdir deps/build -fi - -if ! [[ -n "$SKIP_RAM_CHECK" ]] +if ! [[ -n "${SKIP_RAM_CHECK}" ]] then -check_available_memory_and_disk + check_available_memory_and_disk fi -if [[ -n "$BUILD_DEPS" ]] +if [[ -n "${BUILD_DEPS}" ]] then - echo "[3/9] Configuring dependencies..." - BUILD_ARGS="" - if [[ -n "$FOUND_GTK3_DEV" ]] + echo "Configuring dependencies..." + BUILD_ARGS="-DDEP_WX_GTK3=ON" + if [[ -n "${CLEAN_BUILD}" ]] + then + rm -fr deps/build + fi + if [ ! -d "deps/build" ] then - BUILD_ARGS="-DDEP_WX_GTK3=ON" + mkdir deps/build fi - if [[ -n "$BUILD_DEBUG" ]] + if [[ -n "${BUILD_DEBUG}" ]] then - # have to build deps with debug & release or the cmake won't find evrything it needs + # have to build deps with debug & release or the cmake won't find everything it needs mkdir deps/build/release - pushd deps/build/release - cmake ../.. -DDESTDIR="../destdir" $BUILD_ARGS - make -j$NCORES - popd + cmake -S deps -B deps/build/release -G Ninja -DDESTDIR="../destdir" ${BUILD_ARGS} + cmake --build deps/build/release BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug" fi - - # cmake deps - pushd deps/build - cmake .. $BUILD_ARGS - echo "done" - - # make deps - echo "[4/9] Building dependencies..." - make -j$NCORES - echo "done" - - # rename wxscintilla # TODO: DeftDawg: Does BambuStudio need this? - # echo "[5/9] Renaming wxscintilla library..." - # pushd destdir/usr/local/lib - # if [[ -z "$FOUND_GTK3_DEV" ]] - # then - # cp libwxscintilla-3.1.a libwx_gtk2u_scintilla-3.1.a - # else - # cp libwxscintilla-3.1.a libwx_gtk3u_scintilla-3.1.a - # fi - # popd - # echo "done" - # FIXME: only clean deps if compiling succeeds; otherwise reruns waste tonnes of time! - # clean deps - # echo "[6/9] Cleaning dependencies..." - # rm -rf dep_* - popd - echo "done" + echo "cmake -S deps -B deps/build -G Ninja ${BUILD_ARGS}" + cmake -S deps -B deps/build -G Ninja ${BUILD_ARGS} + cmake --build deps/build fi -if [[ -n "$BUILD_BAMBU_STUDIO" ]] +if [[ -n "${BUILD_BAMBU_STUDIO}" ]] then - echo "[7/9] Configuring Slic3r..." + echo "Configuring BambuStudio..." + if [[ -n "${CLEAN_BUILD}" ]] + then + rm -fr build + fi BUILD_ARGS="" - if [[ -n "$FOUND_GTK3_DEV" ]] + if [[ -n "${FOUND_GTK3_DEV}" ]] then BUILD_ARGS="-DSLIC3R_GTK=3" fi - if [[ -n "$BUILD_DEBUG" ]] + if [[ -n "${BUILD_DEBUG}" ]] then BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug -DBBL_INTERNAL_TESTING=1" else BUILD_ARGS="${BUILD_ARGS} -DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=0" fi - - # cmake - pushd build - cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS} - echo "done" - - # make Slic3r - echo "[8/9] Building Slic3r..." - make -j$NCORES BambuStudio # Slic3r - - # make .mo - # make gettext_po_to_mo # FIXME: DeftDawg: complains about msgfmt not existing even in SuperSlicer, did this ever work? - - popd + echo -e "cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}" + cmake -S . -B build -G Ninja \ + -DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" \ + -DSLIC3R_STATIC=1 \ + ${BUILD_ARGS} + echo "done" + echo "Building BambuStudio ..." + cmake --build build --target BambuStudio echo "done" fi -if [[ -e $ROOT/build/src/BuildLinuxImage.sh ]]; then +if [[ -e ${ROOT}/build/src/BuildLinuxImage.sh ]]; then # Give proper permissions to script -chmod 755 $ROOT/build/src/BuildLinuxImage.sh +chmod 755 ${ROOT}/build/src/BuildLinuxImage.sh echo "[9/9] Generating Linux app..." pushd build - if [[ -n "$BUILD_IMAGE" ]] + if [[ -n "${BUILD_IMAGE}" ]] then - $ROOT/build/src/BuildLinuxImage.sh -i - else - $ROOT/build/src/BuildLinuxImage.sh + ${ROOT}/build/src/BuildLinuxImage.sh -i fi popd echo "done" -fi +fi \ No newline at end of file diff --git a/linux.d/debian b/linux.d/debian new file mode 100644 index 000000000..b519d2e7f --- /dev/null +++ b/linux.d/debian @@ -0,0 +1,59 @@ +FOUND_GTK3=$(dpkg -l libgtk* | grep gtk-3) + +REQUIRED_DEV_PACKAGES=( + autoconf + build-essential + ninja-build + cmake + extra-cmake-modules + file + gettext + git + wget + libgstreamerd-3-dev + libsecret-1-dev + libosmesa6-dev + libssl-dev + eglexternalplatform-dev + libcurl4-openssl-dev + libdbus-1-dev + libglew-dev + libudev-dev + libmspack-dev + libgl1-mesa-dev + libgtk-3-dev + libxkbcommon-dev + libtool + libunwind-dev + libfuse2 + texinfo +) + +if [[ -n "$UPDATE_LIB" ]] +then + # for ubuntu 22+ and 23+: + ubu_major_version="$(grep VERSION_ID /etc/os-release | cut -d "=" -f 2 | cut -d "." -f 1 | tr -d /\"/)" + if [ $ubu_major_version == "22" ] || [ $ubu_major_version == "23" ] + then + REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.0-dev curl libfuse-dev libssl-dev libcurl4-openssl-dev m4) + elif [ $ubu_major_version == "24" ] + then + REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.1-dev) + else + REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.0-dev) + fi + if [[ -n "$BUILD_DEBUG" ]] + then + REQUIRED_DEV_PACKAGES+=(libssl-dev libcurl4-openssl-dev) + fi + # TODO: optimize this by checking which, if any, packages are already installed + + # install them all at once + sudo apt update + sudo apt install -y ${REQUIRED_DEV_PACKAGES[@]} + + echo -e "done\n" + exit 0 +fi + +FOUND_GTK3_DEV=$(dpkg -l libgtk* | grep gtk-3-dev || echo '') \ No newline at end of file diff --git a/linux.d/fedora b/linux.d/fedora new file mode 100644 index 000000000..dd48349a3 --- /dev/null +++ b/linux.d/fedora @@ -0,0 +1,61 @@ +FOUND_GTK3=$(rpm -qa | grep -P '^gtk3' || true) + +REQUIRED_DEV_PACKAGES=( + autoconf + automake + cmake + dbus-devel + eglexternalplatform-devel + extra-cmake-modules + file + gcc + gcc-c++ + gettext + git + perl + gstreamer1-devel + gstreamer1-plugins-base-devel + gstreamer1-plugin-openh264 + gstreamermm-devel + gtk3-devel + libmspack-devel + libsecret-devel + libtool + m4 + mesa-libGLU-devel + mesa-libOSMesa-devel + mesa-libGL-devel + ninja-build + openssl-devel + perl-FindBin + texinfo + wayland-devel + wayland-protocols-devel + libxkbcommon-devel + wget + libcurl-devel + libquadmath-devel +) + +if [[ -n "$UPDATE_LIB" ]] +then + NEEDED_PKGS="" + fedora_version=$(awk -F= '/^VERSION_ID=/ {print $2}' /etc/os-release) + if [ $fedora_version == "40" ] + then + REQUIRED_DEV_PACKAGES+=(webkit2gtk4.1-devel) + else + REQUIRED_DEV_PACKAGES+=(webkit2gtk4.0-devel) + fi + for PKG in ${REQUIRED_DEV_PACKAGES[@]}; do + rpm -q ${PKG} > /dev/null || NEEDED_PKGS+=" ${PKG}" + done + + if [ -n "${NEEDED_PKGS}" ]; then + sudo dnf install -y ${NEEDED_PKGS} + fi + echo -e "done\n" + exit 0 +fi + +FOUND_GTK3_DEV=$(rpm -qa | grep -P '^gtk3-devel' || true) \ No newline at end of file From 88ba37c119142cf8bcad73c341d06ae1bdca31a3 Mon Sep 17 00:00:00 2001 From: Mack Date: Fri, 12 Jul 2024 15:25:33 +0800 Subject: [PATCH 4/4] 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) --- .github/workflows/build_bambu.yml | 2 +- .github/workflows/build_deps.yml | 2 +- BuildLinux.sh | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_bambu.yml b/.github/workflows/build_bambu.yml index ba7eb0a0a..b6a63912c 100644 --- a/.github/workflows/build_bambu.yml +++ b/.github/workflows/build_bambu.yml @@ -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 diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index 7f2e00381..0ed634e21 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -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 diff --git a/BuildLinux.sh b/BuildLinux.sh index d3c79e106..11ea412d6 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -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..."