Skip to content

Commit 098ae9a

Browse files
authored
Merge pull request #19 from StephanKa/feature/add-example-for-static-analysis
Added example for static analysis
2 parents bd9d84c + a9228dd commit 098ae9a

6 files changed

Lines changed: 95 additions & 268 deletions

File tree

.github/workflows/build_cmake.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,60 @@ jobs:
8181
- name: Test
8282
shell: bash
8383
run: ctest --preset test-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}
84+
85+
linux-static_analysis:
86+
name: Static Analysis, ${{ matrix.os }}, ${{ matrix.compiler.name }}, ${{ matrix.buildtype }}
87+
runs-on: ${{ matrix.os }}
88+
strategy:
89+
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix entry fails.
90+
matrix:
91+
os: [ubuntu-22.04]
92+
buildtype: [debug]
93+
compiler: [{name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15 llvm-15-dev libclang-15-dev', iwyu_branch: 'clang_15', path_prefix: "/usr/lib/llvm-15"}]
94+
95+
steps:
96+
- uses: actions/checkout@v3
97+
98+
- name: Cache
99+
uses: actions/cache@v3
100+
env:
101+
cache-name: cache-conan-modules
102+
with:
103+
path: |
104+
${{ env.CONAN_USER_HOME }}
105+
~/.cache/pip
106+
key: ${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('cmake/Conan.cmake') }}
107+
108+
- name: Install conan
109+
shell: bash
110+
run: |
111+
python3 -m pip install --upgrade pip setuptools conan==1.59
112+
source ~/.profile
113+
114+
- name: Install dependencies
115+
run: |
116+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
117+
sudo apt update
118+
sudo apt install ninja-build ${{ matrix.compiler.pkgs }} cppcheck
119+
shell: bash
120+
121+
- name: Compile and install IWYU
122+
run: |
123+
mkdir iwyu && cd iwyu
124+
git clone https://github.com/include-what-you-use/include-what-you-use.git
125+
cd include-what-you-use
126+
git checkout ${{ matrix.compiler.iwyu_branch }}
127+
cd ..
128+
mkdir build && cd build
129+
cmake -G "Ninja" -DCMAKE_PREFIX_PATH=${{ matrix.compiler.path_prefix }} ../include-what-you-use
130+
ninja
131+
sudo ninja install
132+
shell: bash
133+
134+
- name: Configure via CMake
135+
shell: bash
136+
run: cmake --preset unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}-static-analysis
137+
138+
- name: Build
139+
shell: bash
140+
run: cmake --build --preset build-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}-static-analysis

CMakePresets.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,20 @@
304304
"CMAKE_CXX_COMPILER": "g++.exe",
305305
"CMAKE_BUILD_TYPE": "Release"
306306
}
307+
},
308+
{
309+
"name": "unixlike-clang-15-debug-static-analysis",
310+
"displayName": "Clang 15 Debug - Static Analysis",
311+
"description": "Target Unix-like OS with the Clang 15 compiler, debug build type",
312+
"inherits": "unixlike-clang-15-debug",
313+
"cacheVariables": {
314+
"CMAKE_C_COMPILER": "clang-15",
315+
"CMAKE_CXX_COMPILER": "clang++-15",
316+
"CMAKE_BUILD_TYPE": "Debug",
317+
"ENABLE_CPPCHECK": "ON",
318+
"ENABLE_CLANG_TIDY": "ON",
319+
"ENABLE_INCLUDE_WHAT_YOU_USE": "ON"
320+
}
307321
}
308322
],
309323
"buildPresets": [
@@ -386,6 +400,10 @@
386400
{
387401
"name": "build-win32-gcc-x64-mingw-release",
388402
"configurePreset": "win32-gcc-x64-mingw-release"
403+
},
404+
{
405+
"name": "build-unixlike-clang-15-debug-static-analysis",
406+
"configurePreset": "unixlike-clang-15-debug-static-analysis"
389407
}
390408
],
391409
"testPresets": [

azure.yml

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

docker/Dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
FROM ubuntu:22.10 as cpp-docker-common
66

77
ARG DEBIAN_FRONTEND=noninteractive
8+
ARG CLANG_COMPILER_VERSION=15
9+
ARG CMAKE_VERSION=3.26.3
810
ENV PATH="${PATH}:/cmake-3.26.3-linux-x86_64/bin/:"
911

1012
RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install --fix-missing \
11-
apturl \
1213
binutils \
1314
build-essential \
1415
bzip2 \
1516
cppcheck \
1617
ccache \
1718
doxygen \
1819
graphviz \
20+
git \
1921
lsb-release \
2022
ninja-build \
2123
python3 \
@@ -27,13 +29,23 @@ RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install --fix-missin
2729
tar \
2830
valgrind \
2931
wget
30-
RUN wget https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.sh \
31-
&& chmod +x cmake-3.26.3-linux-x86_64.sh \
32-
&& ./cmake-3.26.3-linux-x86_64.sh --include-subdir --skip-license \
33-
&& rm cmake-3.26.3-linux-x86_64.sh
32+
33+
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh \
34+
&& chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh \
35+
&& ./cmake-${CMAKE_VERSION}-linux-x86_64.sh --include-subdir --skip-license \
36+
&& rm cmake-${CMAKE_VERSION}-linux-x86_64.sh
3437
RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
35-
RUN apt-get -y install clang-format clang-tidy clang-15
36-
RUN apt-get autoremove -y && apt-get clean
38+
39+
RUN apt-get -y install --fix-missing clang-format clang-tidy clang-${CLANG_COMPILER_VERSION} llvm-${CLANG_COMPILER_VERSION} llvm-${CLANG_COMPILER_VERSION}-dev libclang-${CLANG_COMPILER_VERSION}-dev \
40+
&& apt-get autoremove -y && apt-get clean
41+
42+
RUN mkdir iwyu && cd iwyu \
43+
&& git clone --branch clang_${CLANG_COMPILER_VERSION} https://github.com/include-what-you-use/include-what-you-use.git \
44+
&& mkdir build && cd build \
45+
&& cmake -G "Ninja" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${CLANG_COMPILER_VERSION} ../include-what-you-use \
46+
&& sudo ninja install \
47+
&& cd ../.. \
48+
&& rm -rf iwyu
3749

3850

3951
# =================================

docker/build-ci-image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
DOCKER_BUILDKIT=1 docker -l debug build \
44
--target cpp-docker-ci \
5+
--build-arg CI_USER=ci \
56
-t cpp_ci_env:latest .

0 commit comments

Comments
 (0)