Skip to content

Commit 8f7770f

Browse files
authored
added an include-what-you-use GitHub Action (cppcheck-opensource#3759)
1 parent 0807924 commit 8f7770f

14 files changed

Lines changed: 83 additions & 17 deletions

.github/workflows/iwyu.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
2+
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
3+
name: include-what-you-use
4+
5+
on: workflow_dispatch
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-20.04
11+
12+
container:
13+
image: "kalilinux/kali-rolling"
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
# TODO: the necessary packages are excessive - mostly because of Qt - use a pre-built image
19+
- name: Install missing software
20+
run: |
21+
apt-get update
22+
apt-get install -y cmake g++ make libz3-dev libpcre3-dev
23+
apt-get install -y qtbase5-dev qttools5-dev libqt5charts5-dev
24+
apt-get install -y wget iwyu
25+
26+
- name: Prepare CMake
27+
run: |
28+
mkdir cmake.output
29+
cd cmake.output
30+
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -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 -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off ..
31+
cd ..
32+
33+
- name: Prepare CMake dependencies
34+
run: |
35+
# make sure the precompiled headers exist
36+
#make -C cmake.output lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
37+
#make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx
38+
# make sure the auto-generated GUI sources exist
39+
make -C cmake.output autogen
40+
# make sure the auto-generated GUI dependencies exist
41+
make -C cmake.output gui-build-deps
42+
43+
- name: Build Qt mappings
44+
run: |
45+
wget https://raw.githubusercontent.com/include-what-you-use/include-what-you-use/master/mapgen/iwyu-mapgen-qt.py
46+
python3 iwyu-mapgen-qt.py /usr/include/x86_64-linux-gnu/qt5/ > qt5.imp
47+
48+
# TODO: the mapping file causes a massive slowdown so we cannot use it at the moment.
49+
# add "-Xiwyu --mapping_file=qt5.imp" at the end of the whole command if we can use them.
50+
- name: iwyu_tool
51+
run: |
52+
# do not fail for now so the output is being saved
53+
iwyu_tool -p cmake.output -j $(nproc) -- -w > iwyu.log || true
54+
55+
- uses: actions/upload-artifact@v2
56+
with:
57+
name: Qt Mappings
58+
path: ./qt5.imp
59+
60+
- uses: actions/upload-artifact@v2
61+
with:
62+
name: Logs
63+
path: ./*.log

cli/cppcheckexecutor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
# include <ucontext.h>
6363
#endif
6464
#ifdef __linux__
65-
#include <sys/syscall.h>
66-
#include <sys/types.h>
65+
#include <syscall.h>
6766
#endif
6867
#endif
6968

cli/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@
5959
*/
6060

6161

62-
#include "errortypes.h"
6362
#include "cppcheckexecutor.h"
6463

64+
#ifdef NDEBUG
65+
#include "errortypes.h"
66+
6567
#include <cstdlib>
6668
#include <exception>
67-
#include <string>
68-
69-
#ifdef NDEBUG
7069
#include <iostream>
70+
#include <string>
7171
#endif
7272

7373
#ifdef _WIN32

cli/threadexecutor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,18 @@
3838
#ifdef __SVR4 // Solaris
3939
#include <sys/loadavg.h>
4040
#endif
41+
4142
#ifdef THREADING_MODEL_FORK
4243
#if defined(__linux__)
4344
#include <sys/prctl.h>
4445
#endif
4546
#include <sys/select.h>
4647
#include <sys/wait.h>
4748
#include <fcntl.h>
49+
#include <csignal>
4850
#include <unistd.h>
4951
#endif
52+
5053
#ifdef THREADING_MODEL_WIN
5154
#include <future>
5255
#include <numeric>

externals/simplecpp/simplecpp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
#include <cstdlib>
2828
#include <cstring>
2929
#include <exception>
30-
#include <fstream>
30+
#include <fstream> // IWYU pragma: keep
3131
#include <iostream>
3232
#include <limits>
33-
#include <sstream>
33+
#include <sstream> // IWYU pragma: keep
3434
#include <stack>
3535
#include <stdexcept>
36+
#include <type_traits>
3637
#include <utility>
3738

3839
#ifdef SIMPLECPP_WINDOWS

lib/analyzerinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <tinyxml2.h>
2626
#include <cstring>
2727
#include <map>
28-
#include <sstream>
28+
#include <sstream> // IWYU pragma: keep
2929

3030
AnalyzerInformation::~AnalyzerInformation()
3131
{

lib/checkother.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include <memory>
4141
#include <ostream>
4242
#include <set>
43-
#include <type_traits>
4443
#include <utility>
4544
#include <numeric>
4645

lib/color.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <unistd.h>
2323
#endif
2424
#include <cstddef>
25-
#include <sstream>
25+
#include <sstream> // IWYU pragma: keep
2626

2727
#ifdef _WIN32
2828
std::ostream& operator<<(std::ostream& os, const Color& /*c*/)

lib/errorlogger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "path.h"
2525
#include "token.h"
2626
#include "tokenlist.h"
27+
#include "utils.h"
2728

2829
#include <algorithm>
2930
#include <array>

lib/importproject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <algorithm>
3030
#include <cstdlib>
3131
#include <cstring>
32-
#include <fstream>
32+
#include <fstream> // IWYU pragma: keep
3333
#include <iostream>
3434
#include <iterator>
3535

0 commit comments

Comments
 (0)