Skip to content

Commit 6f65d22

Browse files
committed
Merge branch 'update_ci'
2 parents f384e89 + 797acd9 commit 6f65d22

File tree

8 files changed

+83
-37
lines changed

8 files changed

+83
-37
lines changed

.github/workflows/ccpp.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,47 @@ name: Build
44
on: push
55

66
jobs:
7-
87
linux:
9-
runs-on: ubuntu-20.04
10-
container: docker://jgeudens/qt-linux:5.15.2_build_1
8+
runs-on: ubuntu-latest
9+
10+
container:
11+
image: docker://jgeudens/qt-linux:6.4.1_build_1
1112
steps:
12-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1314

1415
- name: Update Modules and Build
15-
run: sh scripts/build_linux.sh
16+
run: bash scripts/build_linux.sh
1617

1718
- name: Deploy
18-
run: sh scripts/deploy_linux.sh
19+
run: bash scripts/deploy_linux.sh
1920

20-
- uses: actions/upload-artifact@v2
21+
- uses: actions/upload-artifact@v3
2122
with:
2223
name: modbussim-linux
23-
path: release/bin/linux/ModbusSim*.AppImage
24+
path: ModbusSim*.AppImage
2425

2526
windows:
2627
runs-on: windows-2019
2728

2829
steps:
29-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
3031

3132
- name: Install Qt installer
3233
run: pip3 install aqtinstall
3334

35+
# Cache go build cache, used to speedup go test
36+
- name: Qt Build Cache
37+
uses: actions/cache@v3
38+
id: cache
39+
with:
40+
path: ${{ github.workspace }}\Qt
41+
key: ${{ runner.os }}-qt-build-${{ hashFiles('scripts\setup_windows.bat') }}
42+
3443
- name: Setup, build and deploy
3544
shell: cmd
36-
run: scripts/full_build_and_deploy_windows.bat ${{ github.workspace }}
45+
run: scripts\full_build_and_deploy_windows.bat '${{ steps.cache.outputs.cache-hit }}' ${{ github.workspace }}\Qt
3746

38-
- uses: actions/upload-artifact@v2
47+
- uses: actions/upload-artifact@v3
3948
with:
4049
name: modbussim-windows
4150
path: |

CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,36 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1111
set(CMAKE_CXX_STANDARD 11)
1212
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1313

14-
# Tell CMake to run moc when necessary:
1514
set(CMAKE_AUTOUIC ON)
1615
set(CMAKE_AUTOMOC ON)
1716
set(CMAKE_AUTORCC ON)
1817

19-
find_package(Qt5 COMPONENTS
20-
Core
21-
Gui
18+
# Find the QtCore library
19+
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
20+
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
21+
22+
message(STATUS "Using Qt${QT_VERSION_MAJOR} version ${Qt${QT_VERSION_MAJOR}Core_VERSION}")
23+
24+
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS
2225
Widgets
2326
Xml
24-
PrintSupport
2527
Network
2628
SerialBus
2729

2830
REQUIRED
2931
)
3032

3133
set(QT_LIB
32-
Qt::Core
33-
Qt::Gui
3434
Qt::Widgets
3535
Qt::Xml
36-
Qt::PrintSupport
3736
Qt::Network
3837
Qt::SerialBus
3938
)
4039

41-
include_directories(SYSTEM ${QT_INCLUDES})
42-
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/testslave)
40+
include_directories(
41+
${CMAKE_CURRENT_SOURCE_DIR}/src
42+
${CMAKE_CURRENT_SOURCE_DIR}/testslave
43+
)
4344

