Skip to content

Commit 8ae1d5d

Browse files
authored
🔧 Add clang-tidy options (#73)
1 parent de28509 commit 8ae1d5d

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ jobs:
4444
modules_support_needed: true
4545
coroutine_support_needed: true
4646
secrets: inherit
47+
48+
tests:
49+
name: ✅ Testing w/ Clang-Tidy enabled
50+
uses: libhal/ci/.github/workflows/tests.yml@5.x.y
51+
secrets: inherit

CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,20 @@ project(async_context LANGUAGES CXX)
3333

3434
if(CMAKE_CROSSCOMPILING)
3535
message(STATUS "Cross compiling, skipping clang-tidy")
36-
else()
37-
if(USE_CLANG_TIDY)
38-
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
39-
if(CLANG_TIDY_EXE)
40-
message(STATUS "Clang-tidy found: ${CLANG_TIDY_EXE}")
41-
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};--config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy;--fix")
42-
else()
43-
message(STATUS "Clang-tidy not found - continuing without clang-tidy")
36+
elseif(LIBHAL_ENABLE_CLANG_TIDY)
37+
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
38+
if(CLANG_TIDY_EXE)
39+
message(STATUS "Clang-tidy found: ${CLANG_TIDY_EXE}")
40+
set(CLANG_TIDY_CMD "${CLANG_TIDY_EXE};--config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy")
41+
if(LIBHAL_CLANG_TIDY_FIX)
42+
list(APPEND CLANG_TIDY_CMD "--fix")
4443
endif()
44+
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_CMD})
4545
else()
46-
message(WARNING "Clang-tidy checks disabled")
46+
message(STATUS "Clang-tidy not found - continuing without clang-tidy")
4747
endif()
48+
else()
49+
message(STATUS "Clang-tidy checks disabled (use -o enable_clang_tidy=True to enable)")
4850
endif()
4951

5052
# ==============================================================================

conanfile.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class async_context_conan(ConanFile):
3636
exports_sources = "modules/*", "benchmarks/*", "tests/*", "CMakeLists.txt", "LICENSE", ".clang-tidy"
3737
package_type = "static-library"
3838
shared = False
39+
options = {
40+
"enable_clang_tidy": [True, False],
41+
"clang_tidy_fix": [True, False],
42+
}
43+
default_options = {
44+
"enable_clang_tidy": False,
45+
"clang_tidy_fix": False,
46+
}
3947

4048
@property
4149
def _min_cppstd(self):
@@ -104,6 +112,8 @@ def layout(self):
104112
def generate(self):
105113
tc = CMakeToolchain(self)
106114
tc.generator = "Ninja"
115+
tc.variables["LIBHAL_ENABLE_CLANG_TIDY"] = self.options.enable_clang_tidy
116+
tc.variables["LIBHAL_CLANG_TIDY_FIX"] = self.options.clang_tidy_fix
107117
tc.generate()
108118

109119
deps = CMakeDeps(self)

0 commit comments

Comments
 (0)