Skip to content

Commit b8b6a30

Browse files
authored
Merge pull request #264 from eseiler/infra/iwyu
[INFRA] use seqan/actions/iwyu
2 parents 1df6a31 + 901ad55 commit b8b6a30

File tree

17 files changed

+53
-1079
lines changed

17 files changed

+53
-1079
lines changed

.github/workflows/ci_iwyu.yml

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -26,87 +26,14 @@ jobs:
2626
runs-on: ubuntu-latest
2727
if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch'
2828
container:
29-
image: ghcr.io/seqan/clang-18
29+
image: ghcr.io/seqan/clang-19
3030
volumes:
3131
- /home/runner:/home/runner
3232
steps:
33-
- name: Checkout
34-
uses: actions/checkout@v4
33+
- name: Run IWYU
34+
uses: seqan/actions/iwyu@main
3535
with:
36-
path: hibf
36+
configure_path: test/all
3737
token: ${{ secrets.SEQAN_ACTIONS_PAT }}
38-
39-
- name: Build IWYU
40-
run: |
41-
mkdir iwyu && cd iwyu
42-
git clone https://github.com/include-what-you-use/include-what-you-use.git --branch 0.22
43-
mkdir build && cd build
44-
cmake ../include-what-you-use -G "Unix Makefiles" \
45-
-DCMAKE_BUILD_TYPE=Release \
46-
-DCMAKE_INSTALL_PREFIX=/usr \
47-
-DCMAKE_PREFIX_PATH=/usr/lib/llvm-18 \
48-
-DCMAKE_C_COMPILER=clang-18 \
49-
-DCMAKE_CXX_COMPILER=clang++-18
50-
make -j
51-
make install
52-
53-
- name: Configure Test
54-
run: |
55-
mkdir build && cd build
56-
cmake ../hibf/test/iwyu -DCMAKE_BUILD_TYPE=Debug
57-
58-
- name: Run Test
59-
working-directory: build
60-
run: |
61-
ccache -z
62-
make -j 2> out.txt
63-
ccache -sv
64-
65-
- name: Apply changes
66-
working-directory: build
67-
run: |
68-
fix_includes.py --nosafe_headers \
69-
--comments \
70-
--noreorder \
71-
--ignore_re ".*/include/hibf/contrib/.*" < out.txt
72-
73-
- name: Add changes
74-
id: changed_files
75-
working-directory: hibf
76-
run: |
77-
git add .
78-
CPP_LIST=$(git diff --name-only HEAD | { grep -E "(\.cpp|\.hpp)$" || test $? = 1; } | xargs)
79-
echo "cpp_list=$CPP_LIST" >> $GITHUB_OUTPUT
80-
81-
- name: Run clang-format
82-
if: ${{ steps.changed_files.outputs.cpp_list }}
83-
working-directory: hibf
84-
run: |
85-
clang-format-18 --style=file -i ${{ steps.changed_files.outputs.cpp_list }}
86-
git add .
87-
88-
- name: Import GPG key
89-
if: ${{ steps.changed_files.outputs.cpp_list }}
90-
uses: crazy-max/ghaction-import-gpg@v6
91-
with:
92-
gpg_private_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }}
93-
passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }}
94-
git_user_signingkey: true
95-
git_commit_gpgsign: true
96-
workdir: hibf
97-
98-
- name: Open PR
99-
if: ${{ steps.changed_files.outputs.cpp_list }}
100-
uses: peter-evans/create-pull-request@v7
101-
with:
102-
token: ${{ secrets.SEQAN_ACTIONS_PAT }}
103-
path: hibf
104-
commit-message: "[MISC] IWYU"
105-
committer: "seqan-actions[bot] <seqan-actions@users.noreply.github.com>"
106-
author: "seqan-actions[bot] <seqan-actions@users.noreply.github.com>"
107-
branch: "actions/iwyu"
108-
delete-branch: true
109-
title: "[MISC] IWYU"
110-
body: "Auto-generated include-what-you-use changes"
111-
112-
38+
gpg_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }}
39+
gpg_passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }}

cmake/configuration.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ else ()
246246
endif ()
247247
endif ()
248248

249-
check_ipo_supported (RESULT HIBF_HAS_LTO OUTPUT HIBF_HAS_LTO_OUTPUT)
249+
check_ipo_supported (
250+
RESULT HIBF_HAS_LTO
251+
OUTPUT HIBF_HAS_LTO_OUTPUT
252+
LANGUAGES CXX)
250253
cmake_dependent_option (HIBF_LTO_BUILD "Use Link Time Optimisation." ON "HIBF_HAS_LTO" OFF)
251254
cmake_dependent_option (HIBF_DEV_CHECK_LTO "LTO check." ON
252255
"HIBF_LTO_BUILD;NOT HIBF_IS_TOP_LEVEL;NOT CMAKE_INTERPROCEDURAL_OPTIMIZATION" OFF)
@@ -257,7 +260,7 @@ if (HIBF_DEV_CHECK_LTO)
257260
" Add the following at the beginning of your CMakeLists.txt:\n"
258261
" ```\n"
259262
" include (CheckIPOSupported)\n"
260-
" check_ipo_supported (RESULT result OUTPUT output)\n"
263+
" check_ipo_supported (RESULT result OUTPUT output LANGUAGES CXX)\n"
261264
" if (result)\n"
262265
" set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)\n"
263266
" endif ()\n"

cmake/hibf-config.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ else ()
2828
find_dependency (simde @HIBF_SIMDE_VERSION@ REQUIRED)
2929
endif ()
3030

