Skip to content

Commit 80321d6

Browse files
committed
Add CodeChecker static analysis workflow
- add codechecker workflow - enable `-pedantic` - fix a lot of warnings - only report error from `gbm_surface_create_with_modifiers` if `gbm_surface_create` fails too
1 parent e6df12c commit 80321d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1365
-820
lines changed

.codechecker.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"analyze": [
3+
"-d",
4+
"clang-diagnostic-reserved-macro-identifier",
5+
"-d",
6+
"clang-diagnostic-reserved-identifier",
7+
"-d",
8+
"cert-err33-c",
9+
"-d",
10+
"clang-diagnostic-sign-compare",
11+
"-d",
12+
"clang-diagnostic-implicit-int-float-conversion",
13+
"-d",
14+
"clang-diagnostic-switch-enum",
15+
"--analyzers",
16+
"clangsa",
17+
"clang-tidy",
18+
"gcc",
19+
"-i",
20+
".codechecker.skipfile"
21+
]
22+
}

.codechecker.skipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
+*/flutter-pi/src
2+
-*

.github/workflows/codeql-buildscript.sh

100644100755
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#!/usr/bin/env bash
22

3-
sudo apt install -y cmake libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev ttf-mscorefonts-installer fontconfig libsystemd-dev libinput-dev libudev-dev libxkbcommon-dev
4-
mkdir build && cd build
5-
cmake ..
6-
make -j`nproc`
3+
# gstreamer and libc++ want different versions of libunwind-dev.
4+
# We explicitly install the version that gstreamer wants so
5+
# we don't get install errors.
6+
7+
sudo apt-get install -y --no-install-recommends \
8+
git cmake pkg-config ninja-build clang clang-tools \
9+
libgl-dev libgles-dev libegl-dev libvulkan-dev libdrm-dev libgbm-dev libsystemd-dev libinput-dev libudev-dev libxkbcommon-dev \
10+
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
11+
libunwind-dev
12+
13+
$WRAPPER cmake \
14+
-S . -B build \
15+
-GNinja \
16+
-DCMAKE_BUILD_TYPE=Debug \
17+
-DBUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN=ON \
18+
-DBUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN=ON \
19+
-DENABLE_VULKAN=ON \
20+
-DENABLE_SESSION_SWITCHING=ON \
21+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
22+
23+
$WRAPPER cmake --build build

.github/workflows/codeql.yml

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

.github/workflows/fail_on_error.py renamed to .github/workflows/fail_on_warning.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ def codeql_sarif_contain_error(filename):
2020
rule_index = res['rule']['index']
2121
else:
2222
continue
23+
2324
try:
2425
rule_level = rules_metadata[rule_index]['defaultConfiguration']['level']
25-
except IndexError as e:
26-
print(e, rule_index, len(rules_metadata))
27-
else:
28-
if rule_level == 'error':
29-
return True
26+
except LookupError:
27+
# According to the SARIF schema (https://www.schemastore.org/schemas/json/sarif-2.1.0-rtm.6.json),
28+
# the defalt level is "warning" if not specified.
29+
rule_level = 'warning'
30+
31+
if rule_level == 'error':
32+
return True
33+
elif rule_level == 'warning':
34+
return True
3035
return False
3136

3237
if __name__ == "__main__":

.github/workflows/static-analysis.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
push:
5+
branches: [ "main", "master" ]
6+
schedule:
7+
- cron: '0 0 * * *'
8+
pull_request:
9+
branches: '*'
10+
11+
jobs:
12+
codechecker:
13+
name: CodeChecker
14+
15+
# Use latest Ubuntu 24.04 for latest GCC.
16+
# CodeChecker requires gcc >= 13.0.0.
17+
# ubuntu-latest is ubuntu 22.04 (atm)
18+
runs-on: ubuntu-24.04
19+
20+
permissions:
21+
actions: read
22+
contents: read
23+
security-events: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: recursive
30+
31+
- name: Install Deps, Configure and Build
32+
run: |
33+
./.github/workflows/codeql-buildscript.sh
34+
35+
- name: Run CodeChecker
36+
uses: ardera/CodeChecker-Action@master
37+
id: codechecker
38+
with:
39+
ctu: true
40+
logfile: ${{ github.workspace }}/build/compile_commands.json
41+
config: ${{ github.workspace }}/.codechecker.json
42+
43+
- uses: actions/upload-artifact@v4
44+
id: upload
45+
with:
46+
name: "CodeChecker Bug Reports"
47+
path: ${{ steps.codechecker.outputs.result-html-dir }}
48+
49+
- name: Fail on Warnings
50+
if: ${{ steps.codechecker.outputs.warnings == 'true' }}
51+
run: |
52+
cat <<EOF >>$GITHUB_STEP_SUMMARY
53+
## ⚠️ CodeChecker found warnings
54+
Please see the 'CodeChecker Bug Reports' artifact for more details:
55+
- ${{ steps.upload.outputs.artifact-url }}
56+
EOF
57+
58+
exit 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.vscode
22
/build
33
/out
4+
/.codechecker
45

