-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (126 loc) · 6.54 KB
/
iwyu.yml
File metadata and controls
147 lines (126 loc) · 6.54 KB
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
#
# Copyright 2025 Antony Peacock
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
name: Include What You Use
on: workflow_dispatch
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug
COMPILER_TYPE: clang
COMPILER_VERSION: 19
STDLIB: libc++
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: ${{ matrix.os }}
strategy:
matrix:
os: [ "ubuntu-latest" ]
steps:
- uses: actions/checkout@v4.2.2
- name: Cache Conan data
uses: actions/cache@v4.2.2
env:
cache-name: cache-conan-data
with:
path: ${{github.workspace}}/conan_cache_save.tgz
key: ${{ hashFiles('**/conanfile.py') }}-build-${{ matrix.os }}-${{ env.BUILD_TYPE }}-${{ env.COMPILER_TYPE }}-${{ env.COMPILER_VERSION }}-${{ env.STDLIB }}
restore-keys: |
${{ hashFiles('**/conanfile.py') }}-build-${{ matrix.os }}-${{ env.BUILD_TYPE }}-${{ env.COMPILER_TYPE }}-${{ env.COMPILER_VERSION }}-
${{ hashFiles('**/conanfile.py') }}-build-${{ matrix.os }}-${{ env.BUILD_TYPE }}-${{ env.COMPILER_TYPE }}-
${{ hashFiles('**/conanfile.py') }}-build-${{ matrix.os }}-${{ env.BUILD_TYPE }}-
${{ hashFiles('**/conanfile.py') }}-build-${{ matrix.os }}-
- name: Install Clang
shell: bash
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ env.COMPILER_VERSION }} all
- name: Install Libc++
shell: bash
run: |
sudo apt install -y libc++-${{ env.COMPILER_VERSION }}-dev libc++abi-${{ env.COMPILER_VERSION }}-dev libunwind-${{env.COMPILER_VERSION }}-dev
- name: Install build dependencies and IWYU
run: |
sudo apt update
sudo apt install -y clang llvm-dev cmake git ninja-build libcurl4-openssl-dev libedit-dev
# Build and install IWYU
git clone https://github.com/include-what-you-use/include-what-you-use.git
cd include-what-you-use
git checkout clang_${{ env.COMPILER_VERSION }}
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${{ env.COMPILER_VERSION }} -DCMAKE_BUILD_TYPE=Release
cmake --build build
sudo cmake --install build
- name: Set up Python
uses: actions/setup-python@v5.4.0
with:
python-version: '3.13'
- name: Install Python requirements
run: |
pip install -r ./requirements.txt
- name: Configure Conan
shell: bash
run: |
conan profile detect --force
sed -i.backup '/^\[settings\]$/,/^\[/ s/^compiler.cppstd=.*/compiler.cppstd=23/' .conan2/profiles/default
sed -i.backup '/^\[settings\]$/,/^\[/ s/^build_type=.*/build_type=${{ env.BUILD_TYPE }}/' .conan2/profiles/default
sed -i.backup '/^\[settings\]$/,/^\[/ s/^compiler=.*/compiler=${{ env.COMPILER_TYPE }}/' .conan2/profiles/default
sed -i.backup '/^\[settings\]$/,/^\[/ s/^compiler.version=.*/compiler.version=${{ env.COMPILER_VERSION }}/' .conan2/profiles/default
sed -i.backup '/^\[settings\]$/,/^\[/ s/^compiler.libcxx=.*/compiler.libcxx=${{ env.STDLIB }}/' .conan2/profiles/default
sed -i.backup '1a mold*:build_type=Release' .conan2/profiles/default
sed -i.backup '1a onetbb*:build_type=Release' .conan2/profiles/default
sed -i.backup '1a mold*:compiler.libcxx=libstdc++11' .conan2/profiles/default
echo -e "\n[options]" >> .conan2/profiles/default
sed -i.backup '/^\[options\]/a date*:tz_db=system' .conan2/profiles/default
cat >> .conan2/global.conf <<EOF
tools.cmake.cmaketoolchain:generator = Ninja
tools.system.package_manager:mode = install
tools.system.package_manager:sudo = True
tools.build:compiler_executables = {"c": "clang-$COMPILER_VERSION", "cpp": "clang++-$COMPILER_VERSION"}
EOF
conan profile show -pr default
- name: Conan Cache Restore
shell: bash
run: |
if [ -f ./conan_cache_save.tgz ]; then
conan cache restore ./conan_cache_save.tgz
fi
- name: Configure Install
working-directory: ${{github.workspace}}
shell: bash
run: |
conan install "${{github.workspace}}" --build missing
- name: Conan Preset
shell: bash
run: echo "CONAN_PRESET=conan-$(echo ${{env.BUILD_TYPE}} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- 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: |
source build/${{env.BUILD_TYPE}}/generators/conanbuild.sh
cmake --preset ${{ env.CONAN_PRESET }} -DIWYU_ENABLE=1
- name: Build
# Build your program with the given configuration
run: |
source build/${{env.BUILD_TYPE}}/generators/conanbuild.sh
cmake --build --preset ${{ env.CONAN_PRESET }}
- name: Conan Cache Save
run: |
conan cache clean
conan cache save "*/*:*"