Skip to content

Commit

Permalink
Move options into .clang-tidy and update build
Browse files Browse the repository at this point in the history
Code doesn't get compiled so skip linking stage.
  • Loading branch information
mikee47 committed Apr 19, 2024
1 parent 07c1a71 commit 66a1dc3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 33 deletions.
61 changes: 38 additions & 23 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*'
HeaderFilterRegex: ''
Checks: >
-*
cppcoreguidelines-*
-cppcoreguidelines-avoid-c-arrays
-cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-macro-usage
-cppcoreguidelines-pro-type-cstyle-cast
-cppcoreguidelines-pro-type-static-cast-downcast
-cppcoreguidelines-pro-type-vararg
-cppcoreguidelines-pro-bounds-pointer-arithmetic
-cppcoreguidelines-pro-type-union-access
-cppcoreguidelines-avoid-const-or-ref-data-members
-cppcoreguidelines-non-private-member-variables-in-classes
-cppcoreguidelines-special-member-functions
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
User: slavey
User: slavey
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: cppcoreguidelines-pro-type-static-cast-downcast.StrictMode
value: false
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: true
...

17 changes: 7 additions & 10 deletions Sming/component-wrapper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,10 @@ 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_FLAG_EXTRA :=

CLANG_TIDY_WARN := \
no-invalid-constexpr
CLANG_FLAG_UNKNOWN := \
-fstrict-volatile-bitfields

# $1 -> absolute source directory, no trailing path separator
# $2 -> relative output build directory, with trailing path separator
Expand All @@ -145,7 +140,7 @@ 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))
$(Q) clang-tidy $$< $(CLANG_TIDY_OPTS) -- $(addprefix -I,$(INCDIR)) $$(filter-out $(CLANG_FLAG_UNKNOWN),$(CPPFLAGS) $(CFLAGS)) $(CLANG_FLAG_EXTRA)
else
$2%.o: $1/%.c $2%.c.d
$(vecho) "CC $$<"
Expand All @@ -159,7 +154,7 @@ 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))
$(Q) clang-tidy $$< $(CLANG_TIDY_OPTS) -- $(addprefix -I,$(INCDIR)) $$(filter-out $(CLANG_FLAG_UNKNOWN),$(CPPFLAGS) $(CXXFLAGS)) $(CLANG_FLAG_EXTRA)
else
$2%.o: $1/%.cpp $2%.cpp.d
$(vecho) "C+ $$<"
Expand Down Expand Up @@ -199,10 +194,12 @@ include $(wildcard $(ABS_BUILD_DIRS:=/*.cpp.d))

# Provide a target unless Component is custom built, in which case the component.mk will have defined this already
$(COMPONENT_LIBPATH): build.ar
ifneq ($(ENABLE_CLANG_TIDY),1)
$(vecho) "AR $@"
$(Q) test ! -f $@ || rm $@
$(Q) $(AR) -M < build.ar
$(Q) mv $(notdir $(COMPONENT_LIBPATH)) $(COMPONENT_LIBPATH)
endif

define addmod
@echo ADDMOD $2 >> $1
Expand Down

0 comments on commit 66a1dc3

Please sign in to comment.