GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — OrcaSlicer/build_linux.sh at main · BlocksTechnology/OrcaSlicer Expand file tree/ Copy pathbuild_linux.shMore file actions executable file ·665 lines (593 loc) · 22.7 KB / Copy pathbuild_linux.shFile metadata and controlsexecutable file ·665 lines (593 loc) · 22.7 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 #!/usr/bin/env bash set -e # Exit immediately if a command exits with a non-zero status. 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][-J N][-p][-r][-s][-t][-u][-l][-L] [-- CMAKE_ARGS...]" echo " -1: limit builds to one core (where possible)" echo " -j N: limit builds to N cores (where possible)" echo " -J N: build up to N dependencies at a time, each still using -j jobs (default: 1)" 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)" 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: disable precompiled headers (on by default): more ccache hits after header changes, slower misses" 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)" echo " -l: use Clang instead of GCC (default: GCC)" echo " -L: use ld.lld as linker (if available)" echo " -- CMAKE_ARGS...: pass everything after '--' to the cmake configure step of the deps (-d) and OrcaSlicer (-s/-t) builds," echo " e.g. -DCMAKE_CXX_FLAGS=\"-O2 -march=native\", -DCMAKE_CXX_COMPILER=g++-14, -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold." echo " They come last on the cmake command line, so they override what -l and -L set." 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." echo "DEPS_EXTRA_BUILD_ARGS and ORCA_EXTRA_BUILD_ARGS add whitespace-separated cmake configure arguments to the deps and OrcaSlicer builds; prefer '--' for arguments that contain spaces." } SLIC3R_PRECOMPILED_HEADERS="ON" DEPS_PARALLEL="" unset name BUILD_DIR=build BUILD_CONFIG=Release FORWARDED_ARGS=() while getopts ":1j:J: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") ;; J ) DEPS_PARALLEL=$OPTARG FORWARDED_ARGS+=("-J" "$OPTARG") ;; b ) 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") ;; D ) DRY_RUN="1" FORWARDED_ARGS+=("-D") ;; e ) BUILD_DIR=build-dbginfo BUILD_CONFIG=RelWithDebInfo FORWARDED_ARGS+=("-e") ;; F ) CLEAN_DOCKER_IMAGE="1" ;; g ) USE_DOCKER="1" ;; 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") ;; l ) USE_CLANG="1" FORWARDED_ARGS+=("-l") ;; L ) USE_LLD="1" FORWARDED_ARGS+=("-L") ;; * ) echo "Unknown argument '${opt}', aborting." exit 1 ;; esac done # getopts stops at '--'; whatever follows is handed to cmake unchanged. if [[ ${OPTIND} -le $# ]] ; then separator_index=$((OPTIND-1)) if [[ "${!separator_index}" != "--" ]] ; then echo "Unexpected argument '${!OPTIND}': cmake arguments must follow '--', aborting." exit 1 fi fi shift $((OPTIND-1)) EXTRA_CMAKE_ARGS=("$@") if [[ ${#EXTRA_CMAKE_ARGS[@]} -gt 0 ]] ; then FORWARDED_ARGS+=("--" "${EXTRA_CMAKE_ARGS[@]}") fi 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 if [[ -n "${DEPS_PARALLEL}" ]] && ! [[ "${DEPS_PARALLEL}" =~ ^[1-9][0-9]*$ ]] ; then echo "Error: -J expects a positive integer." 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 } 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 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=() if [[ -n "${USE_CLANG}" ]] ; then export CMAKE_C_CXX_COMPILER_CLANG=(-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++) 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 export CMAKE_CCACHE_ARGS=() CMAKE_CCACHE=${CMAKE_CCACHE:-} if [ -n "$CMAKE_CCACHE" ]; then echo "Checking ${CMAKE_CCACHE} environment variable for compiler cache program..." CMAKE_CCACHE=$(command -v "${CMAKE_CCACHE}") || { echo "CMAKE_CCACHE environment variable is set to '${CMAKE_CCACHE}' but it was not found in PATH." CMAKE_CCACHE="" } elif command -v sccache >/dev/null 2>&1 ; then CMAKE_CCACHE=$(command -v sccache) elif command -v ccache >/dev/null 2>&1 ; then CMAKE_CCACHE=$(command -v ccache) fi if [ -n "${CMAKE_CCACHE}" ] ; then echo "${CMAKE_CCACHE} found, enabling compiler caching..." export CMAKE_CCACHE_ARGS=(-DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_CCACHE}" -DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CCACHE}") # The same ccache settings as the CI build. Without this sloppiness ccache refuses every # compile that uses the precompiled header, which is most of OrcaSlicer, and skips headers # a checkout has just written. It is added to the sloppiness already configured, and # CCACHE_SLOPPINESS or CCACHE_(NO)DEPEND set in the environment win. if [[ "$(basename "${CMAKE_CCACHE}")" == ccache ]] ; then if [[ -z "${CCACHE_SLOPPINESS+x}" ]] ; then CCACHE_SLOPPINESS=$("${CMAKE_CCACHE}" --get-config sloppiness 2>/dev/null || true) export CCACHE_SLOPPINESS="${CCACHE_SLOPPINESS:+${CCACHE_SLOPPINESS},}pch_defines,time_macros,include_file_mtime,include_file_ctime" fi # Hash the includes the compiler reports instead of preprocessing every miss. if [[ -z "${CCACHE_DEPEND+x}${CCACHE_NODEPEND+x}" ]] ; then export CCACHE_DEPEND=1 fi fi else echo "Note: ccache or sccache are not found. Install either of them 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 print_and_run rm -fr deps/$BUILD_DIR fi mkdir -p deps/$BUILD_DIR if [[ $BUILD_CONFIG != Release ]] ; then BUILD_ARGS+=(-DCMAKE_BUILD_TYPE="${BUILD_CONFIG}") fi print_and_run cmake -S deps -B deps/$BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" "${CMAKE_CCACHE_ARGS[@]}" -G Ninja "${COLORED_OUTPUT}" "${BUILD_ARGS[@]}" "${EXTRA_CMAKE_ARGS[@]}" # The top-level build runs one dependency at a time by default, which keeps the console # output readable and lets that dependency's own build use all of CMAKE_BUILD_PARALLEL_LEVEL. # -J raises the top level instead, and -j still applies in full to every dependency, so the # worst case is -J times -j compile jobs at once. Ninja has no job server to share a pool # across the nested builds, so that ceiling is not enforced anywhere: pick -J to suit the RAM. DEPS_JOBS=1 if [[ -n "${DEPS_PARALLEL}" ]] ; then DEPS_JOBS=${DEPS_PARALLEL} SAVED_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL-} export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:-$(nproc)} echo "Building up to ${DEPS_JOBS} dependencies at a time, ${CMAKE_BUILD_PARALLEL_LEVEL} jobs each: up to $(( DEPS_JOBS * CMAKE_BUILD_PARALLEL_LEVEL )) compile jobs at once." fi print_and_run cmake --build deps/$BUILD_DIR -j"${DEPS_JOBS}" if [[ -n "${DEPS_PARALLEL}" ]] ; then # Give the whole -j back to the OrcaSlicer build below. if [[ -n "${SAVED_PARALLEL_LEVEL}" ]] ; then export CMAKE_BUILD_PARALLEL_LEVEL=${SAVED_PARALLEL_LEVEL} else unset CMAKE_BUILD_PARALLEL_LEVEL fi fi fi if [[ -n "${BUILD_ORCA}" ]] || [[ -n "${BUILD_TESTS}" ]] ; then echo "Configuring OrcaSlicer..." if [[ -n "${CLEAN_BUILD}" ]] ; then print_and_run rm -fr $BUILD_DIR fi read -r -a BUILD_ARGS <<< "${ORCA_EXTRA_BUILD_ARGS}" 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 print_and_run cmake -S . -B $BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" "${CMAKE_CCACHE_ARGS[@]}" -G "Ninja Multi-Config" \ -DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} \ -DORCA_TOOLS=ON \ "${COLORED_OUTPUT}" \ "${BUILD_ARGS[@]}" \ "${EXTRA_CMAKE_ARGS[@]}" echo "done" 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 echo "Building generate_system_cache ..." print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target generate_system_cache ./scripts/run_gettext.sh fi 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 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 print_and_run ${build_linux_image} ${extra_script_args} -R "${BUILD_CONFIG}" echo "done" fi popd > /dev/null # build fi elapsed=$SECONDS printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60)) popd > /dev/null # ${SCRIPT_PATH} |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |