Enable automatic generation of compile_flags.txt for clang-tidy via make tidy (#2008)

This commit is contained in:
Eldred Habert
2026-07-11 16:11:14 -04:00
committed by GitHub
parent 96bc58b7f7
commit 22bd8a9bd5
4 changed files with 8 additions and 12 deletions
+1
View File
@@ -11,6 +11,7 @@
*.gcno
*.gcda
*.gcov
/compile_flags.txt
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
+7 -3
View File
@@ -33,11 +33,13 @@ WARNFLAGS := -Wall -pedantic -Wno-unknown-warning-option \
# Overridable CXXFLAGS
CXXFLAGS ?= -O3 -flto -DNDEBUG
# Non-overridable CXXFLAGS
REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} -std=c++20 -I include -fno-exceptions -fno-rtti
REQUIREDCXXFLAGS := -std=c++20 -I include -fno-exceptions -fno-rtti
REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} ${REQUIREDCXXFLAGS}
# Overridable LDFLAGS
LDFLAGS ?=
# Non-overridable LDFLAGS
REALLDFLAGS := ${LDFLAGS} ${WARNFLAGS} -DBUILD_VERSION_STRING=\"${VERSION_STRING}\"
REQUIREDLDFLAGS := -DBUILD_VERSION_STRING=\"${VERSION_STRING}\"
REALLDFLAGS := ${LDFLAGS} ${WARNFLAGS} ${REQUIREDLDFLAGS}
# Wrapper around bison that passes flags depending on what the version supports
BISON := src/bison.sh
@@ -250,8 +252,10 @@ format:
# Target used in development to check code with clang-tidy.
# Requires Bison-generated header files to exist.
tidy: src/asm/parser.hpp src/link/script.hpp
tidy: src/asm/parser.hpp src/link/script.hpp compile_flags.txt
$Qclang-tidy -p . $$(git ls-files '*.[hc]pp')
compile_flags.txt:
$Qprintf '%s\n' ${REQUIREDCXXFLAGS} ${REQUIREDLDFLAGS} >$@
# Target used in development to remove unused `#include` headers.
iwyu:
-6
View File
@@ -1,6 +0,0 @@
-std=c++20
-I
include
-fno-exceptions
-fno-rtti
-fno-caret-diagnostics
-3
View File
@@ -65,7 +65,6 @@ rgbds/
├── .clang-tidy
├── CMakeLists.txt
├── CMakePresets.json
├── compile_flags.txt
├── Dockerfile
└── Makefile
```
@@ -129,8 +128,6 @@ rgbds/
Defines how to build RGBDS with CMake.
- **`CMakePresets.json`:**
Defines some [presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) useful for working with our CMake.
- **`compile_flags.txt`:**
Compiler flags for `clang-tidy`.
- **`Dockerfile`:**
Defines how to build RGBDS with Docker (which we do in CI to provide a [container image](https://github.com/gbdev/rgbds/pkgs/container/rgbds)).
- **`Makefile`:**