From 782adafc3977fd601ae6e4e671023a6da82a9f4e Mon Sep 17 00:00:00 2001 From: Seth LaForge Date: Sat, 29 Mar 2025 05:21:44 -0700 Subject: [PATCH] Build script improvements. (#7914) * Build script improvements. Add NDEBUG for non-debug MacOS builds. I don't understand why, but on my system Release and RelWithDebugInfo builds were not defining NDEBUG, resulting in failing asserts and other sanity checks. Add -jN flag to BuildLinux.sh. On my 4-core 8GB RAM system, passing -j4 allows building without a swap storm. Improve README.md description of building on macOS. * Merge branch 'main' into bug/macos-ndebug * Merge branch 'main' into bug/macos-ndebug * Merge branch 'SoftFever:main' into bug/macos-ndebug * Improve CMake syntax. Mention Mac path to app. * Merge branch 'main' into bug/macos-ndebug --- BuildLinux.sh | 20 +++++++++++++------- CMakeLists.txt | 2 +- README.md | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/BuildLinux.sh b/BuildLinux.sh index 0f4210b419..44ed284427 100755 --- a/BuildLinux.sh +++ b/BuildLinux.sh @@ -12,21 +12,24 @@ function check_available_memory_and_disk() { MIN_DISK_KB=$((10 * 1024 * 1024)) if [ ${FREE_MEM_GB} -le ${MIN_MEM_GB} ]; then - echo -e "\nERROR: Orca Slicer Builder requires at least ${MIN_MEM_GB}G of 'available' mem (systen has only ${FREE_MEM_GB}G available)" + echo -e "\nERROR: Orca Slicer Builder requires at least ${MIN_MEM_GB}G of 'available' mem (system has only ${FREE_MEM_GB}G available)" echo && free -h && echo + echo "Invoke with -r to skip ram and disk checks." exit 2 fi if [[ ${FREE_DISK_KB} -le ${MIN_DISK_KB} ]]; then - echo -e "\nERROR: Orca Slicer Builder requires at least $(echo ${MIN_DISK_KB} |awk '{ printf "%.1fG\n", $1/1024/1024; }') (systen has only $(echo ${FREE_DISK_KB} | awk '{ printf "%.1fG\n", $1/1024/1024; }') disk free)" + echo -e "\nERROR: Orca Slicer Builder requires at least $(echo ${MIN_DISK_KB} |awk '{ printf "%.1fG\n", $1/1024/1024; }') (system has only $(echo ${FREE_DISK_KB} | awk '{ printf "%.1fG\n", $1/1024/1024; }') disk free)" echo && df -h . && echo + echo "Invoke with -r to skip ram and disk checks." exit 1 fi } function usage() { - echo "Usage: ./BuildLinux.sh [-1][-b][-c][-d][-i][-r][-s][-u]" + echo "Usage: ./BuildLinux.sh [-1][-b][-c][-d][-i][-r][-s][-u] [-j N]" echo " -1: limit builds to 1 core (where possible)" + echo " -j N: limit builds to N cores (where possible)" echo " -b: build in debug mode" echo " -c: force a clean build" echo " -d: build deps (optional)" @@ -40,11 +43,14 @@ function usage() { } unset name -while getopts ":1bcdghirsu" opt; do +while getopts ":1j:bcdghirsu" opt; do case ${opt} in 1 ) export CMAKE_BUILD_PARALLEL_LEVEL=1 ;; + j ) + CMAKE_BUILD_PARALLEL_LEVEL=$OPTARG + ;; b ) BUILD_DEBUG="1" ;; @@ -61,8 +67,8 @@ while getopts ":1bcdghirsu" opt; do BUILD_IMAGE="1" ;; r ) - SKIP_RAM_CHECK="1" - ;; + SKIP_RAM_CHECK="1" + ;; s ) BUILD_ORCA="1" ;; @@ -163,7 +169,7 @@ then else BUILD_ARGS="${BUILD_ARGS} -DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=0" fi - echo -e "cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}" + echo -e "cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 -DORCA_TOOLS=ON ${BUILD_ARGS}" cmake -S . -B build -G Ninja \ -DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" \ -DSLIC3R_STATIC=1 \ diff --git a/CMakeLists.txt b/CMakeLists.txt index c2e104d833..eb51485e48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) if(NOT WIN32) # Add DEBUG flags to debug builds. - add_compile_options("$<$:-DDEBUG>") + add_compile_definitions("$,DEBUG,NDEBUG>") endif() # To be able to link libslic3r with the Perl XS module. diff --git a/README.md b/README.md index bed40f3b23..cd1803ebcc 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,9 @@ Explore the latest developments in Orca Slicer with our nightly builds. Feedback - Mac 64-bit - Tools needed: Xcode, Cmake, git, gettext, libtool, automake, autoconf, texinfo - You can install most of them by running `brew install cmake gettext libtool automake autoconf texinfo` + - If you haven't since upgrading Xcode, start Xcode and install macOS build support. - run `build_release_macos.sh` + - open `build_arm64/OrcaSlicer/OrcaSlicer.app` - To build and debug in Xcode: - run `Xcode.app` - open ``build_`arch`/OrcaSlicer.Xcodeproj`` @@ -119,7 +121,7 @@ Explore the latest developments in Orca Slicer with our nightly builds. Feedback - Ubuntu - Dependencies **Will be auto installed with the shell script**: `libmspack-dev 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 libgtk2.0-dev libglew-dev libudev-dev libdbus-1-dev cmake git texinfo` - run 'sudo ./BuildLinux.sh -u' - - run './BuildLinux.sh -dsir' + - run './BuildLinux.sh -dsi' # Note: If you're running Klipper, it's recommended to add the following configuration to your `printer.cfg` file.