-
Notifications
You must be signed in to change notification settings - Fork 1
234 lines (201 loc) · 9.24 KB
/
cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: Build QLiteHtmlBrowser
# Trigger the workflow on push or pull request,
# but only for the main branch
#name: CMake
#on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
#env:
# # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
# BUILD_TYPE: Release
#jobs:
# build:
# # The CMake configure and build commands are platform agnostic and should work equally
# # well on Windows or Mac. You can convert this to a matrix build if you need
# # cross-platform coverage.
# # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - name: Configure CMake
# # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
# - name: Build
# # Build your program with the given configuration
# run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
# - name: Test
# working-directory: ${{github.workspace}}/build
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C ${{env.BUILD_TYPE}}
on:
workflow_dispatch:
# push:
# branches:
# - master
push:
tags:
- "v*"
env:
PLUGIN_NAME: qlitehtmlbrowser
QT_VERSION: 5.15.2
BUILD_TYPE: Release
#NINJA_VERSION: 1.10.1
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
strategy:
matrix:
path:
- 'include'
- 'src'
- 'test'
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++ programs.
uses: jidicula/[email protected]
with:
clang-format-version: '17'
check-path: ${{ matrix.path }}
# fallback-style: 'LLVM'
build:
needs: formatting-check
name: Build ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
outputs:
qt_url: ${{ steps.qt.outputs.qt_base_url }}
strategy:
matrix:
config:
- {
name: "Windows Latest MSVC", artifact: "Windows",
os: windows-latest,
cc: "cl", cxx: "cl",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
}
- {
name: "Ubuntu Latest GCC", artifact: "Linux",
os: ubuntu-latest,
cc: "gcc", cxx: "g++"
}
#- {
# name: "Ubuntu Latest CLANG", artifact: "Linux",
# os: ubuntu-latest,
# cc: "clang", cxx: "clang++"
#}
#- {
# name: "macOS Latest Clang", artifact: "macOS",
# os: macos-latest,
# cc: "clang", cxx: "clang++"
#}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install system libs
shell: cmake -P {0}
run: |
if ("${{ runner.os }}" STREQUAL "Linux")
execute_process(
COMMAND sudo apt update
)
execute_process(
COMMAND sudo apt install libgl1-mesa-dev
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to install dependencies")
endif()
endif()
- name: Download Qt
id: qt
shell: cmake -P {0}
run: |
set(qt_version "$ENV{QT_VERSION}")
string(REPLACE "." "" qt_version_dotless "${qt_version}")
if ("${{ runner.os }}" STREQUAL "Windows")
set(url_os "windows_x86")
set(qt_package_arch_suffix "win64_msvc2019_64")
set(qt_dir_prefix "${qt_version}/msvc2019_64")
set(qt_package_suffix "-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(url_os "linux_x64")
set(qt_package_arch_suffix "gcc_64")
set(qt_dir_prefix "${qt_version}/gcc_64")
set(qt_package_suffix "-Linux-RHEL_7_6-GCC-Linux-RHEL_7_6-X86_64")
elseif ("${{ runner.os }}" STREQUAL "macOS")
set(url_os "mac_x64")
set(qt_package_arch_suffix "clang_64")
set(qt_dir_prefix "${qt_version}/clang_64")
set(qt_package_suffix "-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64")
endif()
file(MAKE_DIRECTORY build-qt5)
set(qt_base_url "https://download.qt.io/online/qtsdkrepository/${url_os}/desktop/qt5_${qt_version_dotless}")
file(DOWNLOAD "${qt_base_url}/Updates.xml" ./build-qt5/Updates.xml SHOW_PROGRESS)
file(READ ./build-qt5/Updates.xml updates_xml)
string(REGEX MATCH "<Name>qt.qt5.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}")
set(qt_package_version ${CMAKE_MATCH_1})
# Save the path for other steps
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/build-qt5/${qt_dir_prefix}" qt_dir)
#message("\"qt_dir=${qt_dir}\" >> $GITHUB_OUTPUT")
file(APPEND "$ENV{GITHUB_OUTPUT}" "qt_dir=${qt_dir}\n")
message("Downloading Qt to ${qt_dir}")
function(downloadAndExtract url archive)
message("Downloading ${url}")
file(DOWNLOAD "${url}" ./build-qt5/${archive} SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ${archive} WORKING_DIRECTORY build-qt5)
endfunction()
# qtdeclarative qttools qtsvg qtxmlpatterns
foreach(package qtbase qttools )
downloadAndExtract(
"${qt_base_url}/qt.qt5.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}.7z"
${package}.7z
)
endforeach()
# uic depends on libicu56.so
if ("${{ runner.os }}" STREQUAL "Linux")
downloadAndExtract(
"${qt_base_url}/qt.qt5.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}icu-linux-Rhel7.2-x64.7z"
icu.7z
)
endif()
# message("::set-output name=qt_base_url::${qt_base_url}")
# message("\"qt_base_url::${qt_base_url}\" >> $GITHUB_OUTPUT")
file(APPEND "$ENV{GITHUB_OUTPUT}" "qt_base_url::${qt_base_url}\n")
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cmake --version
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
env:
Qt5_DIR: ${{ steps.qt.outputs.qt_dir}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
shell: cmake -P {0}
run: |
execute_process(COMMAND ctest -C ${{env.BUILD_TYPE}} -E NOT_BUILT --verbose
WORKING_DIRECTORY build
RESULT_VARIABLE result
COMMAND_ECHO STDOUT
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "running tests failed")
endif()
env:
QT_QPA_PLATFORM: offscreen
Qt5_DIR: ${{ steps.qt.outputs.qt_dir}}
- name: Deploy
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: |
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target dist-source