From 303c33b44dd0a07c35c776a1435bddcaa743438b Mon Sep 17 00:00:00 2001 From: haosicheng Date: Mon, 13 Oct 2025 14:58:56 +0800 Subject: [PATCH] =?UTF-8?q?[patch]=20=E4=BF=AE=E6=94=B9=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E9=A1=B9=E7=BC=93=E5=AD=98=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=20=E6=8F=90=E5=8D=87=E6=89=93=E5=8C=85=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/gui-version-release.yml | 4 ++++ quick_build.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/gui-version-release.yml b/.gitea/workflows/gui-version-release.yml index 94be626..d07d65e 100644 --- a/.gitea/workflows/gui-version-release.yml +++ b/.gitea/workflows/gui-version-release.yml @@ -135,6 +135,10 @@ jobs: - name: Build production executable if: success() shell: powershell + # Optional: Set FORCE_FULL_CLEAN=true to force complete rebuild (clears build cache) + # Default: Incremental build mode (preserves build cache for faster builds) + # env: + # FORCE_FULL_CLEAN: "true" run: | Write-Host "=========================================="; Write-Host "Step 4.5: Build production executable"; diff --git a/quick_build.py b/quick_build.py index 2a611ee..20869a8 100644 --- a/quick_build.py +++ b/quick_build.py @@ -9,6 +9,11 @@ import subprocess import shutil from pathlib import Path +# Build optimization: Control whether to force full clean +# Set environment variable FORCE_FULL_CLEAN=true to clean both dist and build directories +# Default: false (incremental build, faster) +FORCE_FULL_CLEAN = os.getenv('FORCE_FULL_CLEAN', 'false').lower() == 'true' + def clean_build(): """清理构建目录""" @@ -22,7 +27,16 @@ def clean_build(): print("Waiting for file handles to release...") time.sleep(0.5) - dirs_to_clean = ['dist', 'build'] + # Build optimization: Preserve build cache for faster incremental builds + # The build directory contains PyInstaller analysis cache + # Preserving it can reduce build time from ~7min to ~3min + if FORCE_FULL_CLEAN: + dirs_to_clean = ['dist', 'build'] + print("FORCE_FULL_CLEAN enabled - cleaning all directories including build cache") + else: + dirs_to_clean = ['dist'] + print("Incremental build mode - preserving build cache for faster builds") + for dir_name in dirs_to_clean: print(f"Checking directory: {dir_name}") if os.path.exists(dir_name): @@ -56,6 +70,9 @@ def build_with_command(): '--name=MultiPlatformGUI', # 直接使用最终目录名 '--onedir', # 相当于 --exclude-binaries '--windowed', # 相当于 -w + '--noconfirm', # Build optimization: Skip confirmation prompts + '--log-level=WARN', # Build optimization: Reduce log output (only warnings and errors) + '--noupx', # Build optimization: Skip UPX compression (saves time, minimal size impact) '--icon=static/ai_assistant_icon_64.png', # 添加主程序图标 '--add-data=config.py;.', '--add-data=exe_file_logger.py;.',