Skip to content

Commit 8efef59

Browse files
build(windows): 重构构建发布脚本并更新安装程序配置- 重新组织 build_release.bat脚本结构,增加注释和错误处理
- 创建临时构建目录以避免直接修改项目目录- 更新 SerialPortDebugger.iss配置,使用临时构建目录作为源文件路径 - 优化 Qt 部署和 MinGW运行时库复制过程 - 改进错误处理和用户提示信息
1 parent bc63800 commit 8efef59

File tree

2 files changed

+50
-32
lines changed

2 files changed

+50
-32
lines changed

kit/windows_x86_64/SerialPortDebugger.iss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ ArchitecturesInstallIn64BitMode=x64
1616
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
1717

1818
[Files]
19-
; 使用 windeployqt 打包后的完整发布目录(包含exe + Qt依赖 + MinGW运行时)
20-
Source: "D:\Code\QtProjects\serial_port_debugger\build\Desktop_Qt_5_15_2_MinGW_64_bit-Release\release\*"; DestDir: "{app}"; \
21-
Excludes: "*.pdb,*.ilk,*.qch,*.pri,*.pro,*.obj"; Flags: ignoreversion recursesubdirs createallsubdirs
19+
; ´Ó temp_build Ŀ¼¸´ÖÆËùÓÐÎļþ
20+
Source: "C:\Users\pengx\Desktop\temp_build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
2221

2322
[Icons]
2423
Name: "{group}\Serial Port Debugger"; Filename: "{app}\SerialPortDebugger.exe"
Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,87 @@
11
@echo off
2-
SETLOCAL
2+
setlocal
33

4-
:: Set variables
4+
echo.
5+
echo Set variables environment.
6+
echo.
57
set QT_DIR=D:\Dev\Qt5.15\5.15.2\mingw81_64
6-
set QMAKE_DIR=%QT_DIR%\bin
8+
set QMAKE=%QT_DIR%\bin\qmake.exe
79
set WINDEPLOYQT=%QT_DIR%\bin\windeployqt.exe
810
set PLUGIN_DIR=%QT_DIR%\plugins
911

1012
set PROJECT_DIR=D:\Code\QtProjects\serial_port_debugger
1113
set BUILD_DIR=%PROJECT_DIR%\build\Desktop_Qt_5_15_2_MinGW_64_bit-Release\release
12-
set EXE_NAME=SerialPortDebugger.exe
13-
set ICON_PATH=%PROJECT_DIR%\application.ico
14+
set OUTPUT_EXE=SerialPortDebugger.exe
1415

15-
set ISS_SCRIPT=%PROJECT_DIR%\kit\windows_x86_64\SerialPortDebugger.iss
16+
set DESKTOP_DIR=C:\Users\pengx\Desktop
17+
set TEMP_DIR=%DESKTOP_DIR%\temp_build
1618
set INNO_SETUP=D:\Program Files (x86)\Inno Setup\ISCC.exe
17-
set OUTPUT_DIR=%USERPROFILE%\Desktop
19+
set ISS_SCRIPT=%PROJECT_DIR%\kit\windows_x86_64\SerialPortDebugger.iss
20+
set ICON_PATH=%PROJECT_DIR%\application.ico
21+
1822

1923
echo.
20-
echo Deploying Qt dependencies with windeployqt...
24+
echo Change directory to desktop.
2125
echo.
26+
cd /d "%DESKTOP_DIR%"
2227

23-
"%WINDEPLOYQT%" --dir "%BUILD_DIR%" --plugindir "%PLUGIN_DIR%" "%BUILD_DIR%\%EXE_NAME%"
24-
if not "%errorlevel%"=="0" (
25-
echo Error: windeployqt execution failed.
26-
exit /b 1
27-
)
2828

2929
echo.
30-
echo Copying MinGW runtime libraries...
30+
echo Remove old temp_build directory if it existed.
3131
echo.
32+
if exist "%TEMP_DIR%" rd /s /q "%TEMP_DIR%"
3233

33-
copy /Y "%QMAKE_DIR%\libwinpthread-1.dll" "%BUILD_DIR%"
34-
copy /Y "%QMAKE_DIR%\libstdc++-6.dll" "%BUILD_DIR%"
35-
copy /Y "%QMAKE_DIR%\libgcc_s_seh-1.dll" "%BUILD_DIR%"
3634

3735
echo.
38-
echo Copying Qt platform plugins...
36+
echo Create new temporary build directory.
3937
echo.
38+
mkdir "%TEMP_DIR%"
4039

41-
xcopy /E /I /Y "%PLUGIN_DIR%\platforms" "%BUILD_DIR%\platforms"
4240

43-
if not exist "%BUILD_DIR%\%EXE_NAME%" (
44-
echo Error: Target executable %EXE_NAME% not found. Please ensure the build is successful.
45-
exit /b 1
46-
)
41+
echo.
42+
echo Copy application executable to temporary directory.
43+
echo.
44+
copy "%BUILD_DIR%\%OUTPUT_EXE%" "%TEMP_DIR%\"
45+
4746

4847
echo.
49-
echo Packaging with Inno Setup...
48+
echo Change working directory to temporary build folder.
5049
echo.
50+
cd /d "%TEMP_DIR%"
5151

52+
53+
echo.
54+
echo Deploye Qt dependencies using windeployqt.
55+
echo.
56+
"%WINDEPLOYQT%" "%TEMP_DIR%\%OUTPUT_EXE%"
57+
58+
59+
echo.
60+
echo Copy MinGW runtime libraries to temporary directory.
61+
echo.
62+
copy "%QT_DIR%\bin\libwinpthread-1.dll" "%TEMP_DIR%\"
63+
copy "%QT_DIR%\bin\libstdc++-6.dll" "%TEMP_DIR%\"
64+
copy "%QT_DIR%\bin\libgcc_s_seh-1.dll" "%TEMP_DIR%\"
65+
66+
67+
echo.
68+
echo Packaging with Inno Setup...
69+
echo %INNO_SETUP%
70+
echo %ISS_SCRIPT%
71+
echo.
5272
if not exist "%ISS_SCRIPT%" (
5373
echo Error: Inno Setup script not found at %ISS_SCRIPT%
54-
exit /b 1
74+
pause
5575
)
56-
5776
"%INNO_SETUP%" "%ISS_SCRIPT%"
5877

5978
if errorlevel 1 (
6079
echo Error: Inno Setup packaging failed!
61-
exit /b 1
80+
pause
6281
)
6382

6483
echo.
65-
echo Packaging completed successfully! Installer generated on the desktop.
84+
echo Packaging completed successfully! Installer generated on the desktop. %TEMP_DIR% can delete by user.
6685
echo.
6786

68-
ENDLOCAL
87+
endlocal

0 commit comments

Comments
 (0)