Files
OrcaSlicer/build_linux.sh

587 lines
18 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
2026-03-19 23:17:03 +08:00
SECONDS=0
SCRIPT_NAME=$(basename "$0")
SCRIPT_PATH=$(dirname "$(readlink -f "${0}")")
pushd "${SCRIPT_PATH}" > /dev/null
function usage() {
echo "Usage: ./${SCRIPT_NAME} [-1][-b][-c][-d][-D][-e][-F][-g][-h][-i][-j N][-p][-r][-s][-t][-u][-l][-L]"
echo " -1: limit builds to one core (where possible)"
echo " -j N: limit builds to N cores (where possible)"
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
echo " -b: build in Debug mode"
echo " -c: force a clean build"
echo " -C: enable ANSI-colored compile output (GNU/Clang only)"
echo " -d: download and build dependencies in ./deps/ (build prerequisite)"
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
echo " -D: dry run"
echo " -e: build in RelWithDebInfo mode"
echo " -F: rebuild the cached Docker/Podman runner image from scratch when used with -g"
echo " -g: run the requested build steps inside a Docker/Podman Ubuntu 24.04 container similar to the GitHub Actions Linux runner"
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 " -t: build tests (optional), requires -s flag"
echo " -u: install system dependencies (asks for sudo password; build prerequisite)"
2025-07-04 22:59:27 +08:00
echo " -l: use Clang instead of GCC (default: GCC)"
echo " -L: use ld.lld as linker (if available)"
echo "For a first use, you want to './${SCRIPT_NAME} -u'"
echo " and then './${SCRIPT_NAME} -dsi'"
echo "For a GitHub Actions-like Linux build locally, use './${SCRIPT_NAME} -g -istrlL'"
echo "Use './${SCRIPT_NAME} -gF -istrlL' to rebuild the cached runner image first."
echo "Set ORCA_CONTAINER_CLI, ORCA_DOCKER_IMAGE, ORCA_DOCKER_BASE_IMAGE, or ORCA_DOCKER_CMAKE_VERSION to override the container runtime, cached image tag, base image, or CMake version."
}
SLIC3R_PRECOMPILED_HEADERS="ON"
unset name
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
BUILD_DIR=build
BUILD_CONFIG=Release
FORWARDED_ARGS=()
while getopts ":1j:bcCdDeFghiprstulL" opt ; do
case ${opt} in
1 )
export CMAKE_BUILD_PARALLEL_LEVEL=1
FORWARDED_ARGS+=("-1")
;;
j )
export CMAKE_BUILD_PARALLEL_LEVEL=$OPTARG
FORWARDED_ARGS+=("-j" "$OPTARG")
;;
b )
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
BUILD_DIR=build-dbg
BUILD_CONFIG=Debug
FORWARDED_ARGS+=("-b")
;;
c )
CLEAN_BUILD=1
FORWARDED_ARGS+=("-c")
;;
C )
COLORED_OUTPUT="-DCOLORED_OUTPUT=ON"
FORWARDED_ARGS+=("-C")
;;
d )
BUILD_DEPS="1"
FORWARDED_ARGS+=("-d")
;;
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
D )
DRY_RUN="1"
FORWARDED_ARGS+=("-D")
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
;;
e )
BUILD_DIR=build-dbginfo
BUILD_CONFIG=RelWithDebInfo
FORWARDED_ARGS+=("-e")
;;
F )
CLEAN_DOCKER_IMAGE="1"
;;
g )
USE_DOCKER="1"
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
;;
h ) usage
exit 1
;;
i )
BUILD_IMAGE="1"
FORWARDED_ARGS+=("-i")
;;
p )
SLIC3R_PRECOMPILED_HEADERS="OFF"
FORWARDED_ARGS+=("-p")
;;
r )
SKIP_RAM_CHECK="1"
FORWARDED_ARGS+=("-r")
;;
s )
BUILD_ORCA="1"
FORWARDED_ARGS+=("-s")
;;
t )
BUILD_TESTS="1"
FORWARDED_ARGS+=("-t")
;;
u )
export UPDATE_LIB="1"
FORWARDED_ARGS+=("-u")
;;
2025-07-04 22:59:27 +08:00
l )
USE_CLANG="1"
FORWARDED_ARGS+=("-l")
2025-07-04 22:59:27 +08:00
;;
L )
USE_LLD="1"
FORWARDED_ARGS+=("-L")
;;
* )
echo "Unknown argument '${opt}', aborting."
exit 1
;;
esac
done
if [ ${OPTIND} -eq 1 ] ; then
usage
exit 1
fi
if [[ -n "${CLEAN_DOCKER_IMAGE}" ]] && [[ -z "${USE_DOCKER}" ]] ; then
echo "Error: -F requires -g."
exit 1
fi
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 (system has only ${FREE_MEM_GB}G available)"
echo && free --human && 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; }') (system has only $(echo "${FREE_DISK_KB}" | awk '{ printf "%.1fG\n", $1/1024/1024; }') disk free)"
echo && df --human-readable . && echo
echo "Invoke with -r to skip ram and disk checks."
exit 1
fi
}
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
function print_and_run() {
cmd=()
# Remove empty arguments, leading and trailing spaces
for item in "$@" ; do
if [[ -n $item ]]; then
cmd+=( "$(echo "${item}" | xargs)" )
fi
done
echo "${cmd[@]}"
if [[ -z "${DRY_RUN}" ]] ; then
"${cmd[@]}"
fi
}
function resolve_container_cli() {
if [[ -n "${ORCA_CONTAINER_CLI}" ]] ; then
if ! command -v "${ORCA_CONTAINER_CLI}" >/dev/null 2>&1 ; then
echo "Error: container runtime '${ORCA_CONTAINER_CLI}' was not found." >&2
exit 1
fi
echo "${ORCA_CONTAINER_CLI}"
return
fi
if command -v docker >/dev/null 2>&1 ; then
echo "docker"
return
fi
if command -v podman >/dev/null 2>&1 ; then
echo "podman"
return
fi
echo "Error: neither docker nor podman is available. Install one of them or set ORCA_CONTAINER_CLI." >&2
exit 1
}
function get_docker_runner_image() {
local base_image
local docker_cmake_version
local recipe_hash
local sanitized_base_image
local sanitized_cmake_version
if [[ -n "${ORCA_DOCKER_IMAGE}" ]] ; then
echo "${ORCA_DOCKER_IMAGE}"
return
fi
base_image="${ORCA_DOCKER_BASE_IMAGE:-ubuntu:24.04}"
docker_cmake_version="${ORCA_DOCKER_CMAKE_VERSION-4.3.0}"
recipe_hash=$(find "${SCRIPT_PATH}/build_linux.sh" "${SCRIPT_PATH}/scripts/linux.d" -type f -print0 | sort -z | xargs -0 cat | sha256sum | cut -c1-12)
sanitized_base_image=$(echo "${base_image}" | tr '/:@' '---' | tr -cs 'A-Za-z0-9_.-' '-')
sanitized_cmake_version=$(echo "${docker_cmake_version:-system}" | tr -cs 'A-Za-z0-9_.-' '-')
echo "orcaslicer-linux-builder:${sanitized_base_image}-cmake-${sanitized_cmake_version}-${recipe_hash}"
}
function docker_runner_dockerfile() {
cat <<'EOF'
ARG BASE_IMAGE=ubuntu:24.04
FROM ${BASE_IMAGE}
ARG CMAKE_VERSION=4.3.0
ENV DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-c"]
RUN apt-get update && apt-get install -y sudo ca-certificates curl tar
COPY build_linux.sh /tmp/orcaslicer/build_linux.sh
COPY scripts/linux.d /tmp/orcaslicer/scripts/linux.d
WORKDIR /tmp/orcaslicer
RUN chmod +x ./build_linux.sh
RUN ./build_linux.sh -ur
RUN if [[ -n "${CMAKE_VERSION}" ]] ; then \
case "$(uname -m)" in \
x86_64|amd64) cmake_arch="x86_64" ;; \
aarch64|arm64) cmake_arch="aarch64" ;; \
*) cmake_arch="" ;; \
esac ; \
if [[ -n "${cmake_arch}" ]] ; then \
cmake_root="/opt/cmake-${CMAKE_VERSION}-linux-${cmake_arch}" ; \
if ! curl -fsSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${cmake_arch}.tar.gz" | tar -xz -C /opt ; then \
echo "Warning: failed to install CMake ${CMAKE_VERSION}; falling back to the distro cmake package." ; \
elif [[ -d "${cmake_root}" ]] ; then \
ln -sf "${cmake_root}/bin/"* /usr/local/bin/ ; \
fi ; \
else \
echo "Skipping GitHub Actions CMake install for unsupported architecture $(uname -m)." ; \
fi ; \
fi
RUN rm -rf /var/lib/apt/lists/* /tmp/orcaslicer
EOF
}
function ensure_docker_runner_image() {
local container_cli
local base_image
local runner_image
local docker_cmake_version
local image_exists="0"
local force_rebuild="0"
local -a build_cmd
container_cli="$1"
runner_image="$2"
base_image="${ORCA_DOCKER_BASE_IMAGE:-ubuntu:24.04}"
docker_cmake_version="${ORCA_DOCKER_CMAKE_VERSION-4.3.0}"
if "${container_cli}" image inspect "${runner_image}" >/dev/null 2>&1 ; then
image_exists="1"
fi
if [[ -n "${CLEAN_DOCKER_IMAGE}" ]] ; then
force_rebuild="1"
if [[ "${image_exists}" == "1" ]] ; then
echo "Removing cached container image ${runner_image} ..."
if [[ -z "${DRY_RUN}" ]] ; then
"${container_cli}" image rm -f "${runner_image}" >/dev/null
else
printf '%q ' "${container_cli}" image rm -f "${runner_image}"
echo
fi
image_exists="0"
fi
fi
if [[ "${image_exists}" == "1" ]] ; then
echo "Using cached container image ${runner_image}"
return
fi
build_cmd=(
"${container_cli}" build --pull
-t "${runner_image}"
--build-arg "BASE_IMAGE=${base_image}"
--build-arg "CMAKE_VERSION=${docker_cmake_version}"
)
if [[ "${force_rebuild}" == "1" ]] ; then
build_cmd+=(--no-cache)
fi
build_cmd+=(-f - "${SCRIPT_PATH}")
printf '%q ' "${build_cmd[@]}"
echo
if [[ -n "${DRY_RUN}" ]] ; then
return
fi
docker_runner_dockerfile | "${build_cmd[@]}"
}
function run_in_docker() {
local container_cli
local runner_image
local container_workspace
local host_uid
local host_gid
local host_user
local -a build_args
local -a container_env
container_cli=$(resolve_container_cli)
runner_image=$(get_docker_runner_image)
host_uid=$(id -u)
host_gid=$(id -g)
host_user="${USER:-orca}"
container_workspace="/__w/OrcaSlicer/OrcaSlicer"
build_args=()
for item in "${FORWARDED_ARGS[@]}" ; do
if [[ "${item}" == "-u" ]] || [[ "${item}" == "-D" ]] ; then
continue
fi
build_args+=("${item}")
done
container_env=(
-e "CI=true"
-e "GITHUB_ACTIONS=true"
-e "GITHUB_WORKSPACE=${container_workspace}"
-e "RUNNER_OS=Linux"
-e "RUNNER_TEMP=/tmp"
-e "HOST_UID=${host_uid}"
-e "HOST_GID=${host_gid}"
-e "HOST_USER=${host_user}"
)
if [[ -n "${CMAKE_BUILD_PARALLEL_LEVEL}" ]] ; then
container_env+=( -e "CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL}" )
fi
if [[ -n "${ORCA_UPDATER_SIG_KEY}" ]] ; then
container_env+=( -e "ORCA_UPDATER_SIG_KEY=${ORCA_UPDATER_SIG_KEY}" )
fi
ensure_docker_runner_image "${container_cli}" "${runner_image}"
printf '%q ' "${container_cli}" run --rm -i \
-v "${SCRIPT_PATH}:${container_workspace}" \
-w "${container_workspace}" \
"${container_env[@]}" \
"${runner_image}" \
bash -s -- "${build_args[@]}"
echo
if [[ -n "${DRY_RUN}" ]] ; then
return
fi
"${container_cli}" run --rm -i \
-v "${SCRIPT_PATH}:${container_workspace}" \
-w "${container_workspace}" \
"${container_env[@]}" \
"${runner_image}" \
bash -s -- "${build_args[@]}" <<'EOF'
set -e
function create_builder_user() {
if [[ "${HOST_UID}" == "0" ]] ; then
HOST_USER=root
return
fi
if getent group "${HOST_GID}" >/dev/null 2>&1 ; then
HOST_GROUP=$(getent group "${HOST_GID}" | cut -d: -f1)
else
HOST_GROUP="orca-builder"
if getent group "${HOST_GROUP}" >/dev/null 2>&1 ; then
HOST_GROUP="orca-builder-${HOST_GID}"
fi
groupadd -g "${HOST_GID}" "${HOST_GROUP}"
fi
if getent passwd "${HOST_UID}" >/dev/null 2>&1 ; then
HOST_USER=$(getent passwd "${HOST_UID}" | cut -d: -f1)
usermod -g "${HOST_GROUP}" "${HOST_USER}"
elif id -u "${HOST_USER}" >/dev/null 2>&1 ; then
usermod -u "${HOST_UID}" -g "${HOST_GROUP}" "${HOST_USER}"
else
useradd -m -u "${HOST_UID}" -g "${HOST_GROUP}" -s /bin/bash "${HOST_USER}"
fi
echo "${HOST_USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/orcaslicer-builder
chmod 0440 /etc/sudoers.d/orcaslicer-builder
}
create_builder_user
mkdir -p "${GITHUB_WORKSPACE}/deps/build/destdir"
chown -R "${HOST_UID}:${HOST_GID}" "${GITHUB_WORKSPACE}/deps/build"
if [[ -d "${GITHUB_WORKSPACE}/build" ]] ; then
chown -R "${HOST_UID}:${HOST_GID}" "${GITHUB_WORKSPACE}/build"
fi
if [[ -d "${GITHUB_WORKSPACE}/build-dbg" ]] ; then
chown -R "${HOST_UID}:${HOST_GID}" "${GITHUB_WORKSPACE}/build-dbg"
fi
if [[ -d "${GITHUB_WORKSPACE}/build-dbginfo" ]] ; then
chown -R "${HOST_UID}:${HOST_GID}" "${GITHUB_WORKSPACE}/build-dbginfo"
fi
sudo -H -u "${HOST_USER}" env \
CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL-}" \
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" \
ORCA_UPDATER_SIG_KEY="${ORCA_UPDATER_SIG_KEY-}" \
bash -c '
set -e
cd "${GITHUB_WORKSPACE}"
if [[ "$#" -gt 0 ]] ; then
./build_linux.sh "$@"
else
echo "No build steps were requested after container setup."
fi
' bash "$@"
EOF
}
if [[ -n "${USE_DOCKER}" ]] ; then
run_in_docker
popd > /dev/null # ${SCRIPT_PATH}
exit 0
fi
# cmake 4.x compatibility workaround
export CMAKE_POLICY_VERSION_MINIMUM=3.5
DISTRIBUTION=$(awk -F= '/^ID=/ {print $2}' /etc/os-release | tr -d '"')
DISTRIBUTION_LIKE=$(awk -F= '/^ID_LIKE=/ {print $2}' /etc/os-release | tr -d '"')
# Check for direct distribution match to Ubuntu/Debian
if [ "${DISTRIBUTION}" == "ubuntu" ] || [ "${DISTRIBUTION}" == "linuxmint" ] ; then
DISTRIBUTION="debian"
# Check if distribution is Debian/Ubuntu-like based on ID_LIKE
elif [[ "${DISTRIBUTION_LIKE}" == *"debian"* ]] || [[ "${DISTRIBUTION_LIKE}" == *"ubuntu"* ]] ; then
DISTRIBUTION="debian"
elif [[ "${DISTRIBUTION_LIKE}" == *"arch"* ]] ; then
DISTRIBUTION="arch"
elif [[ "${DISTRIBUTION_LIKE}" == *"suse"* ]] ; then
DISTRIBUTION="suse"
fi
if [ ! -f "./scripts/linux.d/${DISTRIBUTION}" ] ; then
echo "Your distribution \"${DISTRIBUTION}\" is not supported by system-dependency scripts in ./scripts/linux.d/"
echo "Please resolve dependencies manually and contribute a script for your distribution to upstream."
exit 1
else
echo "resolving system dependencies for distribution \"${DISTRIBUTION}\" ..."
# shellcheck source=/dev/null
source "./scripts/linux.d/${DISTRIBUTION}"
fi
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
echo "FOUND_GTK3_DEV=${FOUND_GTK3_DEV}"
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 [[ -z "${SKIP_RAM_CHECK}" ]] ; then
check_available_memory_and_disk
fi
export CMAKE_C_CXX_COMPILER_CLANG=()
2025-07-04 22:59:27 +08:00
if [[ -n "${USE_CLANG}" ]] ; then
export CMAKE_C_CXX_COMPILER_CLANG=(-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++)
2025-07-04 22:59:27 +08:00
fi
# Configure use of ld.lld as the linker when requested
export CMAKE_LLD_LINKER_ARGS=()
if [[ -n "${USE_LLD}" ]] ; then
if command -v ld.lld >/dev/null 2>&1 ; then
LLD_BIN=$(command -v ld.lld)
export CMAKE_LLD_LINKER_ARGS=(-DCMAKE_LINKER="${LLD_BIN}" -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld)
else
echo "Error: ld.lld not found. Please install the 'lld' package (e.g., sudo apt install lld) or omit -L."
exit 1
fi
fi
Introducing Orca Cloud: https://cloud.orcaslicer.com (#13414) * Add OrcaCloud sync platform and preset bundle sharing system Introduce OrcaCloud, a cloud sync platform for user presets, alongside a preset bundle system that enables sharing printer/filament/process profiles as local exportable bundles or subscribed cloud bundles. OrcaCloud platform: - Auth to Orca Cloud - Encrypted token storage (file-based or system keychain) - User preset sync with - Profile migration from default/bambu folders on first login - Homepage integration with entrance to cloud.orcaslicer.com Preset bundles: - Local bundle import/export with bundle_structure.json metadata - Subscribed cloud bundles with version-based update checking - Thread-safe concurrent bundle access with read-write mutex - Canonical bundle preset naming (_local/<id>/... and _subscribed/<id>/...) - Bundle presets are read-only; grouped under subheaders in combo boxes - PresetBundleDialog with auto-sync toggle, refresh, update notifications - Hyperlinked bundle names to cloud bundle pages Co-authored-by: Sabriel Koh <sabrielkcr@gmail.com> Co-authored-by: Derrick <derrick992110@gmail.com> Co-authored-by: Mykola Nahirnyi <mnahirnyi@amcbridge.com> Co-authored-by: Ian Chua <iancrb00@gmail.com> Co-authored-by: Draginraptor <draginraptor@gmail.com> Co-authored-by: ExPikaPaka <112851715+ExPikaPaka@users.noreply.github.com> Co-authored-by: Ian Bassi <ian.bassi@outlook.com> Co-authored-by: Ocraftyone <Ocraftyone@users.noreply.github.com> Co-authored-by: yw4z <ywsyildiz@gmail.com> Co-authored-by: peterm-m <101202951+peterm-m@users.noreply.github.com> * Fixed an issue on Windows it failed to login Orca Cloud with Google account
2026-05-01 18:01:29 +08:00
# Auto-detect ccache for faster rebuilds
export CMAKE_CCACHE_ARGS=()
if command -v ccache >/dev/null 2>&1 ; then
echo "ccache found at $(command -v ccache), enabling compiler caching..."
export CMAKE_CCACHE_ARGS=(-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
else
echo "Note: ccache not found. Install ccache for faster rebuilds."
fi
if [[ -n "${BUILD_DEPS}" ]] ; then
echo "Configuring dependencies..."
read -r -a BUILD_ARGS <<< "${DEPS_EXTRA_BUILD_ARGS}"
if [[ -n "${CLEAN_BUILD}" ]]
then
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
print_and_run rm -fr deps/$BUILD_DIR
fi
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
mkdir -p deps/$BUILD_DIR
if [[ $BUILD_CONFIG != Release ]] ; then
BUILD_ARGS+=(-DCMAKE_BUILD_TYPE="${BUILD_CONFIG}")
fi
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
print_and_run cmake -S deps -B deps/$BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" -G Ninja "${COLORED_OUTPUT}" "${BUILD_ARGS[@]}"
print_and_run cmake --build deps/$BUILD_DIR -j1
fi
Fix tests (#10906) * Get libslic3r tests closer to passing I can't get geometry tests to do anything useful. I've added extra output, but it hasn't helped me figure out why they don't work yet. That's also probably the last broken 3mf test doesn't work. The config tests were mostly broken because of config name changes. The placeholder_parser tests have some things that may-or-may-not still apply to Orca. * Vendor a 3.x version of Catch2 Everything is surely broken at this point. * Allow building tests separately from Orca with build_linux.sh * Remove unnecessary log message screwing up ctest Same solution as Prusaslicer * Make 2 TriangleMesh methods const Since they can be. * Move method comment to the header where it belongsc * Add indirectly-included header directly Transform3d IIRC * libslic3r tests converted to Catch2 v3 Still has 3 failing tests, but builds and runs. * Disable 2D convex hull test and comment what I've learned Not sure the best way to solve this yet. * Add diff compare method for DynamicConfig Help the unit test report errors better. * Perl no longer used, remove comment line * Clang-format Config.?pp So difficult to work with ATM * Remove cpp17 unit tests Who gives a shit * Don't need explicit "example" test We have lots of tests to serve as examples. * Leave breadcrumb to enable sla_print tests * Fix serialization of DynamicConfig Add comments to test, because these code paths might not be even used anymore. * Update run_unit_tests to run all the tests By the time I'm done with the PR all tests will either excluded by default or passing, so just do all. * Update how-to-test now that build_linux.sh builds tests separately * Update cmake regenerate instructions Read this online; hopefully works. * Enable slic3rutils test with Catch2 v3 * Port libnest2d and fff_print to Catch2 v3 They build. Many failing. * Add slightly more info to Objects not fit on bed exception * Disable failing fff_print tests from running They're mostly failing for "objects don't fit on bed" for an infinite-sized bed. Given infinite bed is probably only used in tests, it probably was incidentally broken long ago. * Must checkout tests directory in GH Actions So we get the test data * Missed a failing fff_print test * Disable (most/all) broken libnest2d tests Trying all, not checking yet though * Fix Polygon convex/concave detection tests Document the implementation too. Reorganize the tests to be cleaner. * Update the test script to run tests in parallel * Get sla_print tests to build Probably not passing * Don't cause full project rebuild when updating test CMakeLists.txts * Revert "Clang-format Config.?pp" This reverts commit 771e4c0ad2fdbaa26a8fee77030650afacdc5083. --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-12-08 06:42:11 -08:00
if [[ -n "${BUILD_ORCA}" ]] || [[ -n "${BUILD_TESTS}" ]] ; then
echo "Configuring OrcaSlicer..."
if [[ -n "${CLEAN_BUILD}" ]] ; then
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
print_and_run rm -fr $BUILD_DIR
fi
read -r -a BUILD_ARGS <<< "${ORCA_EXTRA_BUILD_ARGS}"
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
if [[ $BUILD_CONFIG != Release ]] ; then
BUILD_ARGS+=(-DCMAKE_BUILD_TYPE="${BUILD_CONFIG}")
fi
if [[ -n "${BUILD_TESTS}" ]] ; then
BUILD_ARGS+=(-DBUILD_TESTS=ON)
fi
if [[ -n "${ORCA_UPDATER_SIG_KEY}" ]] ; then
BUILD_ARGS+=(-DORCA_UPDATER_SIG_KEY="${ORCA_UPDATER_SIG_KEY}")
fi
Introducing Orca Cloud: https://cloud.orcaslicer.com (#13414) * Add OrcaCloud sync platform and preset bundle sharing system Introduce OrcaCloud, a cloud sync platform for user presets, alongside a preset bundle system that enables sharing printer/filament/process profiles as local exportable bundles or subscribed cloud bundles. OrcaCloud platform: - Auth to Orca Cloud - Encrypted token storage (file-based or system keychain) - User preset sync with - Profile migration from default/bambu folders on first login - Homepage integration with entrance to cloud.orcaslicer.com Preset bundles: - Local bundle import/export with bundle_structure.json metadata - Subscribed cloud bundles with version-based update checking - Thread-safe concurrent bundle access with read-write mutex - Canonical bundle preset naming (_local/<id>/... and _subscribed/<id>/...) - Bundle presets are read-only; grouped under subheaders in combo boxes - PresetBundleDialog with auto-sync toggle, refresh, update notifications - Hyperlinked bundle names to cloud bundle pages Co-authored-by: Sabriel Koh <sabrielkcr@gmail.com> Co-authored-by: Derrick <derrick992110@gmail.com> Co-authored-by: Mykola Nahirnyi <mnahirnyi@amcbridge.com> Co-authored-by: Ian Chua <iancrb00@gmail.com> Co-authored-by: Draginraptor <draginraptor@gmail.com> Co-authored-by: ExPikaPaka <112851715+ExPikaPaka@users.noreply.github.com> Co-authored-by: Ian Bassi <ian.bassi@outlook.com> Co-authored-by: Ocraftyone <Ocraftyone@users.noreply.github.com> Co-authored-by: yw4z <ywsyildiz@gmail.com> Co-authored-by: peterm-m <101202951+peterm-m@users.noreply.github.com> * Fixed an issue on Windows it failed to login Orca Cloud with Google account
2026-05-01 18:01:29 +08:00
print_and_run cmake -S . -B $BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" "${CMAKE_CCACHE_ARGS[@]}" -G "Ninja Multi-Config" \
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
-DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} \
-DORCA_TOOLS=ON \
"${COLORED_OUTPUT}" \
"${BUILD_ARGS[@]}"
echo "done"
Fix tests (#10906) * Get libslic3r tests closer to passing I can't get geometry tests to do anything useful. I've added extra output, but it hasn't helped me figure out why they don't work yet. That's also probably the last broken 3mf test doesn't work. The config tests were mostly broken because of config name changes. The placeholder_parser tests have some things that may-or-may-not still apply to Orca. * Vendor a 3.x version of Catch2 Everything is surely broken at this point. * Allow building tests separately from Orca with build_linux.sh * Remove unnecessary log message screwing up ctest Same solution as Prusaslicer * Make 2 TriangleMesh methods const Since they can be. * Move method comment to the header where it belongsc * Add indirectly-included header directly Transform3d IIRC * libslic3r tests converted to Catch2 v3 Still has 3 failing tests, but builds and runs. * Disable 2D convex hull test and comment what I've learned Not sure the best way to solve this yet. * Add diff compare method for DynamicConfig Help the unit test report errors better. * Perl no longer used, remove comment line * Clang-format Config.?pp So difficult to work with ATM * Remove cpp17 unit tests Who gives a shit * Don't need explicit "example" test We have lots of tests to serve as examples. * Leave breadcrumb to enable sla_print tests * Fix serialization of DynamicConfig Add comments to test, because these code paths might not be even used anymore. * Update run_unit_tests to run all the tests By the time I'm done with the PR all tests will either excluded by default or passing, so just do all. * Update how-to-test now that build_linux.sh builds tests separately * Update cmake regenerate instructions Read this online; hopefully works. * Enable slic3rutils test with Catch2 v3 * Port libnest2d and fff_print to Catch2 v3 They build. Many failing. * Add slightly more info to Objects not fit on bed exception * Disable failing fff_print tests from running They're mostly failing for "objects don't fit on bed" for an infinite-sized bed. Given infinite bed is probably only used in tests, it probably was incidentally broken long ago. * Must checkout tests directory in GH Actions So we get the test data * Missed a failing fff_print test * Disable (most/all) broken libnest2d tests Trying all, not checking yet though * Fix Polygon convex/concave detection tests Document the implementation too. Reorganize the tests to be cleaner. * Update the test script to run tests in parallel * Get sla_print tests to build Probably not passing * Don't cause full project rebuild when updating test CMakeLists.txts * Revert "Clang-format Config.?pp" This reverts commit 771e4c0ad2fdbaa26a8fee77030650afacdc5083. --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-12-08 06:42:11 -08:00
if [[ -n "${BUILD_ORCA}" ]]; then
echo "Building OrcaSlicer ..."
print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer
echo "Building OrcaSlicer_profile_validator .."
print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator
./scripts/run_gettext.sh
fi
Build and run a test in CI (#10835) * Actually build tests on Linux and allow RelWithDebInfo They weren't being built. Also cleaned up --config flags which enables RelWithDebInfo on Linux, now that Ninja Multi-Config is used, it's quite trivial. * Remove obsolete Slic3r Perl tests The directory doesn't exist, they're already gone. * Add GH job for running unit tests * Move unit test execution to script and upload test results * Don't run scheduled builds on forks * Only deploy from SoftFever/OrcaSlicer Will stop failures on forks * Use artifact instead of cache * Tweak archive and checkout paths Keep getting error: ``` /home/runner/work/_temp/902d0a0a-6d23-4fe0-a643-8b5cc4efd25b.sh: line 1: scripts/run_unit_tests.sh: Permission denied ``` That seems to be because I didn't use actions/checkout, the working directory is never setup correctly? So using checkout to get scripts directory. Unsure if archive will preserve the `build/tests/` prefix; will find out soon. * Use tar to package directory and write results to correct directory Tar preserves filenames and directory structure * Use tar -xvf not -xzf Muscle memory failed me * Add testing wiki page * Save test logs on failure and choose correct directory for junit * Consolidate apt install steps, use for unit tests too, disable non-Linux builds Temporarily disable non-Linux builds to save time while developing this. Cache the apt packages to save some time searching apt and downloading them again (though I realize this is also downloading, but hopefully by something closer and faster). Remove all the redundant packages listed in the workflow and debian distribution lists. * Remove apt install steps from workflow `./build-linux.sh -u` is supposed to install all needed packages, so it should build without needing anything besides that. If I'm wrong this commit will be dropped. * Need composite action checked out locally * Re-enable non-Linux builds now that it's working * Skip a deploy and a notarize in forks They only succeed in the main repo. * Fix multi-build for non-Release builds: share CONFIG * Correct build errors in unit tests Indeterminate method signatures resolved. Updated script to build all the tests. * Fix -g vs -e for RelWithDebInfo * Change CONFIG->BUILD_CONFIG Missed one in prior commits * Reduce wasteful redundant build artifact copies 1. Don't copy the artifacts and leave them; make a hard link first; only make a copy only while creating AppImage. 2. Don't tar up the `package` directory; nothing uses this tar AFAICT * Fix directory name * Change jigsaw auth test URLs to httpbin.org No idea why the basic auth doesn't work, but it doesn't work for `curl` CLI either. This does. * Remove force-build It got reverted at https://github.com/SoftFever/OrcaSlicer/commit/e3f049829bff3ac4de9fd271768948efc150e4c3 for unknown reasons. * Add timeout for unit tests in GitHub Actions workflow (#11146) --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-29 05:56:06 -07:00
if [[ -n "${BUILD_TESTS}" ]] ; then
echo "Building tests ..."
print_and_run cmake --build ${BUILD_DIR} --config "${BUILD_CONFIG}" --target tests/all
fi
echo "done"
fi
if [[ -n "${BUILD_IMAGE}" || -n "${BUILD_ORCA}" ]] ; then
Better CMake Defaults (#10294) * Auto generate CMAKE_PREFIX_PATH/DESTDIR * Auto set CMAKE_INSTALL_PREFIX * Always default SLIC3R_STATIC to on * Only allow one value for CMAKE_OSX_ARCHITECTURES * Set arch for OpenSSL from CMAKE_OSX_ARCHITECTURES * Set CMAKE_INSTALL_RPATH from CMAKE_PREFIX_PATH * Default CMAKE_MACOSX_RPATH and CMAKE_MACOSX_BUNDLE to on * Auto set BBL_RELEASE_TO_PUBLIC based on build config * Default to GTK 3 * Fix linux debug build Update find modules to also look for the debug variant of the libraries * Set DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE * Add a fallback value for Windows SDK if the env variables are not set * Reflect CMake changes in the build scripts * Add missing line * Fix auto setting DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO * Update dep folder name for linux in GH actions * Invert dep-folder-name conditions `''` is considered a falsy value, which was causing the value to always be set to 'OrcaSlicer_dep' * Properly handle finding the debug version of libnoise * Convert FindNLopt.cmake to a config mode wrapper * Use separate build directory for debug builds on Linux * Move find_package for libnoise * Cleanup and improve linux build script - Add dry run - Add build in RelWithDebInfo - Add function to print and run commands * Remove linux destdir deprecation and cleanup * Fix flatpak build * Disable fail fast for flatpak builds * Flatpak improvements - Build wxWidgets using deps cmake - Improve handling of space freeing commands while building deps - Allow cmake to directly download deps - Set needed flags within cmake instead of the build manifest * Print clean build commands * Implement shellcheck recommendations * Cleanup * Fix CMakeLists.txt syntax by replacing empty elseif with else statement --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-25 10:05:09 -04:00
pushd $BUILD_DIR > /dev/null
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 and run a test in CI (#10835) * Actually build tests on Linux and allow RelWithDebInfo They weren't being built. Also cleaned up --config flags which enables RelWithDebInfo on Linux, now that Ninja Multi-Config is used, it's quite trivial. * Remove obsolete Slic3r Perl tests The directory doesn't exist, they're already gone. * Add GH job for running unit tests * Move unit test execution to script and upload test results * Don't run scheduled builds on forks * Only deploy from SoftFever/OrcaSlicer Will stop failures on forks * Use artifact instead of cache * Tweak archive and checkout paths Keep getting error: ``` /home/runner/work/_temp/902d0a0a-6d23-4fe0-a643-8b5cc4efd25b.sh: line 1: scripts/run_unit_tests.sh: Permission denied ``` That seems to be because I didn't use actions/checkout, the working directory is never setup correctly? So using checkout to get scripts directory. Unsure if archive will preserve the `build/tests/` prefix; will find out soon. * Use tar to package directory and write results to correct directory Tar preserves filenames and directory structure * Use tar -xvf not -xzf Muscle memory failed me * Add testing wiki page * Save test logs on failure and choose correct directory for junit * Consolidate apt install steps, use for unit tests too, disable non-Linux builds Temporarily disable non-Linux builds to save time while developing this. Cache the apt packages to save some time searching apt and downloading them again (though I realize this is also downloading, but hopefully by something closer and faster). Remove all the redundant packages listed in the workflow and debian distribution lists. * Remove apt install steps from workflow `./build-linux.sh -u` is supposed to install all needed packages, so it should build without needing anything besides that. If I'm wrong this commit will be dropped. * Need composite action checked out locally * Re-enable non-Linux builds now that it's working * Skip a deploy and a notarize in forks They only succeed in the main repo. * Fix multi-build for non-Release builds: share CONFIG * Correct build errors in unit tests Indeterminate method signatures resolved. Updated script to build all the tests. * Fix -g vs -e for RelWithDebInfo * Change CONFIG->BUILD_CONFIG Missed one in prior commits * Reduce wasteful redundant build artifact copies 1. Don't copy the artifacts and leave them; make a hard link first; only make a copy only while creating AppImage. 2. Don't tar up the `package` directory; nothing uses this tar AFAICT * Fix directory name * Change jigsaw auth test URLs to httpbin.org No idea why the basic auth doesn't work, but it doesn't work for `curl` CLI either. This does. * Remove force-build It got reverted at https://github.com/SoftFever/OrcaSlicer/commit/e3f049829bff3ac4de9fd271768948efc150e4c3 for unknown reasons. * Add timeout for unit tests in GitHub Actions workflow (#11146) --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
2025-10-29 05:56:06 -07:00
print_and_run ${build_linux_image} ${extra_script_args} -R "${BUILD_CONFIG}"
echo "done"
fi
popd > /dev/null # build
fi
2026-03-19 23:17:03 +08:00
elapsed=$SECONDS
printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60))
popd > /dev/null # ${SCRIPT_PATH}