print build time

This commit is contained in:
SoftFever
2026-03-19 23:17:03 +08:00
parent acbe5c708e
commit a9c5748d30
5 changed files with 50 additions and 17 deletions

View File

@@ -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))

View File

@@ -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}

View File

@@ -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))

View File

@@ -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

View File

@@ -4,7 +4,7 @@
# as the CI (build_all.yml).
#
# Usage:
# ./scripts/build_flatpak_with_docker.sh [--arch <x86_64|aarch64>] [--no-debug-info]
# ./scripts/build_flatpak_with_docker.sh [--arch <x86_64|aarch64>] [--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 <x86_64|aarch64>] [--no-debug-info] [--no-pull] [--keep-build] [--privileged] [--image <image>]"
echo "Usage: $0 [--arch <x86_64|aarch64>] [--no-debug-info] [--pull] [--keep-build] [--image <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).
@@ -216,3 +220,6 @@ echo " ${PROJECT_ROOT}/${BUNDLE_NAME}"
echo ""
echo "Install with:"
echo " flatpak install --user ${BUNDLE_NAME}"
elapsed=$SECONDS
printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60))