From a9c5748d309321fb070f0603f15e73c458c6bd9d Mon Sep 17 00:00:00 2001 From: SoftFever Date: Thu, 19 Mar 2026 23:17:03 +0800 Subject: [PATCH] print build time --- build_flatpak.sh | 4 +++ build_linux.sh | 4 +++ build_release_macos.sh | 4 +++ build_release_vs.bat | 18 ++++++++++++-- scripts/build_flatpak_with_docker.sh | 37 +++++++++++++++++----------- 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/build_flatpak.sh b/build_flatpak.sh index 225cf25e66..94b79b1465 100755 --- a/build_flatpak.sh +++ b/build_flatpak.sh @@ -5,6 +5,7 @@ # Based on the GitHub Actions workflow in .github/workflows/build_all.yml set -e +SECONDS=0 # Colors for output RED='\033[0;31m' @@ -371,3 +372,6 @@ if [[ "$FORCE_CLEAN" != true ]]; then echo -e "• To force a clean build: $0 -f" echo -e "• To clean cache manually: rm -rf $CACHE_DIR" fi + +elapsed=$SECONDS +printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60)) diff --git a/build_linux.sh b/build_linux.sh index 9a9a9160ba..b1e1806c27 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -1,5 +1,6 @@ #!/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}")") @@ -266,4 +267,7 @@ if [[ -n "${BUILD_IMAGE}" || -n "${BUILD_ORCA}" ]] ; then 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} diff --git a/build_release_macos.sh b/build_release_macos.sh index 4fca109877..8d417695ad 100755 --- a/build_release_macos.sh +++ b/build_release_macos.sh @@ -2,6 +2,7 @@ set -e set -o pipefail +SECONDS=0 while getopts ":dpa:snt:xbc:i:1Tuh" opt; do case "${opt}" in @@ -342,3 +343,6 @@ fi if [ "1." == "$PACK_DEPS". ]; then pack_deps fi + +elapsed=$SECONDS +printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60)) diff --git a/build_release_vs.bat b/build_release_vs.bat index fc3445bb5d..3f1a2e0af4 100644 --- a/build_release_vs.bat +++ b/build_release_vs.bat @@ -1,6 +1,7 @@ @REM OrcaSlicer build script for Windows with VS auto-detect @echo off set WP=%CD% +set _START_TIME=%TIME% @REM Check for Ninja Multi-Config option (-x) set USE_NINJA=0 @@ -73,7 +74,7 @@ if "%1"=="pack" ( echo packing deps: OrcaSlicer_dep_win64_!build_date!_vs!VS_VERSION!.zip %WP%/tools/7z.exe a OrcaSlicer_dep_win64_!build_date!_vs!VS_VERSION!.zip OrcaSlicer_dep - exit /b 0 + goto :done ) set debug=OFF @@ -120,7 +121,7 @@ if "%USE_NINJA%"=="1" ( ) @echo off -if "%1"=="deps" exit /b 0 +if "%1"=="deps" goto :done :slicer echo "building Orca Slicer..." @@ -142,3 +143,16 @@ cd .. call scripts/run_gettext.bat cd %build_dir% cmake --build . --target install --config %build_type% + +:done +@echo off +for /f "tokens=1-3 delims=:.," %%a in ("%_START_TIME: =0%") do set /a "_start_s=%%a*3600+%%b*60+%%c" +for /f "tokens=1-3 delims=:.," %%a in ("%TIME: =0%") do set /a "_end_s=%%a*3600+%%b*60+%%c" +set /a "_elapsed=_end_s - _start_s" +if %_elapsed% lss 0 set /a "_elapsed+=86400" +set /a "_hours=_elapsed / 3600" +set /a "_remainder=_elapsed - _hours * 3600" +set /a "_mins=_remainder / 60" +set /a "_secs=_remainder - _mins * 60" +echo. +echo Build completed in %_hours%h %_mins%m %_secs%s diff --git a/scripts/build_flatpak_with_docker.sh b/scripts/build_flatpak_with_docker.sh index 8e490f8f8b..d3eeaab6df 100755 --- a/scripts/build_flatpak_with_docker.sh +++ b/scripts/build_flatpak_with_docker.sh @@ -4,7 +4,7 @@ # as the CI (build_all.yml). # # Usage: -# ./scripts/build_flatpak_with_docker.sh [--arch ] [--no-debug-info] +# ./scripts/build_flatpak_with_docker.sh [--arch ] [--no-debug-info] [--pull] # # Requirements: # - Docker (or Podman with docker compatibility) @@ -12,6 +12,7 @@ # The resulting .flatpak bundle is placed in the project root. set -euo pipefail +SECONDS=0 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" @@ -19,9 +20,8 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # ---------- defaults ---------- ARCH="$(uname -m)" NO_DEBUG_INFO=false -NO_PULL=false +FORCE_PULL=false FORCE_CLEAN=true -PRIVILEGED=false CONTAINER_IMAGE="ghcr.io/flathub-infra/flatpak-github-actions:gnome-49" normalize_arch() { @@ -45,16 +45,18 @@ while [[ $# -gt 0 ]]; do ARCH="$2"; shift 2 ;; --no-debug-info) NO_DEBUG_INFO=true; shift ;; + --pull) + FORCE_PULL=true; shift ;; --no-pull) - NO_PULL=true; shift ;; + FORCE_PULL=false; shift ;; # kept for backward compat (now default) --keep-build) FORCE_CLEAN=false; shift ;; - --privileged) - PRIVILEGED=true; shift ;; --image) CONTAINER_IMAGE="$2"; shift 2 ;; -h|--help) - echo "Usage: $0 [--arch ] [--no-debug-info] [--no-pull] [--keep-build] [--privileged] [--image ]" + echo "Usage: $0 [--arch ] [--no-debug-info] [--pull] [--keep-build] [--image ]" + echo " --pull Force pull the container image (default: use cached, auto-pull if missing)" + echo " --no-pull Do not force pull (default, kept for backward compat)" exit 0 ;; *) echo "Unknown option: $1" >&2; exit 1 ;; @@ -91,7 +93,7 @@ echo " Arch: ${ARCH}" echo " Image: ${CONTAINER_IMAGE}" echo " Bundle: ${BUNDLE_NAME}" echo " Debug info: $([ "$NO_DEBUG_INFO" = true ] && echo "disabled" || echo "enabled")" -echo " Privileged: $([ "$PRIVILEGED" = true ] && echo "enabled" || echo "disabled")" +echo " Pull mode: $([ "$FORCE_PULL" = true ] && echo "force" || echo "auto (cached if available)")" echo " ccache: enabled" echo "" @@ -123,9 +125,14 @@ sed "/name: OrcaSlicer/{ # ---------- run build in Docker ---------- DOCKER="${DOCKER:-docker}" -if [ "$NO_PULL" = false ]; then - echo "=== Pulling container image ===" +if [ "$FORCE_PULL" = true ]; then + echo "=== Pulling container image (--pull requested) ===" "$DOCKER" pull "$CONTAINER_IMAGE" +elif ! "$DOCKER" image inspect "$CONTAINER_IMAGE" &>/dev/null; then + echo "=== Pulling container image (not found locally) ===" + "$DOCKER" pull "$CONTAINER_IMAGE" +else + echo "=== Using cached container image (use --pull to update) ===" fi FORCE_CLEAN_FLAG="" @@ -133,10 +140,7 @@ if [ "$FORCE_CLEAN" = true ]; then FORCE_CLEAN_FLAG="--force-clean" fi -DOCKER_RUN_ARGS=(run --rm) -if [ "$PRIVILEGED" = true ]; then - DOCKER_RUN_ARGS+=(--privileged) -fi +DOCKER_RUN_ARGS=(run --rm -i --privileged) # Pass build parameters as env vars so the inner script doesn't need # variable expansion from the outer shell (avoids quoting issues). @@ -215,4 +219,7 @@ echo "=== Flatpak bundle ready ===" echo " ${PROJECT_ROOT}/${BUNDLE_NAME}" echo "" echo "Install with:" -echo " flatpak install --user ${BUNDLE_NAME}" \ No newline at end of file +echo " flatpak install --user ${BUNDLE_NAME}" + +elapsed=$SECONDS +printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60)) \ No newline at end of file