Skip to content

Commit 54d6215

Browse files
authored
scan GUI sources with clang-tidy in CI (#3233)
* build UI dependencies before running clang-tidy * clang-tidy.yml: enabled GUI sources and build some dependencies for clang-tidy * work around missing dependency for Qt install step
1 parent df59b07 commit 54d6215

4 files changed

Lines changed: 21 additions & 9 deletions

File tree

.github/workflows/clang-tidy.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,30 @@ jobs:
2121
apt-get install -y cmake g++ make
2222
apt-get install -y z3 libz3-dev
2323
apt-get install -y libpcre3-dev
24+
apt-get install -y libffi7 # work around missing dependency for Qt install step
2425
apt-get install -y software-properties-common
2526
add-apt-repository universe
2627
apt-get update
2728
apt-get install -y clang-tidy-13
2829
29-
# uses "sudo" internally which is not available on docker by default
30-
#- name: Install Qt
31-
# uses: jurplel/install-qt-action@v2
32-
# with:
33-
# modules: 'qtcharts'
30+
- name: Install Qt
31+
uses: jurplel/install-qt-action@v2
32+
with:
33+
install-deps: 'nosudo'
34+
version: '5.15.2'
35+
modules: 'qtcharts'
3436

3537
- name: Prepare CMake
3638
run: |
3739
mkdir cmake.output
3840
cd cmake.output
39-
# cannot include GUI since we need to generate the ui_*.h files first
40-
cmake -G "Unix Makefiles" -DUSE_Z3=On -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off ..
41+
cmake -G "Unix Makefiles" -DUSE_Z3=On -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On ..
4142
cd ..
4243
4344
- name: Clang-Tidy
4445
run: |
4546
# make sure the precompiled headers exist
4647
make -C cmake.output lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
4748
make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx
49+
make -C cmake.output autogen
4850
cmake --build cmake.output --target run-clang-tidy 2> /dev/null

cmake/clang_tidy.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ message(STATUS "RUN_CLANG_TIDY=${RUN_CLANG_TIDY}")
1212
if (RUN_CLANG_TIDY)
1313
# disable all compiler warnings since we are just interested in the tidy ones
1414
add_custom_target(run-clang-tidy ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -extra-arg=-w -quiet)
15+
if (BUILD_GUI)
16+
add_dependencies(run-clang-tidy gui-build-deps)
17+
if (BUILD_TESTS)
18+
add_dependencies(run-clang-tidy triage-build-ui-deps)
19+
endif()
20+
endif()
1521
endif()

gui/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ if (BUILD_GUI)
1515
QT5_WRAP_UI(uis_hdrs ${uis})
1616
QT5_ADD_RESOURCES(resources "gui.qrc")
1717
QT5_ADD_TRANSLATION(qms ${tss})
18-
list(APPEND cppcheck-gui_SOURCES ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
18+
list(APPEND cppcheck-gui-deps ${hdrs} ${uis_hdrs} ${resources} ${qms} )
19+
add_custom_target(gui-build-deps SOURCES ${cppcheck-gui-deps})
20+
21+
list(APPEND cppcheck-gui_SOURCES ${srcs} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
1922
if(USE_BUNDLED_TINYXML2)
2023
list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
2124
endif()
2225

23-
add_executable(cppcheck-gui ${cppcheck-gui_SOURCES})
26+
add_executable(cppcheck-gui ${cppcheck-gui-deps} ${cppcheck-gui_SOURCES})
2427
set_target_properties(cppcheck-gui PROPERTIES AUTOMOC ON)
2528
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
2629
if(USE_BUNDLED_TINYXML2)

tools/triage/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if (BUILD_GUI AND BUILD_TESTS)
1212
file(GLOB uis "*.ui")
1313
qt5_wrap_ui(uis_hdrs ${uis})
1414

15+
add_custom_target(triage-build-ui-deps SOURCES ${hdrs} ${uis_hdrs})
1516
add_executable(
1617
triage
1718
${hdrs}

0 commit comments

Comments
 (0)