4445
SET(APP_SRCS
4546
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp

scripts/build_windows.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ echo %PATH%
99
g++ -v
1010

1111
cmake -G "Ninja" ..
12+
IF ERRORLEVEL 1 GOTO errorHandling
13+
1214
ninja
15+
IF ERRORLEVEL 1 GOTO errorHandling
1316

1417
cd ..
18+
19+
EXIT /B 0
20+
21+
:errorHandling
22+
EXIT /B 1

scripts/deploy_linux.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ chmod +x linuxdeploy*.AppImage
1818
export APPIMAGE_EXTRACT_AND_RUN=1 # Workaround because FUSE isn't available in Docker
1919
./linuxdeploy-x86_64.AppImage --appdir AppDir -e modbussim -i ModbusSim.png -d ModbusSim.desktop --plugin qt --output appimage
2020

21-
ls
21+
ls
22+
23+
cp ModbusSim*.AppImage ../../..
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
echo on
22

3-
call scripts\setup_windows.bat %1
3+
REM Usage (path is optional):
4+
REM Use cache: scripts\full_build_and_deploy_windows.bat 'true' [path]
5+
REM No cache: scripts\full_build_and_deploy_windows.bat '' [path]
6+
7+
call scripts\setup_windows.bat %1 %2
48
call scripts\build_windows.bat
5-
call scripts\deploy_windows.bat
9+
call scripts\deploy_windows.bat

scripts/setup_windows.bat

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,53 @@
11
echo on
22

3-
if "%~1"=="" (set "QT_INSTALL_DIR=D:\aqt_Qt\Qt") else (set "QT_INSTALL_DIR=%~1\Qt")
3+
echo Argument1: %~1
4+
echo Argument2: %~2
5+
6+
if "%~1"=="'true'" (set "CACHE_HIT=1") else (set "CACHE_HIT=0")
7+
if "%~2"=="" (set "QT_INSTALL_DIR=D:\aqt_Qt\Qt") else (set "QT_INSTALL_DIR=%~2")
48
echo QT_INSTALL_DIR: %QT_INSTALL_DIR%
9+
echo CACHE_HIT: %CACHE_HIT%
510

611
REM Set configuration
7-
set QT=5.15.2
8-
set QT_MODULES=
12+
set QT=6.4.1
13+
set QT_MODULES=qtserialbus qtserialport
914
set QT_HOST=windows
1015
set QT_TARGET=desktop
11-
set QT_ARCH=win64_mingw81
16+
set QT_ARCH=win64_mingw
17+
18+
set QT_ARCH_PATH=mingw_64
19+
20+
if %CACHE_HIT% EQU 1 (
21+
echo "Cache hit!"
22+
goto cache_hit
23+
)
1224

13-
set QT_ARCH_PATH=mingw81_64
25+
echo "Cache miss: installing Qt"
1426

1527
REM Install Qt
1628
aqt install-qt --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% %QT% %QT_ARCH% -m %QT_MODULES%
1729

1830
REM Install Tools
19-
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_mingw qt.tools.win64_mingw810
31+
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_mingw90 qt.tools.win64_mingw900
2032
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_cmake
2133
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_ninja
2234
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_openssl_x64
2335

36+
:cache_hit
37+
38+
REM Debug info
39+
echo Debug info
40+
dir %QT_INSTALL_DIR%\Tools
41+
2442
REM Set env variables with path
2543
set "PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\bin;%PATH%"
26-
set "PATH=%QT_INSTALL_DIR%\Tools\mingw810_64\bin;%PATH%"
44+
set "PATH=%QT_INSTALL_DIR%\Tools\mingw1120_64\bin;%PATH%"
2745
set "PATH=%QT_INSTALL_DIR%\Tools\CMake_64\bin;%PATH%"
2846
set "PATH=%QT_INSTALL_DIR%\Tools\Ninja;%PATH%"
2947

3048
set "QT_PLUGIN_PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\plugins\"
3149
set "QML_IMPORT_PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\qml\"
3250
set "QML2_IMPORT_PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\qml\"
33-
set "CMAKE_PREFIX_PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\lib\cmake\Qt5"
51+
set "CMAKE_PREFIX_PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\lib\cmake\Qt6"
3452

3553
set "OPENSSL_DIR=%QT_INSTALL_DIR%\Tools\OpenSSL\Win_x64\bin"

src/mainwindow.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ MainWindow::MainWindow(QWidget *parent) :
3636
_exceptionGroup.addButton(_pUi->chkTargetNoResponse, QModbusPdu::GatewayTargetDeviceFailedToRespond);
3737
_exceptionGroup.addButton(_pUi->chkGatewayPathUnavailable, QModbusPdu::GatewayPathUnavailable);
3838

39-
connect(&_exceptionGroup, QOverload<int, bool>::of(&QButtonGroup::buttonToggled),
39+
connect(&_exceptionGroup, QOverload<int, bool>::of(&QButtonGroup::idToggled), this,
4040
[=](int id, bool checked){
4141
if (checked)
4242
{
@@ -49,7 +49,7 @@ MainWindow::MainWindow(QWidget *parent) :
4949
_errorRecurrenceGroup.addButton(_pUi->optErrorOnce, true);
5050
_errorRecurrenceGroup.addButton(_pUi->optErrorPersistent, false);
5151

52-
connect(&_errorRecurrenceGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
52+
connect(&_errorRecurrenceGroup, QOverload<int>::of(&QButtonGroup::idClicked), this,
5353
[=](int id){
5454
_bErrorOnce = static_cast<bool>(id);
5555
});
@@ -60,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent) :
6060
connect(&_autoIncTimer, &QTimer::timeout, this, &MainWindow::handleAutoIncTick);
6161
_autoIncTimer.start(1000);
6262
_bAutoInc = false;
63-
connect(_pUi->checkAutoIncrement, &QCheckBox::stateChanged,
63+
connect(_pUi->checkAutoIncrement, &QCheckBox::stateChanged, this,
6464
[=](int state){
6565
_bAutoInc = (state == Qt::Checked);
6666
});
@@ -151,6 +151,6 @@ void MainWindow::handleRequestProcessed()
151151
{
152152
if (_bErrorOnce)
153153
{
154-
_pUi->chkNone->animateClick(Qt::Checked);
154+
_pUi->chkNone->click();
155155
}
156156
}

src/registerdatamodel.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ QVariant RegisterDataModel::data(const QModelIndex &index, int role) const
4949
{
5050
return QString("%0").arg(registerAddress + 40001);
5151
}
52+
else
53+
{
54+
return QVariant();
55+
}
5256
}
5357
else if (role == Qt::CheckStateRole)
5458
{
@@ -101,7 +105,7 @@ bool RegisterDataModel::setData(const QModelIndex &index, const QVariant &value,
101105
}
102106
else if (role == Qt::EditRole)
103107
{
104-
if (value.canConvert(QMetaType::UInt))
108+
if (value.canConvert(QMetaType(QMetaType::UInt)))
105109
{
106110
_pTestSlaveData->setRegisterValue(registerAddress, value.toUInt());
107111
}

0 commit comments

Comments
 (0)