Skip to content

Commit 3701dc2

Browse files
committed
Port build scripts from ModbusScope
1 parent 54d7cbc commit 3701dc2

8 files changed

Lines changed: 94 additions & 56 deletions

File tree

.github/workflows/ccpp.yml

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,9 @@ jobs:
77

88
linux:
99
runs-on: ubuntu-20.04
10-
10+
container: docker://jgeudens/qt-linux:5.15.2_build_1
1111
steps:
12-
- uses: actions/checkout@v1
13-
with:
14-
submodules: true
15-
16-
- name: Install Qt
17-
uses: jurplel/install-qt-action@v2
18-
with:
19-
version: 5.15.2
20-
21-
- name: Install toolchain dependencies
22-
run: sudo apt-get install ninja-build
12+
- uses: actions/checkout@v2
2313

2414
- name: Update Modules and Build
2515
run: sh scripts/build_linux.sh
@@ -30,32 +20,23 @@ jobs:
3020
- uses: actions/upload-artifact@v2
3121
with:
3222
name: modbussim-linux
33-
path: release/bin/linux/ModbusSim*.AppImage
23+
path: release/src/bin/linux/ModbusSim*.AppImage
3424

3525
windows:
3626
runs-on: windows-2019
3727

3828
steps:
39-
- uses: actions/checkout@v1
40-
with:
41-
submodules: true
29+
- uses: actions/checkout@v2
4230

43-
- name: Install Qt
44-
uses: jurplel/install-qt-action@v2
45-
with:
46-
version: 5.15.2
47-
arch: win64_mingw81
48-
49-
- name: Install toolchain dependencies
50-
run: choco install ninja
31+
- name: Install Qt installer
32+
run: pip3 install aqtinstall
5133

52-
- name: Update Modules and Build
53-
run: scripts/build_windows.bat
54-
55-
- name: Deploy
56-
run: scripts/deploy_windows.bat
34+
- name: Setup, build and deploy
35+
shell: cmd
36+
run: scripts/full_build_and_deploy_windows.bat ${{ github.workspace }}
5737

5838
- uses: actions/upload-artifact@v2
5939
with:
6040
name: modbussim-windows
61-
path: release\bin\win\ModbusSim.zip
41+
path: |
42+
release\src\bin\win\ModbusSim.zip

CMakeLists.txt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.16)
22

33
project(ModbusSim
44
LANGUAGES CXX
5-
DESCRIPTION "Test module to test Modbus communication"
5+
DESCRIPTION "Modbus Slave Simulation"
66
VERSION 0.0.0
77
)
88

99
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1010

11-
# As moc files are generated in the binary dir, tell CMake
12-
# to always look for includes there:
13-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
14-
1511
set(CMAKE_CXX_STANDARD 11)
1612
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1713

@@ -60,25 +56,34 @@ SET(TESTSLAVE_SRCS
6056
${CMAKE_CURRENT_SOURCE_DIR}/testslave/testslavemodbus.cpp
6157
)
6258

63-
# set platform specific for compilation
59+
# Default GUI type is blank
60+
set(GUI_TYPE "")
61+
6462
if(WIN32)
63+
set(GUI_TYPE WIN32)
6564
set(target_dir "bin/win")
6665
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
6766
set(target_dir "bin/linux")
6867
else()
69-
message(SEND_ERROR "You are on an unsupported platform! (Not Win, Mac OS X or Unix)")
68+
message(SEND_ERROR "You are on an unsupported platform! (Not Win or Unix)")
7069
endif(WIN32)
7170

72-
add_executable(modbussim ${APP_SRCS} ${TESTSLAVE_SRCS})
71+
add_executable(${PROJECT_NAME} ${GUI_TYPE} ${APP_SRCS} ${TESTSLAVE_SRCS})
7372

