@@ -8,6 +8,13 @@ VARIABLE+=ESPPORT
8
8
HELP_ESPPORT =which device to flash/monitor
9
9
export ESPPORT
10
10
11
+ VARIABLE+ =FORMAT
12
+ HELP_FORMAT =patterns of files to format
13
+ ifndef FORMAT
14
+ FORMAT += **/*.h
15
+ FORMAT += **/*.c
16
+ endif
17
+
11
18
# ## internal variables ###
12
19
13
20
# assume /etc/passwd holds right shell of user
@@ -31,6 +38,8 @@ TEMPLATEPATH=../.Makefile.template
31
38
# ## default target ###
32
39
DEFAULT += help
33
40
41
+ UNCRUSTIFY_CFG = ./.uncrustify.cfg
42
+
34
43
# ## menuconfig targets ###
35
44
36
45
.PHONY : menuconfig
@@ -107,6 +116,28 @@ CHECK += check-monitor
107
116
HELP_check-monitor = check env if monitor is possible
108
117
check-monitor : | check-docker check-dev
109
118
119
+ # ## uncrustidy code format
120
+
121
+ .PHONY : uncrustify
122
+ TARGET += uncrustify
123
+ HELP_uncrustify = formats code with uncrustify
124
+ uncrustify : | check-docker
125
+ @make --no-print-directory -C $(DOCKERDIR ) uncrustify \
126
+ EXEC=" git ls-files -ico $( foreach PATTERN,$( FORMAT) ,-x $( PATTERN) ) \
127
+ | xargs -I % uncrustify -c $(UNCRUSTIFY_CFG ) --replace --no-backup %"
128
+
129
+ .PHONY : check-uncrustify
130
+ TARGET += check-uncrustify
131
+ HELP_check-uncrustify = check if formatting code with uncrustify is necessary
132
+ check-uncrustify : | check-docker
133
+ @make --no-print-directory -C $(DOCKERDIR ) uncrustify \
134
+ EXEC=" git ls-files -ico $( foreach PATTERN,$( FORMAT) ,-x $( PATTERN) ) \
135
+ | xargs -I % sh -c \" uncrustify -c $(UNCRUSTIFY_CFG ) -f % \
136
+ | git diff --exit-code \
137
+ --no-index \
138
+ --color \
139
+ % - \" "
140
+
110
141
# ## vscode ###
111
142
112
143
.PHONY : vscode
0 commit comments