TabEditor-Qt/packaging.bat
2023-06-27 23:52:43 +08:00

76 lines
1.6 KiB
Batchfile

@echo off
setlocal
REM 获取当前脚本所在目录
set "SCRIPT_DIR=%~dp0"
REM 构建路径选择
set "BUILD_DIR="
REM 构建类型选择
set "BUILD_TYPE="
REM 列出同级目录中包含 "build" 的文件夹
setlocal enabledelayedexpansion
set "BUILD_INDEX=1"
for /d %%D in ("%SCRIPT_DIR%..\build*") do (
echo [!BUILD_INDEX!] %%~fD
set "BUILD_DIRS[!BUILD_INDEX!]=%%~fD"
set /a "BUILD_INDEX+=1"
)
REM 检查是否找到 build 文件夹
if "%BUILD_INDEX%"=="1" (
echo Error: Build directory not found.
pause
exit /b 1
)
REM 提示用户选择构建目录
set /p "BUILD_SELECTION=Enter the number of the build directory: "
REM 根据用户选择设置构建目录
if defined BUILD_DIRS[%BUILD_SELECTION%] (
set "BUILD_DIR=!BUILD_DIRS[%BUILD_SELECTION%]!"
) else (
echo Error: Invalid build directory selection.
pause
exit /b 1
)
REM 提示用户选择构建类型
echo Choose the build type:
echo [1] Debug
echo [2] Release
set /p "BUILD_TYPE=Enter the number of the build type: "
REM 根据用户选择设置构建目录和构建类型
if "%BUILD_TYPE%"=="1" (
set "BUILD_DIR=%BUILD_DIR%\debug"
) else if "%BUILD_TYPE%"=="2" (
set "BUILD_DIR=%BUILD_DIR%\release"
) else (
echo Error: Invalid build type.
pause
exit /b 1
)
REM 切换到Qt环境变量脚本所在目录
cd /d "C:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin"
REM 运行Qt环境变量脚本
call qtenv2.bat
REM 切换到构建目录
cd /d "%BUILD_DIR%"
REM 运行windeployqt命令来打包依赖项
windeployqt TabEditor.exe
REM 切换回脚本所在目录
cd /d "%SCRIPT_DIR%"
REM 完成打包
echo Packaging completed successfully.
pause