74-
set_target_properties(modbussim PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
73+
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
74+
75+
target_link_libraries(${PROJECT_NAME} PRIVATE
76+
${SCOPESOURCE}
77+
${QT_LIB}
78+
)
7579

76-
target_link_libraries(modbussim ${QT_LIB})
80+
# Reset GUI type to blank
81+
set(GUI_TYPE "")
7782

7883
# Do platform specific post target stuff
7984
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
8085

81-
install(TARGETS modbussim RUNTIME DESTINATION bin)
86+
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
8287

8388
elseif(WIN32)
8489
# not required

scripts/build_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -ex
44
mkdir -p release
55
cd release
66

7-
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..
7+
cmake -GNinja ..
88
ninja

scripts/build_windows.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ mkdir release
55
cd release
66

77
echo %PATH%
8+
89
g++ -v
910

10-
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release ..
11+
cmake -G "Ninja" ..
1112
ninja
1213

14+
cd ..

scripts/deploy_linux.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
set -ex
33

44
# Copy assets
5-
cp misc/ModbusSim.desktop release/bin/linux/
6-
cp misc/ModbusSim.png release/bin/linux/
7-
cd release/bin/linux/
5+
cp misc/ModbusSim.desktop release/src/bin/linux/
6+
cp misc/icon-64x64.png release/src/bin/linux/ModbusSim.png
7+
cd release/src/bin/linux/
88

99
# now, build AppImage using linuxdeploy and linuxdeploy-plugin-qt
1010
# download linuxdeploy and its Qt plugin
@@ -15,6 +15,7 @@ wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/cont
1515
chmod +x linuxdeploy*.AppImage
1616

1717
# Generate AppImage
18+
export APPIMAGE_EXTRACT_AND_RUN=1 # Workaround because FUSE isn't available in Docker
1819
./linuxdeploy-x86_64.AppImage --appdir AppDir -e modbussim -i ModbusSim.png -d ModbusSim.desktop --plugin qt --output appimage
1920

2021
ls

scripts/deploy_windows.bat

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
echo on
22

3-
echo "Deploy ModbusSim ..."
3+
echo "Deploy ModbusScope ..."
44

5-
cd release\bin\win
6-
7-
echo %PATH%
85
g++ -v
96

10-
mkdir ModbusSim
11-
copy modbussim.exe ModbusSim
7+
cd release\src\bin\win
8+
IF ERRORLEVEL 1 GOTO errorHandling
9+
10+
set DEPLOY_DIR=deploy
11+
12+
mkdir %DEPLOY_DIR%
13+
copy modbussim.exe %DEPLOY_DIR%
14+
IF ERRORLEVEL 1 GOTO errorHandling
1215

13-
cd ModbusSim
16+
cd %DEPLOY_DIR%
1417
windeployqt.exe modbussim.exe --compiler-runtime -verbose 2
18+
IF ERRORLEVEL 1 GOTO errorHandling
1519

16-
REM Back to build dir
1720
cd ..
18-
7z a ModbusSim.zip ModbusSim
21+
7z a ModbusSim.zip ".\%DEPLOY_DIR%\*"
22+
IF ERRORLEVEL 1 GOTO errorHandling
23+
24+
EXIT
25+
26+
:errorHandling
27+
EXIT /B 1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
echo on
2+
3+
call scripts\setup_windows.bat %1
4+
call scripts\build_windows.bat
5+
call scripts\deploy_windows.bat

scripts/setup_windows.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
echo on
2+
3+
if "%~1"=="" (set "QT_INSTALL_DIR=D:\aqt_Qt\Qt") else (set "QT_INSTALL_DIR=%~1\Qt")
4+
echo QT_INSTALL_DIR: %QT_INSTALL_DIR%
5+
6+
REM Set configuration
7+
set QT=5.15.2
8+
set QT_MODULES=
9+
set QT_HOST=windows
10+
set QT_TARGET=desktop
11+
set QT_ARCH=win64_mingw81
12+
13+
set QT_ARCH_PATH=mingw81_64
14+
15+
REM Install Qt
16+
aqt install-qt --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% %QT% %QT_ARCH% -m %QT_MODULES%
17+
18+
REM Install Tools
19+
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_mingw qt.tools.win64_mingw810
20+
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_cmake
21+
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_ninja
22+
aqt install-tool --outputdir %QT_INSTALL_DIR% %QT_HOST% %QT_TARGET% tools_openssl_x64
23+
24+
REM Set env variables with path
25+
set "PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\bin;%PATH%"
26+
set "PATH=%QT_INSTALL_DIR%\Tools\mingw810_64\bin;%PATH%"
27+
set "PATH=%QT_INSTALL_DIR%\Tools\CMake_64\bin;%PATH%"
28+
set "PATH=%QT_INSTALL_DIR%\Tools\Ninja;%PATH%"
29+
30+
set "QT_PLUGIN_PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\plugins\"
31+
set "QML_IMPORT_PATH=%QT_INSTALL_DIR%\%QT%\%QT_ARCH_PATH%\qml\"
32+
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"
34+
35+
set "OPENSSL_DIR=%QT_INSTALL_DIR%\Tools\OpenSSL\Win_x64\bin"

0 commit comments

Comments
 (0)