From 27d662c503f08170a1279cc94cf280edbb3868fc Mon Sep 17 00:00:00 2001 From: pszsh Date: Fri, 30 Jan 2026 02:46:03 -0800 Subject: [PATCH] revised scripts, add master to prepare zips for win release builds --- scripts/build_windows.bat | 108 +++++++++++++++++++++++++++++++++++++ scripts/generate_icons.bat | 24 +++++---- scripts/generate_icons.sh | 89 ++++++++++++++++-------------- 3 files changed, 170 insertions(+), 51 deletions(-) create mode 100644 scripts/build_windows.bat diff --git a/scripts/build_windows.bat b/scripts/build_windows.bat new file mode 100644 index 0000000..afcbcf2 --- /dev/null +++ b/scripts/build_windows.bat @@ -0,0 +1,108 @@ +@echo off +setlocal enabledelayedexpansion + +:: ============================================================================== +:: PATHS +:: ============================================================================== +:: This script lives in scripts/ +set "SCRIPT_DIR=%~dp0" + +:: The build scripts live in windows/ +pushd "%SCRIPT_DIR%..\windows" +set "WINDOWS_SCRIPTS_DIR=%CD%" +popd + +:: The output dir is build_windows/ +pushd "%SCRIPT_DIR%.." +set "PROJECT_ROOT=%CD%" +popd +set "OUTPUT_ROOT=%PROJECT_ROOT%\build_windows" + +echo [MASTER] Project Root: %PROJECT_ROOT% +echo [MASTER] Scripts Dir: %WINDOWS_SCRIPTS_DIR% +echo [MASTER] Output Dir: %OUTPUT_ROOT% +echo. + +:: ============================================================================== +:: 1. BUILD ARM64 +:: ============================================================================== +echo [MASTER] Starting ARM64 Build... +echo ------------------------------------------------------------------------------ + +:: Navigate to the windows directory so the script runs in its native context +pushd "%WINDOWS_SCRIPTS_DIR%" + +:: Run the script +call build_arm64.bat + +if %errorlevel% neq 0 ( + echo. + echo [MASTER] CRITICAL ERROR: ARM64 Build Failed. + popd + pause + exit /b %errorlevel% +) + +:: Return to master context +popd +echo. + +:: ============================================================================== +:: 2. ZIP ARM64 +:: ============================================================================== +echo [MASTER] Packaging ARM64... +set "ARM64_SOURCE=%OUTPUT_ROOT%\arm64" +set "ARM64_ZIP=%OUTPUT_ROOT%\YrCrystals_Win_ARM64.zip" + +if exist "%ARM64_SOURCE%\YrCrystals.exe" ( + if exist "%ARM64_ZIP%" del "%ARM64_ZIP%" + powershell -NoProfile -Command "Compress-Archive -Path '%ARM64_SOURCE%\*' -DestinationPath '%ARM64_ZIP%' -Force" + echo [SUCCESS] Created: %ARM64_ZIP% +) else ( + echo [ERROR] ARM64 Output directory missing or empty. Skipping Zip. +) +echo. + +:: ============================================================================== +:: 3. BUILD x64 +:: ============================================================================== +echo [MASTER] Starting x64 Build... +echo ------------------------------------------------------------------------------ + +pushd "%WINDOWS_SCRIPTS_DIR%" +call build_x64.bat + +if %errorlevel% neq 0 ( + echo. + echo [MASTER] CRITICAL ERROR: x64 Build Failed. + popd + pause + exit /b %errorlevel% +) +popd +echo. + +:: ============================================================================== +:: 4. ZIP x64 +:: ============================================================================== +echo [MASTER] Packaging x64... +set "X64_SOURCE=%OUTPUT_ROOT%\x64" +set "X64_ZIP=%OUTPUT_ROOT%\YrCrystals_Win_x64.zip" + +if exist "%X64_SOURCE%\YrCrystals.exe" ( + if exist "%X64_ZIP%" del "%X64_ZIP%" + powershell -NoProfile -Command "Compress-Archive -Path '%X64_SOURCE%\*' -DestinationPath '%X64_ZIP%' -Force" + echo [SUCCESS] Created: %X64_ZIP% +) else ( + echo [ERROR] x64 Output directory missing or empty. Skipping Zip. +) + +:: ============================================================================== +:: DONE +:: ============================================================================== +echo. +echo ------------------------------------------------------------------------------ +echo [MASTER] All builds completed successfully. +echo [OUTPUT] %OUTPUT_ROOT% +echo ------------------------------------------------------------------------------ +pause \ No newline at end of file diff --git a/scripts/generate_icons.bat b/scripts/generate_icons.bat index 02e3350..0092c2b 100644 --- a/scripts/generate_icons.bat +++ b/scripts/generate_icons.bat @@ -11,14 +11,8 @@ set "SOURCE_IMG=%~2" set "DEST_ICO=%~3" :: --- FIX FOR MISSING DELEGATES / REGISTRY ERRORS --- -:: The x86 ImageMagick on ARM64 often fails to find the registry keys. -:: We extract the directory from the executable path and set MAGICK_HOME manually. - for %%I in ("%MAGICK_EXE%") do set "MAGICK_DIR=%%~dpI" - -:: Remove trailing backslash for safety (optional but cleaner) if "%MAGICK_DIR:~-1%"=="\" set "MAGICK_DIR=%MAGICK_DIR:~0,-1%" - set "MAGICK_HOME=%MAGICK_DIR%" set "MAGICK_CONFIGURE_PATH=%MAGICK_DIR%" set "MAGICK_CODER_MODULE_PATH=%MAGICK_DIR%\modules\coders" @@ -33,11 +27,21 @@ if not exist "%SOURCE_IMG%" ( :: 2. Ensure Destination Directory Exists if not exist "%~dp3" mkdir "%~dp3" -:: 3. Generate the .ico -:: We create a multi-layer ICO with standard Windows sizes -echo [ICONS] Generating Windows Icon: %DEST_ICO% +:: 3. Generate the .ico (Nearest Neighbor / Pixel Art Mode) +echo [ICONS] Generating Pixel-Perfect Windows Icon: %DEST_ICO% -"%MAGICK_EXE%" "%SOURCE_IMG%" -define icon:auto-resize=256,128,64,48,32,16 "%DEST_ICO%" +:: We use -sample (Nearest Neighbor) explicitly for each standard icon size. +:: We clone the original (index 0) for every resize to ensure maximum accuracy from the source. +"%MAGICK_EXE%" "%SOURCE_IMG%" ^ + -background none -alpha on ^ + ( -clone 0 -sample 256x256 ) ^ + ( -clone 0 -sample 128x128 ) ^ + ( -clone 0 -sample 64x64 ) ^ + ( -clone 0 -sample 48x48 ) ^ + ( -clone 0 -sample 32x32 ) ^ + ( -clone 0 -sample 16x16 ) ^ + -delete 0 ^ + "%DEST_ICO%" if %errorlevel% neq 0 ( echo [ERROR] ImageMagick failed to generate icon. diff --git a/scripts/generate_icons.sh b/scripts/generate_icons.sh index 6ae98e9..78c434f 100755 --- a/scripts/generate_icons.sh +++ b/scripts/generate_icons.sh @@ -1,5 +1,3 @@ -# scripts/generate_icons.sh - #!/bin/bash # Argument 1: Path to magick executable @@ -32,51 +30,58 @@ mkdir -p "$MACOS_OUT_DIR" ICONSET="$MACOS_OUT_DIR/icon.iconset" mkdir -p "$ICONSET" -"$MAGICK_BIN" "$SOURCE" -scale 16x16 "$ICONSET/icon_16x16.png" -"$MAGICK_BIN" "$SOURCE" -scale 32x32 "$ICONSET/icon_16x16@2x.png" -"$MAGICK_BIN" "$SOURCE" -scale 32x32 "$ICONSET/icon_32x32.png" -"$MAGICK_BIN" "$SOURCE" -scale 64x64 "$ICONSET/icon_32x32@2x.png" -"$MAGICK_BIN" "$SOURCE" -scale 128x128 "$ICONSET/icon_128x128.png" -"$MAGICK_BIN" "$SOURCE" -scale 256x256 "$ICONSET/icon_128x128@2x.png" -"$MAGICK_BIN" "$SOURCE" -scale 256x256 "$ICONSET/icon_256x256.png" -"$MAGICK_BIN" "$SOURCE" -scale 512x512 "$ICONSET/icon_256x256@2x.png" -"$MAGICK_BIN" "$SOURCE" -scale 512x512 "$ICONSET/icon_512x512.png" -"$MAGICK_BIN" "$SOURCE" -scale 1024x1024 "$ICONSET/icon_512x512@2x.png" +echo "[ICONS] Generating macOS iconset (Pixel Perfect)..." +"$MAGICK_BIN" "$SOURCE" -sample 16x16 "$ICONSET/icon_16x16.png" +"$MAGICK_BIN" "$SOURCE" -sample 32x32 "$ICONSET/icon_16x16@2x.png" +"$MAGICK_BIN" "$SOURCE" -sample 32x32 "$ICONSET/icon_32x32.png" +"$MAGICK_BIN" "$SOURCE" -sample 64x64 "$ICONSET/icon_32x32@2x.png" +"$MAGICK_BIN" "$SOURCE" -sample 128x128 "$ICONSET/icon_128x128.png" +"$MAGICK_BIN" "$SOURCE" -sample 256x256 "$ICONSET/icon_128x128@2x.png" +"$MAGICK_BIN" "$SOURCE" -sample 256x256 "$ICONSET/icon_256x256.png" +"$MAGICK_BIN" "$SOURCE" -sample 512x512 "$ICONSET/icon_256x256@2x.png" +"$MAGICK_BIN" "$SOURCE" -sample 512x512 "$ICONSET/icon_512x512.png" +"$MAGICK_BIN" "$SOURCE" -sample 1024x1024 "$ICONSET/icon_512x512@2x.png" iconutil -c icns "$ICONSET" -o "$MACOS_OUT_DIR/app_icon.icns" rm -rf "$ICONSET" -# Windows +# --- Windows --- +echo "[ICONS] Generating Windows .ico (Pixel Perfect)..." +# Updated to match the high-quality logic from the Windows Batch file +# (Removed -alpha off and -colors 256 which would ruin transparency) "$MAGICK_BIN" "$SOURCE" \ - \( -clone 0 -scale 256x256 \) \ - \( -clone 0 -scale 128x128 \) \ - \( -clone 0 -scale 64x64 \) \ - \( -clone 0 -scale 48x48 \) \ - \( -clone 0 -scale 32x32 \) \ - \( -clone 0 -scale 16x16 \) \ - -delete 0 -alpha off -colors 256 "$MACOS_OUT_DIR/app_icon.ico" + -background none -alpha on \ + \( -clone 0 -sample 256x256 \) \ + \( -clone 0 -sample 128x128 \) \ + \( -clone 0 -sample 64x64 \) \ + \( -clone 0 -sample 48x48 \) \ + \( -clone 0 -sample 32x32 \) \ + \( -clone 0 -sample 16x16 \) \ + -delete 0 "$MACOS_OUT_DIR/app_icon.ico" # --- Android --- # Output directly to android/res so QT_ANDROID_PACKAGE_SOURCE_DIR picks it up +echo "[ICONS] Generating Android mipmaps (Pixel Perfect)..." ANDROID_DIR="android/res" mkdir -p "$ANDROID_DIR/mipmap-mdpi" -"$MAGICK_BIN" "$SOURCE" -scale 48x48 "$ANDROID_DIR/mipmap-mdpi/ic_launcher.png" +"$MAGICK_BIN" "$SOURCE" -sample 48x48 "$ANDROID_DIR/mipmap-mdpi/ic_launcher.png" mkdir -p "$ANDROID_DIR/mipmap-hdpi" -"$MAGICK_BIN" "$SOURCE" -scale 72x72 "$ANDROID_DIR/mipmap-hdpi/ic_launcher.png" +"$MAGICK_BIN" "$SOURCE" -sample 72x72 "$ANDROID_DIR/mipmap-hdpi/ic_launcher.png" mkdir -p "$ANDROID_DIR/mipmap-xhdpi" -"$MAGICK_BIN" "$SOURCE" -scale 96x96 "$ANDROID_DIR/mipmap-xhdpi/ic_launcher.png" +"$MAGICK_BIN" "$SOURCE" -sample 96x96 "$ANDROID_DIR/mipmap-xhdpi/ic_launcher.png" mkdir -p "$ANDROID_DIR/mipmap-xxhdpi" -"$MAGICK_BIN" "$SOURCE" -scale 144x144 "$ANDROID_DIR/mipmap-xxhdpi/ic_launcher.png" +"$MAGICK_BIN" "$SOURCE" -sample 144x144 "$ANDROID_DIR/mipmap-xxhdpi/ic_launcher.png" mkdir -p "$ANDROID_DIR/mipmap-xxxhdpi" -"$MAGICK_BIN" "$SOURCE" -scale 192x192 "$ANDROID_DIR/mipmap-xxxhdpi/ic_launcher.png" +"$MAGICK_BIN" "$SOURCE" -sample 192x192 "$ANDROID_DIR/mipmap-xxxhdpi/ic_launcher.png" # --- iOS --- # Output directly to ios/Assets.xcassets +echo "[ICONS] Generating iOS AppIcon (Pixel Perfect)..." XCASSETS_DIR="ios/Assets.xcassets" IOS_DIR="$XCASSETS_DIR/AppIcon.appiconset" mkdir -p "$IOS_DIR" @@ -90,21 +95,21 @@ cat > "$XCASSETS_DIR/Contents.json" < "$IOS_DIR/Contents.json" < "$IOS_DIR/Contents.json" <