31-
check_ipo_supported (RESULT HIBF_HAS_LTO OUTPUT HIBF_HAS_LTO_OUTPUT)
31+
check_ipo_supported (RESULT HIBF_HAS_LTO OUTPUT HIBF_HAS_LTO_OUTPUT LANGUAGES CXX)
3232
cmake_dependent_option (HIBF_DEV_CHECK_LTO "LTO check." ON "HIBF_HAS_LTO;NOT CMAKE_INTERPROCEDURAL_OPTIMIZATION" OFF)
3333

3434
if (HIBF_DEV_CHECK_LTO)
@@ -37,7 +37,7 @@ if (HIBF_DEV_CHECK_LTO)
3737
" Add the following at the beginning of your CMakeLists.txt:\n"
3838
" ```\n"
3939
" include (CheckIPOSupported)\n"
40-
" check_ipo_supported (RESULT result OUTPUT output)\n"
40+
" check_ipo_supported (RESULT result OUTPUT output LANGUAGES CXX)\n"
4141
" if (result)\n"
4242
" set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)\n"
4343
" endif ()\n"

include/hibf/platform.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99

1010
#pragma once
1111

12+
// IWYU pragma: always_keep
13+
// IWYU pragma: begin_exports
14+
1215
#include <version> // for __cpp_lib_constexpr_vector
1316

17+
// IWYU pragma: end_exports
18+
1419
// macro cruft
1520
//!\cond
1621
#define HIBF_STR_HELPER(x) #x

include/hibf/version.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
#pragma once
66

7-
#include <cstddef> // for size_t
8-
#include <cstdint> // for uint8_t
7+
// IWYU pragma: always_keep
8+
9+
#include <cinttypes> // for uint8_t
10+
#include <cstddef> // for size_t
911

1012
/*!\file
1113
* \brief Provides version macros and global variables.

test/cmake/hibf_require_ccache.cmake

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik
33
# SPDX-License-Identifier: BSD-3-Clause
44

5-
cmake_minimum_required (VERSION 3.20...3.31)
5+
cmake_minimum_required (VERSION 3.21...3.31)
66

77
include (FindPackageMessage)
88

@@ -12,36 +12,29 @@ include (FindPackageMessage)
1212
# * https://ccache.dev/
1313
# * https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html
1414
macro (hibf_require_ccache)
15-
set (HIBF_USE_CCACHE
16-
ON
17-
CACHE BOOL "Use ccache if available.")
18-
set (HIBF_FPROFILE_ABS_PATH "-fprofile-abs-path")
19-
if (HIBF_USE_CCACHE)
15+
option (USE_CCACHE "Use ccache if available." ON)
16+
17+
if (USE_CCACHE)
2018
find_program (CCACHE_PROGRAM ccache)
2119

2220
if (NOT CCACHE_PROGRAM)
23-
find_package_message (CCACHE_PROGRAM " Ccache program: not available" "[${CCACHE_PROGRAM}]")
21+
find_package_message (CCACHE_PROGRAM "  Ccache program: not available" "[${CCACHE_PROGRAM}]")
2422
else ()
25-
find_package_message (CCACHE_PROGRAM " Ccache program: available" "[${CCACHE_PROGRAM}]")
26-
set (HIBF_FPROFILE_ABS_PATH "--ccache-skip -fprofile-abs-path")
27-
# New option since cmake >= 3.4:
28-
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html
29-
if (NOT CMAKE_VERSION VERSION_LESS 3.15) # cmake >= 3.15
30-
list (PREPEND CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
31-
list (PREPEND CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
32-
else ()
33-
# prepend ccache to CMAKE_CXX_COMPILER_LAUNCHER
34-
list (INSERT CMAKE_CXX_COMPILER_LAUNCHER 0 "${CCACHE_PROGRAM}")
35-
list (INSERT CMAKE_C_COMPILER_LAUNCHER 0 "${CCACHE_PROGRAM}")
36-
endif ()
23+
find_package_message (CCACHE_PROGRAM "  Ccache program: available" "[${CCACHE_PROGRAM}]")
24+
25+
set (CMAKE_CXX_COMPILER_LAUNCHER
26+
"${CCACHE_PROGRAM}"
27+
CACHE INTERNAL "")
28+
set (CMAKE_C_COMPILER_LAUNCHER
29+
"${CCACHE_PROGRAM}"
30+
CACHE INTERNAL "")
3731

38-
if (NOT CMAKE_VERSION VERSION_LESS 3.21) # cmake >= 3.21
39-
list (PREPEND CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_PROGRAM}")
40-
list (PREPEND CMAKE_C_LINKER_LAUNCHER "${CCACHE_PROGRAM}")
41-
else ()
42-
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")
43-
endif ()
32+
set (CMAKE_CXX_LINKER_LAUNCHER
33+
"${CCACHE_PROGRAM}"
34+
CACHE INTERNAL "")
35+
set (CMAKE_C_LINKER_LAUNCHER
36+
"${CCACHE_PROGRAM}"
37+
CACHE INTERNAL "")
4438
endif ()
45-
unset (CCACHE_PROGRAM)
4639
endif ()
4740
endmacro ()

test/hibf-test.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ cmake_minimum_required (VERSION 3.20...3.31)
1414
option (HIBF_BENCHMARK_ALIGN_LOOPS "Pass -falign-loops=32 to the benchmark builds." ON)
1515

1616
include (CheckIPOSupported)
17-
check_ipo_supported (RESULT HIBF_TEST_HAS_LTO OUTPUT HIBF_TEST_HAS_LTO_OUTPUT)
17+
check_ipo_supported (
18+
RESULT HIBF_TEST_HAS_LTO
19+
OUTPUT HIBF_TEST_HAS_LTO_OUTPUT
20+
LANGUAGES CXX)
1821
if (HIBF_TEST_HAS_LTO)
1922
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
2023
endif ()

test/iwyu/CMakeLists.txt

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)