From 966c4ac497fa8ed976c7cacca83b81d3ff7d76a8 Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Sat, 1 Feb 2025 01:33:29 +0100 Subject: [PATCH 1/3] fixes and refactors linux build scripts - build_linux.sh: fixes wrong AppImage build folder; refactors script; enhances help text - harmonizes names: BuildLinux.sh and BuildLinuxImage.sh - fixes file permissions: cmake inherits .in-file permission; removes chmod 755 in scripts - linux.d/debian: removes false positive error message - updates documentation --- .devcontainer/postCreate.sh | 7 +- .github/workflows/build_all.yml | 2 +- .github/workflows/build_deps.yml | 4 +- .github/workflows/build_orca.yml | 6 +- BuildLinux.sh | 192 ------------------ CMakeLists.txt | 2 +- Dockerfile | 8 +- README.md | 4 +- build_linux.sh | 188 +++++++++++++++++ doc/How-to-build.md | 2 +- linux.d/README.md | 2 +- linux.d/debian | 2 +- src/CMakeLists.txt | 2 +- ...nuxImage.sh.in => build_linux_image.sh.in} | 12 +- 14 files changed, 215 insertions(+), 218 deletions(-) delete mode 100755 BuildLinux.sh create mode 100755 build_linux.sh rename src/platform/unix/{BuildLinuxImage.sh.in => build_linux_image.sh.in} (93%) mode change 100644 => 100755 diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index ea76f8e22c4..b805c08b8b8 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -3,12 +3,13 @@ apt update apt upgrade -y +build_linux="./build_linux.sh -u" echo "-----------------------------------------" -echo "Running BuildLinux.sh with update flag..." +echo "Running ${build_linux}..." echo "-----------------------------------------" -./BuildLinux.sh -u +${build_linux} echo "------------------------------" echo "Installing missing packages..." echo "------------------------------" -apt install -y libgl1-mesa-dev m4 autoconf libtool \ No newline at end of file +apt install -y libgl1-mesa-dev m4 autoconf libtool diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 5da2b6979f9..a5a3cf94a1b 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -24,7 +24,7 @@ on: - '**/CMakeLists.txt' - 'version.inc' - ".github/workflows/build_*.yml" - - 'BuildLinux.sh' + - 'build_linux.sh' - 'build_release_vs2022.bat' - 'build_release_macos.sh' diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index 163cbca23c0..b453dbbff2f 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -103,9 +103,9 @@ jobs: run: | mkdir -p ${{ github.workspace }}/deps/build mkdir -p ${{ github.workspace }}/deps/build/destdir - sudo ./BuildLinux.sh -ur + sudo ./build_linux.sh -ur sudo chown $USER -R ./ - ./BuildLinux.sh -dr + ./build_linux.sh -dr cd deps/build tar -czvf OrcaSlicer_dep_ubuntu_$(date +"%Y%m%d").tar.gz destdir diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index e417b3ef36c..bde164240d9 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -247,10 +247,10 @@ jobs: libgtk-3-dev libgtk-3-dev libmspack-dev libosmesa6-dev libsecret-1-dev libsoup2.4-dev libssl-dev libudev-dev libwayland-dev \ libwebkit2gtk-${{ env.webkit-ver }}-dev libxkbcommon-dev locales locales-all m4 pkgconf sudo wayland-protocols wget ${{ env.libfuse2-pkg }} - - name: Install dependencies from BuildLinux.sh + - name: Install dependencies from build_linux.sh if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' shell: bash - run: sudo ./BuildLinux.sh -ur + run: sudo ./build_linux.sh -ur - name: Fix permissions if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' @@ -263,7 +263,7 @@ jobs: env: ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} run: | - ./BuildLinux.sh -isr + ./build_linux.sh -isr mv -n ./build/OrcaSlicer_Linux_V${{ env.ver_pure }}.AppImage ./build/OrcaSlicer_Linux_AppImage${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage chmod +x ./build/OrcaSlicer_Linux_AppImage${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage diff --git a/BuildLinux.sh b/BuildLinux.sh deleted file mode 100755 index 28d84fb0462..00000000000 --- a/BuildLinux.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/bash - -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) - MIN_MEM_GB=10 - - FREE_DISK_KB=$(df -k . | tail -1 | awk '{print $4}') - 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 && free -h && echo - 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 && df -h . && echo - exit 1 - 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 orca-slicer (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 ":1bcdghirsu" opt; do - case ${opt} in - 1 ) - export CMAKE_BUILD_PARALLEL_LEVEL=1 - ;; - b ) - BUILD_DEBUG="1" - ;; - c ) - CLEAN_BUILD=1 - ;; - d ) - BUILD_DEPS="1" - ;; - h ) usage - exit 0 - ;; - i ) - BUILD_IMAGE="1" - ;; - r ) - SKIP_RAM_CHECK="1" - ;; - s ) - BUILD_ORCA="1" - ;; - u ) - UPDATE_LIB="1" - ;; - esac -done - -if [ ${OPTIND} -eq 1 ] -then - usage - exit 0 -fi - -DISTRIBUTION=$(awk -F= '/^ID=/ {print $2}' /etc/os-release) -# treat ubuntu as debian -if [ "${DISTRIBUTION}" == "ubuntu" ] || [ "${DISTRIBUTION}" == "linuxmint" ] -then - DISTRIBUTION="debian" -fi -if [ ! -f ./linux.d/${DISTRIBUTION} ] -then - echo "Your distribution does not appear to be currently supported by these build scripts" - exit 1 -fi -source ./linux.d/${DISTRIBUTION} - -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 1 -fi - -echo "Changing date in version..." -{ - # change date in version - sed -i "s/+UNKNOWN/_$(date '+%F')/" version.inc -} -echo "done" - - -if ! [[ -n "${SKIP_RAM_CHECK}" ]] -then - check_available_memory_and_disk -fi - -if [[ -n "${BUILD_DEPS}" ]] -then - echo "Configuring dependencies..." - BUILD_ARGS="-DDEP_WX_GTK3=ON" - if [[ -n "${CLEAN_BUILD}" ]] - then - rm -fr deps/build - fi - if [ ! -d "deps/build" ] - then - mkdir deps/build - fi - if [[ -n "${BUILD_DEBUG}" ]] - then - # have to build deps with debug & release or the cmake won't find everything it needs - if [ ! -d "deps/build/release" ] - then - mkdir deps/build/release - fi - cmake -S deps -B deps/build/release -G Ninja -DDESTDIR="${PWD}/deps/build/destdir" -DDEP_DOWNLOAD_DIR="${PWD}/deps/DL_CACHE" ${BUILD_ARGS} - cmake --build deps/build/release - BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug" - fi - - 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_ORCA}" ]] -then - echo "Configuring OrcaSlicer..." - if [[ -n "${CLEAN_BUILD}" ]] - then - rm -fr build - fi - BUILD_ARGS="" - if [[ -n "${FOUND_GTK3_DEV}" ]] - then - BUILD_ARGS="-DSLIC3R_GTK=3" - fi - 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 - 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 \ - -DORCA_TOOLS=ON \ - ${BUILD_ARGS} - echo "done" - echo "Building OrcaSlicer ..." - cmake --build build --target OrcaSlicer - echo "Building OrcaSlicer_profile_validator .." - cmake --build build --target OrcaSlicer_profile_validator - ./run_gettext.sh - echo "done" -fi - -if [[ -e ${ROOT}/build/src/BuildLinuxImage.sh ]]; then -# Give proper permissions to script -chmod 755 ${ROOT}/build/src/BuildLinuxImage.sh - -echo "[9/9] Generating Linux app..." - pushd build - if [[ -n "${BUILD_IMAGE}" ]] - then - ${ROOT}/build/src/BuildLinuxImage.sh -i - else - ${ROOT}/build/src/BuildLinuxImage.sh - fi - popd -echo "done" -fi diff --git a/CMakeLists.txt b/CMakeLists.txt index ac1af19e336..4016c8c4eca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -761,7 +761,7 @@ endif() if (NOT WIN32 AND NOT APPLE) set(SLIC3R_APP_CMD "orca-slicer") - configure_file(${LIBDIR}/platform/unix/build_appimage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_appimage.sh @ONLY) + configure_file(${LIBDIR}/platform/unix/build_appimage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_appimage.sh USE_SOURCE_PERMISSIONS @ONLY) endif() option(BUILD_BBS_TEST_TOOLS "Build bbs test tools" OFF) diff --git a/Dockerfile b/Dockerfile index 9e6bdb42914..6f4ad663ad2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,17 +65,17 @@ WORKDIR OrcaSlicer # These can run together, but we run them seperate for podman caching # Update System dependencies -RUN ./BuildLinux.sh -u +RUN ./build_linux.sh -u # Build dependencies in ./deps -RUN ./BuildLinux.sh -dr +RUN ./build_linux.sh -dr # Build slic3r -RUN ./BuildLinux.sh -sr +RUN ./build_linux.sh -sr # Build AppImage ENV container podman -RUN ./BuildLinux.sh -ir +RUN ./build_linux.sh -ir # It's easier to run Orca Slicer as the same username, # UID and GID as your workstation. Since we bind mount diff --git a/README.md b/README.md index bed40f3b231..f697de141d1 100644 --- a/README.md +++ b/README.md @@ -118,8 +118,8 @@ Explore the latest developments in Orca Slicer with our nightly builds. Feedback - For most common errors, open `DockerRun.sh` and read the comments. - 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 './build_linux.sh -u' + - run './build_linux.sh -dsir' # Note: If you're running Klipper, it's recommended to add the following configuration to your `printer.cfg` file. diff --git a/build_linux.sh b/build_linux.sh new file mode 100755 index 00000000000..179faf09abf --- /dev/null +++ b/build_linux.sh @@ -0,0 +1,188 @@ +#!/usr/bin/env bash + +SCRIPT_NAME=$(basename "$0") +SCRIPT_PATH=$(dirname $(readlink -f ${0})) + +pushd ${SCRIPT_PATH} > /dev/null + +set -e # Exit immediately if a command exits with a non-zero status. + +function check_available_memory_and_disk() { + FREE_MEM_GB=$(free --gibi --total | grep 'Mem' | rev | cut --delimiter=" " --fields=1 | rev) + MIN_MEM_GB=10 + + FREE_DISK_KB=$(df --block-size=1K . | tail -1 | awk '{print $4}') + 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 && free --human && echo + 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 && df --human-readable . && echo + exit 1 + fi +} + +function usage() { + echo "Usage: ./${SCRIPT_NAME} [-1][-b][-c][-d][-h][-i][-r][-s][-u]" + echo " -1: limit builds to one core (where possible)" + echo " -b: build in debug mode" + echo " -c: force a clean build" + echo " -d: download and build dependencies in ./deps/ (build prerequisite)" + echo " -h: prints this help text" + echo " -i: build the Orca Slicer AppImage (optional)" + echo " -r: skip RAM and disk checks (low RAM compiling)" + echo " -s: build the Orca Slicer (optional)" + echo " -u: install system dependencies (asks for sudo password; build prerequisite)" + echo "For a first use, you want to './${SCRIPT_NAME} -u'" + echo " and then './${SCRIPT_NAME} -dsi'" +} + +unset name +while getopts ":1bcdghirsu" opt ; do + case ${opt} in + 1 ) + export CMAKE_BUILD_PARALLEL_LEVEL=1 + ;; + b ) + BUILD_DEBUG="1" + ;; + c ) + CLEAN_BUILD=1 + ;; + d ) + BUILD_DEPS="1" + ;; + h ) usage + exit 0 + ;; + i ) + BUILD_IMAGE="1" + ;; + r ) + SKIP_RAM_CHECK="1" + ;; + s ) + BUILD_ORCA="1" + ;; + u ) + UPDATE_LIB="1" + ;; + esac +done + +if [ ${OPTIND} -eq 1 ] ; then + usage + exit 0 +fi + +DISTRIBUTION=$(awk -F= '/^ID=/ {print $2}' /etc/os-release) +# treat ubuntu as debian +if [ "${DISTRIBUTION}" == "ubuntu" ] || [ "${DISTRIBUTION}" == "linuxmint" ] ; then + DISTRIBUTION="debian" +fi + +if [ ! -f ./linux.d/${DISTRIBUTION} ] ; then + echo "Your distribution \"${DISTRIBUTION}\" is not supported by system-dependency scripts in ./linux.d/" + echo "Please resolve dependencies manually and contribute a script for your distribution to upstream." + exit 1 +else + echo "resolving sysetem dependeinces for distribution \"${DISTRIBUTION}\" ..." + source ./linux.d/${DISTRIBUTION} +fi + +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 1 +fi + +echo "Changing date in version..." +{ + # change date in version + sed --in-place "s/+UNKNOWN/_$(date '+%F')/" version.inc +} +echo "done" + + +if ! [[ -n "${SKIP_RAM_CHECK}" ]] ; then + check_available_memory_and_disk +fi + +if [[ -n "${BUILD_DEPS}" ]] ; then + echo "Configuring dependencies..." + BUILD_ARGS="-DDEP_WX_GTK3=ON" + if [[ -n "${CLEAN_BUILD}" ]] + then + rm -fr deps/build + fi + if [ ! -d "deps/build" ] + then + mkdir deps/build + fi + if [[ -n "${BUILD_DEBUG}" ]] ; then + # build deps with debug and release else cmake will not find required sources + if [ ! -d "deps/build/release" ] ; then + mkdir deps/build/release + fi + cmake -S deps -B deps/build/release -G Ninja -DDESTDIR="${SCRIPT_PATH}/deps/build/destdir" -DDEP_DOWNLOAD_DIR="${SCRIPT_PATH}/deps/DL_CACHE" ${BUILD_ARGS} + cmake --build deps/build/release + BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug" + fi + + 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_ORCA}" ]] ; then + echo "Configuring OrcaSlicer..." + if [[ -n "${CLEAN_BUILD}" ]] ; then + rm --force --recursive build + fi + BUILD_ARGS="" + if [[ -n "${FOUND_GTK3_DEV}" ]] ; then + BUILD_ARGS="-DSLIC3R_GTK=3" + fi + 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 + echo -e "cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="${SCRIPT_PATH}/deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}" + cmake -S . -B build -G Ninja \ + -DCMAKE_PREFIX_PATH="${SCRIPT_PATH}/deps/build/destdir/usr/local" \ + -DSLIC3R_STATIC=1 \ + -DORCA_TOOLS=ON \ + ${BUILD_ARGS} + echo "done" + echo "Building OrcaSlicer ..." + cmake --build build --target OrcaSlicer + echo "Building OrcaSlicer_profile_validator .." + cmake --build build --target OrcaSlicer_profile_validator + ./run_gettext.sh + echo "done" +fi + +if [[ -n "${BUILD_IMAGE}" || -n "${BUILD_ORCA}" ]] ; then + pushd build > /dev/null + echo "[9/9] Generating Linux app..." + build_linux_image="./src/build_linux_image.sh" + if [[ -e ${build_linux_image} ]] ; then + extra_script_args="" + if [[ -n "${BUILD_IMAGE}" ]] ; then + extra_script_args="-i" + fi + ${build_linux_image} ${extra_script_args} + + echo "done" + fi + popd > /dev/null # build +fi + +popd > /dev/null # ${SCRIPT_PATH} diff --git a/doc/How-to-build.md b/doc/How-to-build.md index a7c05b0f5d3..817d1f5c481 100644 --- a/doc/How-to-build.md +++ b/doc/How-to-build.md @@ -8,4 +8,4 @@ - run `build_release_macos.sh` - Ubuntu - - run `BuildLinux.sh -udisr` \ No newline at end of file + - run `build_linux.sh -udisr` diff --git a/linux.d/README.md b/linux.d/README.md index 7f05a77cd4e..4cfc11b0459 100644 --- a/linux.d/README.md +++ b/linux.d/README.md @@ -1,3 +1,3 @@ Files in this directory are named for the **exact** output of `awk -F= '/^ID=/ {print $2}' /etc/os-release` for their respective distribution. -When `BuildLinux.sh` is executed, the respective file for the distribution will be sourced so the distribution specific instructions/logic are used. +When `build_linux.sh` is executed, the respective file for the distribution will be sourced so the distribution specific instructions/logic are used. diff --git a/linux.d/debian b/linux.d/debian index 1c299cba312..508a56c5f8d 100644 --- a/linux.d/debian +++ b/linux.d/debian @@ -39,7 +39,7 @@ then fi # check which version of libwebkit2gtk is available - if [ "$(apt show --quiet libwebkit2gtk-4.0-dev)" != "" ] + if [ "$(apt show --quiet libwebkit2gtk-4.0-dev 2>/dev/null)" != "" ] then REQUIRED_DEV_PACKAGES+=(libwebkit2gtk-4.0-dev) else diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8133c2b06a3..a4b0992a3e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -132,7 +132,7 @@ if (NOT WIN32 AND NOT APPLE) # Binary name on unix like systems (Linux, Unix) set_target_properties(OrcaSlicer PROPERTIES OUTPUT_NAME "orca-slicer") set(SLIC3R_APP_CMD "orca-slicer") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/unix/BuildLinuxImage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/BuildLinuxImage.sh @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/unix/build_linux_image.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_linux_image.sh USE_SOURCE_PERMISSIONS @ONLY) endif () target_link_libraries(OrcaSlicer libslic3r cereal::cereal) diff --git a/src/platform/unix/BuildLinuxImage.sh.in b/src/platform/unix/build_linux_image.sh.in old mode 100644 new mode 100755 similarity index 93% rename from src/platform/unix/BuildLinuxImage.sh.in rename to src/platform/unix/build_linux_image.sh.in index 77ab1431a71..738f6528eb2 --- a/src/platform/unix/BuildLinuxImage.sh.in +++ b/src/platform/unix/build_linux_image.sh.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash export ROOT=$(echo $ROOT | grep . || pwd) export NCORES=`nproc --all` @@ -8,7 +8,7 @@ while getopts ":ih" opt; do i ) export BUILD_IMAGE="1" ;; - h ) echo "Usage: ./BuildLinuxImage.sh [-i]" + h ) echo "Usage: ./build_linux_image.sh [-i]" echo " -i: Generate Appimage (optional)" exit 0 ;; @@ -67,9 +67,9 @@ EOF chmod ug+x @SLIC3R_APP_CMD@ cp -f @SLIC3R_APP_CMD@ package/@SLIC3R_APP_CMD@ - pushd package + pushd package > /dev/null tar -cvf ../@SLIC3R_APP_KEY@.tar . &>/dev/null - popd + popd > /dev/null #} &> $ROOT/Build.log # Capture all command output echo "done" @@ -77,10 +77,10 @@ if [[ -n "$BUILD_IMAGE" ]] then echo -n "Creating Appimage for distribution..." #{ - pushd package + pushd package > /dev/null chmod +x ../build_appimage.sh ../build_appimage.sh - popd + popd > /dev/null mv package/"@SLIC3R_APP_KEY@_Linux_V@SoftFever_VERSION@.AppImage" "@SLIC3R_APP_KEY@_Linux_V@SoftFever_VERSION@.AppImage" #} &> $ROOT/Build.log # Capture all command output echo "done" From 42be6bf057395bd59992cff77bc27db1c9ad0d5d Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Thu, 27 Feb 2025 20:58:23 +0100 Subject: [PATCH 2/3] enables ANSI-colored output for GNU or Clang --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4016c8c4eca..97fa50a50e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,17 @@ cmake_minimum_required(VERSION 3.13) +option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE) +if (${FORCE_COLORED_OUTPUT}) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + add_compile_options (-fdiagnostics-color=always) + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_compile_options (-fcolor-diagnostics) + endif () +endif () + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always") + if (APPLE) # if CMAKE_OSX_DEPLOYMENT_TARGET is not set, set it to 11.3 if (NOT CMAKE_OSX_DEPLOYMENT_TARGET) From 39b79f949f21156670cf699ba05fa323be920ba5 Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Thu, 27 Feb 2025 21:05:03 +0100 Subject: [PATCH 3/3] build_linux.sh: adds -p flag to disable PCH for boosting ccache hit rate --- build_linux.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/build_linux.sh b/build_linux.sh index 179faf09abf..99510612830 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -35,6 +35,7 @@ function usage() { echo " -d: download and build dependencies in ./deps/ (build prerequisite)" echo " -h: prints this help text" echo " -i: build the Orca Slicer AppImage (optional)" + echo " -p: boost ccache hit rate by disabling precompiled headers (default: ON)" echo " -r: skip RAM and disk checks (low RAM compiling)" echo " -s: build the Orca Slicer (optional)" echo " -u: install system dependencies (asks for sudo password; build prerequisite)" @@ -42,8 +43,10 @@ function usage() { echo " and then './${SCRIPT_NAME} -dsi'" } +SLIC3R_PRECOMPILED_HEADERS="ON" + unset name -while getopts ":1bcdghirsu" opt ; do +while getopts ":1bcdghiprsu" opt ; do case ${opt} in 1 ) export CMAKE_BUILD_PARALLEL_LEVEL=1 @@ -63,9 +66,12 @@ while getopts ":1bcdghirsu" opt ; do i ) BUILD_IMAGE="1" ;; + p ) + SLIC3R_PRECOMPILED_HEADERS="OFF" + ;; r ) SKIP_RAM_CHECK="1" - ;; + ;; s ) BUILD_ORCA="1" ;; @@ -91,7 +97,7 @@ if [ ! -f ./linux.d/${DISTRIBUTION} ] ; then echo "Please resolve dependencies manually and contribute a script for your distribution to upstream." exit 1 else - echo "resolving sysetem dependeinces for distribution \"${DISTRIBUTION}\" ..." + echo "resolving system dependencies for distribution \"${DISTRIBUTION}\" ..." source ./linux.d/${DISTRIBUTION} fi @@ -130,7 +136,7 @@ if [[ -n "${BUILD_DEPS}" ]] ; then if [ ! -d "deps/build/release" ] ; then mkdir deps/build/release fi - cmake -S deps -B deps/build/release -G Ninja -DDESTDIR="${SCRIPT_PATH}/deps/build/destdir" -DDEP_DOWNLOAD_DIR="${SCRIPT_PATH}/deps/DL_CACHE" ${BUILD_ARGS} + cmake -S deps -B deps/build/release -DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} -G Ninja -DDESTDIR="${SCRIPT_PATH}/deps/build/destdir" -DDEP_DOWNLOAD_DIR="${SCRIPT_PATH}/deps/DL_CACHE" ${BUILD_ARGS} cmake --build deps/build/release BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug" fi @@ -154,8 +160,9 @@ if [[ -n "${BUILD_ORCA}" ]] ; 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="${SCRIPT_PATH}/deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}" + echo -e "cmake -S . -B build -G Ninja -DCMAKE_COLOR_DIAGNOSTICS=ON -DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} -DCMAKE_PREFIX_PATH="${SCRIPT_PATH}/deps/build/destdir/usr/local" -DSLIC3R_STATIC=1 ${BUILD_ARGS}" cmake -S . -B build -G Ninja \ + -DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} \ -DCMAKE_PREFIX_PATH="${SCRIPT_PATH}/deps/build/destdir/usr/local" \ -DSLIC3R_STATIC=1 \ -DORCA_TOOLS=ON \