86 lines
1.9 KiB
Batchfile
86 lines
1.9 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 寻找当前要编译的exe程序
|
|
set "EXECUTABLE=%BUILD_DIR%\TabEditor.exe"
|
|
if not exist "%EXECUTABLE%" (
|
|
echo Error: Executable not found in the selected build directory.
|
|
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命令来打包依赖项
|
|
echo Running windeployqt to package dependencies...
|
|
windeployqt "%EXECUTABLE%"
|
|
|
|
REM 切换回脚本所在目录
|
|
cd /d "%SCRIPT_DIR%"
|
|
|
|
REM 完成打包
|
|
echo.
|
|
echo Packaging completed successfully.
|
|
pause
|