-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.buildtests
196 lines (188 loc) · 5.77 KB
/
Makefile.buildtests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
ifneq (, $(filter buildtest, $(MAKECMDGOALS)))
ifeq (, $(strip $(NPROC)))
# Linux (utility program)
NPROC := $(shell nproc 2>/dev/null)
ifeq (, $(strip $(NPROC)))
# Linux (generic)
NPROC := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
endif
ifeq (, $(strip $(NPROC)))
# BSD (at least FreeBSD and Mac OSX)
NPROC := $(shell sysctl -n hw.ncpu 2>/dev/null)
endif
ifeq (, $(strip $(NPROC)))
# Fallback
NPROC := 1
endif
NPROC := $(shell echo $$(($(NPROC) + 1)))
endif
endif
buildtest:
@if [ -z "$${JENKINS_URL}" ] && tput colors 2>&1 > /dev/null; then \
GREEN='\033[1;32m'; RED='\033[1;31m'; RESET='\033[0m'; \
ECHO='/bin/echo -e'; \
else \
GREEN=''; RED=''; RESET=''; \
ECHO='/bin/echo'; \
fi; \
\
if [ -z "$(BOARD_WHITELIST)" ]; then \
BOARDS=$$(find $(RIOTBOARD) -mindepth 1 -maxdepth 1 -type d \! -name \*-common -printf '%f\n' ); \
else \
BOARDS="$(BOARD_WHITELIST)"; \
fi; \
\
for BOARD in $(BOARD_BLACKLIST); do \
echo "Ignoring $${BOARD} (blacklisted)"; \
BOARDS=$$(echo \ $${BOARDS}\ | sed -e 's/ '$${BOARD}' / /'); \
done; \
\
rm -rf "$$BINDIRBASE"; \
for BOARD in $${BOARDS}; do \
RIOTNOLINK=$$(case ' $(BOARD_INSUFFICIENT_RAM) ' in *" $${BOARD} "*) echo 1; esac); \
$${ECHO} -n "Building for $${BOARD} "; \
[ -n "$${RIOTNOLINK}" ] && $${ECHO} -n "(no linking) "; \
$${ECHO} -n ".. "; \
LOG=$$(env -i \
HOME=$${HOME} \
PATH=$${PATH} \
BOARD=$${BOARD} \
RIOTBASE=$${RIOTBASE} \
RIOTBOARD=$${RIOTBOARD} \
RIOTCPU=$${RIOTCPU} \
BINDIRBASE=$${BINDIRBASE} \
RIOTNOLINK=$${RIOTNOLINK} \
RIOT_VERSION=$${RIOT_VERSION} \
$(MAKE) -j$(NPROC) 2>&1 >/dev/null) ; \
if [ "$${?}" = "0" ]; then \
$${ECHO} "$${GREEN}success$${RESET}"; \
else \
$${ECHO} "$${RED}failed$${RESET}"; \
echo "$${LOG}" | grep -v -E '^make(\[[[:digit:]]])?:'; \
BUILDTESTFAILED=1; \
fi; \
done; \
if [ "$${BUILDTESTFAILED}" = "1" ]; then \
exit 1; \
fi
objsize:
@case "${SORTROW}" in \
text) SORTROW=1 ;; \
data) SORTROW=2 ;; \
bss) SORTROW=3 ;; \
dec) SORTROW=4 ;; \
"") SORTROW=4 ;; \
*) echo "Usage: $(MAKE) objsize SORTROW=[text|data|bss|dec]" ; return ;; \
esac; \
echo ' text\t data\t bss\t dec\t hex\tfilename'; \
$(SIZE) -dB $(BASELIBS) | \
tail -n+2 | \
sed -e 's#$(BINDIR)##' | \
sort -rnk$${SORTROW}
buildsize:
@$(SIZE) -dB $(BINDIR)$(APPLICATION).elf
buildsizes: SHELL=bash
buildsizes:
@if [[ -z "$(BOARD_WHITELIST)" ]]; then \
BOARDS=$$(find $(RIOTBOARD) -mindepth 1 -maxdepth 1 -type d \! -name \*-common -printf '%f\n' ); \
else \
BOARDS="$(BOARD_WHITELIST)"; \
fi; \
for BOARD in $(BOARD_BLACKLIST) $(BOARD_INSUFFICIENT_RAM); do \
BOARDS=$$(echo \ $${BOARDS}\ | sed -e 's/ '$${BOARD}' / /'); \
done; \
\
echo -e " text\t data\t bss\t dec\tboard"; \
for BOARD in $${BOARDS}; do \
echo "$$(env -i \
HOME=$${HOME} \
PATH=$${PATH} \
BOARD=$${BOARD} \
RIOTBASE=$${RIOTBASE} \
RIOTBOARD=$${RIOTBOARD} \
RIOTCPU=$${RIOTCPU} \
BINDIRBASE=$${BINDIRBASE} \
$(MAKE) buildsize 2>/dev/null | tail -n-1 | cut -f-4)" "$${BOARD}"; \
done;
buildsizes-diff: SHELL=bash
buildsizes-diff:
@if [[ -z "$(BOARD_WHITELIST)" ]]; then \
BOARDS=$$(find $(RIOTBOARD) -mindepth 1 -maxdepth 1 -type d \! -name \*-common -printf '%f\n' ); \
else \
BOARDS="$(BOARD_WHITELIST)"; \
fi; \
for BOARD in $(BOARD_BLACKLIST) $(BOARD_INSUFFICIENT_RAM); do \
BOARDS=$$(echo \ $${BOARDS}\ | sed -e 's/ '$${BOARD}' / /'); \
done; \
\
GREEN='\033[1;32m'; RED='\033[1;31m'; RESET='\033[0m'; \
\
echo -e "text\tdata\tbss\tdec\tBOARD/BINDIRBASE\n"; \
for BOARD in $$(tr ' ' '\n' <<< $${BOARDS} | sort); do \
for BINDIRBASE in $${OLDBIN} $${NEWBIN}; do \
env -i \
HOME=$${HOME} \
PATH=$${PATH} \
BOARD=$${BOARD} \
RIOTBASE=$${RIOTBASE} \
RIOTBOARD=$${RIOTBOARD} \
RIOTCPU=$${RIOTCPU} \
BINDIRBASE=$${BINDIRBASE} \
$(MAKE) buildsize 2>/dev/null | tail -n-1 | cut -f-4; \
done | \
while read -a OLD && read -a NEW; do \
for I in 0 1 2 3; do \
if [[ -n "$${NEW[I]}" && -n "$${OLD[I]}" ]]; then \
DIFF=$$(($${NEW[I]} - $${OLD[I]})); \
if [[ "$${DIFF}" -gt 0 ]]; then echo -ne "$${RED}"; fi; \
if [[ "$${DIFF}" -lt 0 ]]; then echo -ne "$${GREEN}"; fi; \
else \
DIFF="$${RED}ERR"; \
fi; \
echo -ne "$${DIFF}\t$${RESET}"; \
done; \
echo "$${BOARD}"; \
for I in 0 1 2 3; do echo -ne "$${OLD[I]-$${RED}ERR$${RESET}}\t"; done; echo -e "$${OLDBIN}"; \
for I in 0 1 2 3; do echo -ne "$${NEW[I]-$${RED}ERR$${RESET}}\t"; done; echo -e "$${NEWBIN}\n"; \
done; \
done;
buildinfo:
@echo 'APPLICATION: $(APPLICATION)'
@echo 'BOARD: $(BOARD)'
@echo 'CPU: $(CPU)'
@echo 'MCU: $(MCU)'
@echo ''
@echo 'RIOTBASE: $(RIOTBASE)'
@echo 'RIOTBOARD: $(RIOTBOARD)'
@echo 'RIOTCPU: $(RIOTCPU)'
@echo ''
@echo 'DEFAULT_MODULE: $(sort $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE)))'
@echo 'DISABLE_MODULE: $(sort $(DISABLE_MODULE))'
@echo 'USEMODULE: $(sort $(filter-out $(DEFAULT_MODULE), $(USEMODULE)))'
@echo ''
@echo 'ELFFILE: $(ELFFILE)'
@echo 'HEXFILE: $(HEXFILE)'
@echo ''
@echo 'CC: $(CC)'
@echo -e 'CFLAGS:$(patsubst %, \n\t%, $(CFLAGS))'
@echo ''
@echo 'CXX: $(CXX)'
@echo -e 'CXXUWFLAGS:$(patsubst %, \n\t%, $(CXXUWFLAGS))'
@echo -e 'CXXEXFLAGS:$(patsubst %, \n\t%, $(CXXEXFLAGS))'
@echo ''
@echo 'LINK: $(LINK)'
@echo -e 'LINKFLAGS:$(patsubst %, \n\t%, $(LINKFLAGS))'
@echo ''
@echo 'OBJCOPY: $(OBJCOPY)'
@echo 'OFLAGS: $(OFLAGS)'
@echo ''
@echo 'FLASHER: $(FLASHER)'
@echo 'FFLAGS: $(FFLAGS)'
@echo ''
@echo 'TERMPROG: $(TERMPROG)'
@echo 'PORT: $(PORT)'
@echo ''
@echo 'DEBUGGER: $(DEBUGGER)'
@echo 'DEBUGGER_FLAGS: $(DEBUGGER_FLAGS)'
@echo ''
@echo -e 'MAKEFILE_LIST:$(patsubst %, \n\t%, $(abspath $(MAKEFILE_LIST)))'