Skip to content

Commit ee6252d

Browse files
authored
refs #13614 - iwyu.yml: run include-what-you-use on macOS [skip ci] (danmar#7275)
1 parent ba73164 commit ee6252d

File tree

1 file changed

+103
-11
lines changed

1 file changed

+103
-11
lines changed

.github/workflows/iwyu.yml

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
image: ["fedora:latest"] # "opensuse/tumbleweed:latest" / "fedora:latest" / "debian:unstable" / "archlinux:latest"
19-
stdlib: [libstdc++, libc++]
18+
# "opensuse/tumbleweed:latest" / "fedora:latest" / "debian:unstable" / "archlinux:latest"
2019
include:
21-
- stdlib: libstdc++
22-
use_libcxx: Off
23-
- stdlib: libc++
24-
use_libcxx: On
20+
- os: ubuntu-22.04
21+
image: "fedora:latest"
22+
stdlib: libstdc++
23+
- os: ubuntu-22.04
24+
image: "fedora:latest"
25+
stdlib: libc++
26+
- os: macos-13
27+
image: ""
28+
stdlib: libc++ # no libstdc++ on macOS
2529
fail-fast: false
2630

27-
runs-on: ubuntu-22.04
31+
runs-on: ${{ matrix.os }}
2832
if: ${{ github.repository_owner == 'danmar' }}
2933

3034
container:
@@ -84,6 +88,13 @@ jobs:
8488
zypper install -y include-what-you-use-tools
8589
ln -s iwyu_tool.py /usr/bin/iwyu_tool
8690
91+
# coreutils contains "nproc"
92+
- name: Install missing software on macOS
93+
if: contains(matrix.os, 'macos')
94+
run: |
95+
brew install include-what-you-use pcre coreutils
96+
ln -s iwyu_tool.py /usr/local/bin/iwyu_tool
97+
8798
# Fails on OpenSUSE:
8899
# Warning: Failed to restore: Tar failed with error: Unable to locate executable file: tar. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
89100
# Also the shell is broken afterwards:
@@ -99,7 +110,7 @@ jobs:
99110
- name: Prepare CMake
100111
run: |
101112
# TODO: why does it build dmake in the next step?
102-
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off -DEXTERNALS_AS_SYSTEM=On -DUSE_LIBCXX=${{ matrix.use_libcxx }}
113+
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off -DEXTERNALS_AS_SYSTEM=On -DUSE_LIBCXX=${{ matrix.stdlib == 'libc++' }}
103114
env:
104115
CC: clang
105116
CXX: clang++
@@ -121,21 +132,102 @@ jobs:
121132
122133
- name: iwyu_tool
123134
run: |
124-
PWD=$(pwd)
125135
# -isystem/usr/lib/clang/17/include
126136
# TODO: remove -stdlib= - it should have been taken from the compilation database
127137
iwyu_tool -p cmake.output -j $(nproc) -- -w -Xiwyu --max_line_length=1024 -Xiwyu --comment_style=long -Xiwyu --quoted_includes_first -Xiwyu --update_comments -stdlib=${{ matrix.stdlib }} > iwyu.log
128138
129139
- uses: actions/upload-artifact@v4
130140
if: success() || failure()
131141
with:
132-
name: Compilation Database (include-what-you-use - ${{ matrix.stdlib }})
142+
name: Compilation Database (include-what-you-use - ${{ matrix.os }} ${{ matrix.stdlib }})
143+
path: ./cmake.output/compile_commands.json
144+
145+
- uses: actions/upload-artifact@v4
146+
if: success() || failure()
147+
with:
148+
name: Logs (include-what-you-use - ${{ matrix.os }} ${{ matrix.stdlib }})
149+
path: ./*.log
150+
151+
clang-include-cleaner:
152+
153+
strategy:
154+
matrix:
155+
stdlib: [libstdc++, libc++]
156+
fail-fast: false
157+
158+
runs-on: ubuntu-22.04
159+
if: ${{ github.repository_owner == 'danmar' }}
160+
161+
env:
162+
QT_VERSION: 6.8.1
163+
164+
steps:
165+
- uses: actions/checkout@v4
166+
with:
167+
persist-credentials: false
168+
169+
- name: Install missing software
170+
run: |
171+
sudo apt-get update
172+
sudo apt-get install -y cmake make libpcre3-dev
173+
sudo apt-get install -y libgl-dev # missing dependency for using Qt in CMake
174+
175+
- name: Install clang
176+
run: |
177+
sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14
178+
wget https://apt.llvm.org/llvm.sh
179+
chmod +x llvm.sh
180+
sudo ./llvm.sh 19
181+
sudo apt-get install -y clang-tools-19
182+
183+
- name: Install libc++
184+
if: matrix.stdlib == 'libc++'
185+
run: |
186+
sudo apt-get install -y libc++-19-dev
187+
188+
- name: Install Qt ${{ env.QT_VERSION }}
189+
uses: jurplel/install-qt-action@v4
190+
with:
191+
version: ${{ env.QT_VERSION }}
192+
modules: 'qtcharts'
193+
install-deps: false
194+
cache: true
195+
196+
- name: Prepare CMake
197+
run: |
198+
# TODO: why does it build dmake in the next step?
199+
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off -DEXTERNALS_AS_SYSTEM=On -DUSE_LIBCXX=${{ matrix.stdlib == 'libc++' }}
200+
env:
201+
CC: clang-19
202+
CXX: clang++-19
203+
204+
- name: Prepare CMake dependencies
205+
run: |
206+
# make sure the auto-generated GUI sources exist
207+
make -C cmake.output autogen
208+
# make sure the precompiled headers exist
209+
#make -C cmake.output/cli cmake_pch.hxx.pch
210+
#make -C cmake.output/gui cmake_pch.hxx.pch
211+
#make -C cmake.output/lib cmake_pch.hxx.pch
212+
#make -C cmake.output/test cmake_pch.hxx.pch
213+
# make sure the auto-generated GUI dependencies exist
214+
make -C cmake.output gui-build-deps
215+
216+
- name: clang-include-cleaner
217+
run: |
218+
# TODO: run multi-threaded
219+
find $PWD/cli $PWD/lib $PWD/test $PWD/gui -maxdepth 1 -name "*.cpp" | xargs -t -n 1 clang-include-cleaner-19 --print=changes --extra-arg=-w --extra-arg=-stdlib=${{ matrix.stdlib }} -p cmake.output > clang-include-cleaner.log 2>&1
220+
221+
- uses: actions/upload-artifact@v4
222+
if: success() || failure()
223+
with:
224+
name: Compilation Database (clang-include-cleaner - ${{ matrix.stdlib }})
133225
path: ./cmake.output/compile_commands.json
134226

135227
- uses: actions/upload-artifact@v4
136228
if: success() || failure()
137229
with:
138-
name: Logs (include-what-you-use - ${{ matrix.stdlib }})
230+
name: Logs (clang-include-cleaner - ${{ matrix.stdlib }})
139231
path: ./*.log
140232

141233
clang-include-cleaner:

0 commit comments

Comments
 (0)