56
# CMake docs says it should not be checked in.
67
CMakeUserPresets.json

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,14 @@ target_link_libraries(flutterpi_module PUBLIC
162162
)
163163

164164
target_include_directories(flutterpi_module PUBLIC
165-
${CMAKE_SOURCE_DIR}/third_party/flutter_embedder_header/include
166165
${CMAKE_SOURCE_DIR}/src
167166
${CMAKE_BINARY_DIR}
167+
${CMAKE_SOURCE_DIR}/third_party/mesa3d/include
168+
${CMAKE_SOURCE_DIR}/third_party/flutter_embedder_header/include
168169
)
169170

170171
target_compile_options(flutterpi_module PUBLIC
171-
$<$<CONFIG:Debug>:-O0 -Wall -Wextra -Wno-sign-compare -Werror -ggdb -U_FORTIFY_SOURCE -DDEBUG>
172+
$<$<CONFIG:Debug>:-O0 -Wall -Wextra -Wno-sign-compare -Wswitch-enum -Wformat -Wdouble-promotion -Wno-overlength-strings -Wno-gnu-zero-variadic-macro-arguments -pedantic -Werror -ggdb -U_FORTIFY_SOURCE -DDEBUG>
172173
$<$<CONFIG:RelWithDebInfo>:-O3 -Wall -Wextra -Wno-sign-compare -ggdb -DNDEBUG>
173174
$<$<CONFIG:Release>:-O3 -Wall -Wextra -Wno-sign-compare -DNDEBUG>
174175
)
@@ -237,6 +238,7 @@ if (ENABLE_VULKAN)
237238
target_sources(flutterpi_module PRIVATE
238239
src/vk_gbm_render_surface.c
239240
src/vk_renderer.c
241+
src/vulkan.c
240242
)
241243
target_link_libraries(flutterpi_module PUBLIC
242244
PkgConfig::VULKAN

CMakePresets.json

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,58 @@
77
"description": "Sets Ninja generator, build and install directory",
88
"generator": "Ninja",
99
"binaryDir": "${sourceDir}/out/build/${presetName}",
10+
"hidden": true,
1011
"cacheVariables": {
1112
"CMAKE_BUILD_TYPE": "Debug",
1213
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
14+
"TRY_ENABLE_OPENGL": false,
1315
"ENABLE_OPENGL": true,
16+
"TRY_ENABLE_VULKAN": false,
17+
"ENABLE_VULKAN": true,
18+
"BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN": true,
19+
"TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN": false,
1420
"BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": true,
21+
"TRY_BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": false,
1522
"BUILD_SENTRY_PLUGIN": true,
1623
"ENABLE_TESTS": true
1724
}
1825
},
26+
{
27+
"name": "default-clang",
28+
"displayName": "Default OpenGL host build (clang)",
29+
"description": "Sets Ninja generator, build and install directory",
30+
"generator": "Ninja",
31+
"binaryDir": "${sourceDir}/out/build/${presetName}",
32+
"inherits": "default",
33+
"cacheVariables": {
34+
"CMAKE_C_COMPILER": "clang",
35+
"CMAKE_CXX_COMPILER": "clang++"
36+
}
37+
},
38+
{
39+
"name": "default-clang-20",
40+
"displayName": "Default OpenGL host build (clang-20)",
41+
"description": "Sets Ninja generator, build and install directory",
42+
"generator": "Ninja",
43+
"binaryDir": "${sourceDir}/out/build/${presetName}",
44+
"inherits": "default",
45+
"cacheVariables": {
46+
"CMAKE_C_COMPILER": "clang-20",
47+
"CMAKE_CXX_COMPILER": "clang++-20"
48+
}
49+
},
50+
{
51+
"name": "default-gcc",
52+
"displayName": "Default OpenGL host build (gcc)",
53+
"description": "Sets Ninja generator, build and install directory",
54+
"generator": "Ninja",
55+
"binaryDir": "${sourceDir}/out/build/${presetName}",
56+
"inherits": "default",
57+
"cacheVariables": {
58+
"CMAKE_C_COMPILER": "gcc",
59+
"CMAKE_CXX_COMPILER": "g++"
60+
}
61+
},
1962
{
2063
"name": "cross-aarch64-default",
2164
"displayName": "OpenGL AArch64 cross-build",
@@ -41,4 +84,4 @@
4184
}
4285
}
4386
]
44-
}
87+
}

0 commit comments

Comments
 (0)