Skip to content

Commit

Permalink
Try out clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed May 28, 2023
1 parent 02835d8 commit b16ddf5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Sming/component-wrapper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ else
OUTPUT_DEPS := -MF $$@
endif

CLANG_TIDY_OPTS := \
-checks=-* \
-checks=cppcoreguidelines-* \
-checks=-cppcoreguidelines-avoid-c-arrays \
-checks=-cppcoreguidelines-pro-bounds-array-to-pointer-decay \
-checks=-clang-diagnostic-error

CLANG_TIDY_WARN := \
no-invalid-constexpr

# $1 -> absolute source directory, no trailing path separator
# $2 -> relative output build directory, with trailing path separator
define GenerateCompileTargets
Expand All @@ -132,21 +142,33 @@ $2%.o: $1/%.S
$(Q) $(AS) $(addprefix -I,$(INCDIR)) $(CPPFLAGS) $(CFLAGS) -c $$< -o $$@
endif
ifneq (,$(filter $1/%.c,$(SOURCE_FILES)))
ifeq ($(ENABLE_CLANG_TIDY),1)
$2%.o: $1/%.c
$(vecho) "TIDY $$<"
$(Q) clang-tidy $$< $(CLANG_TIDY_OPTS) -- $(addprefix -I,$(INCDIR)) $$(filter-out -fstrict-volatile-bitfields,$(CPPFLAGS) $(CFLAGS)) $(addprefix -W,$(CLANG_TIDY_WARN))
else
$2%.o: $1/%.c $2%.c.d
$(vecho) "CC $$<"
$(Q) $(CC) $(addprefix -I,$(INCDIR)) $(CPPFLAGS) $(CFLAGS) -c $$< -o $$@
$2%.c.d: $1/%.c
$(Q) $(CC) $(addprefix -I,$(INCDIR)) $(CPPFLAGS) $(CFLAGS) -MM -MT $2$$*.o $$< $(OUTPUT_DEPS)
.PRECIOUS: $2%.c.d
endif
endif
ifneq (,$(filter $1/%.cpp,$(SOURCE_FILES)))
ifeq ($(ENABLE_CLANG_TIDY),1)
$2%.o: $1/%.cpp
$(vecho) "TIDY $$<"
$(Q) clang-tidy $$< $(CLANG_TIDY_OPTS) -- $(addprefix -I,$(INCDIR)) $$(filter-out -fstrict-volatile-bitfields,$(CPPFLAGS) $(CXXFLAGS)) $(addprefix -W,$(CLANG_TIDY_WARN))
else
$2%.o: $1/%.cpp $2%.cpp.d
$(vecho) "C+ $$<"
$(Q) $(CXX) $(addprefix -I,$(INCDIR)) $(CPPFLAGS) $(CXXFLAGS) -c $$< -o $$@
$2%.cpp.d: $1/%.cpp
$(Q) $(CXX) $(addprefix -I,$(INCDIR)) $(CPPFLAGS) $(CXXFLAGS) -MM -MT $2$$*.o $$< $(OUTPUT_DEPS)
.PRECIOUS: $2%.cpp.d
endif
endif
endef

# Resolve a source path to the corresponding build output object file
Expand Down

0 comments on commit b16ddf5

Please sign in to comment.