forked from prathje/DisruptaBLE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
270 lines (211 loc) · 7.02 KB
/
Makefile
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
###############################################################################
# Default Commands
###############################################################################
.PHONY: all
all: posix
.PHONY: ud3tn
ud3tn: posix
.PHONY: clean
clean::
$(RM) -rf build/
###############################################################################
# Execution and Deployment
###############################################################################
.PHONY: run-posix
run-posix: posix
build/posix/ud3tn
.PHONY: run-unittest-posix
run-unittest-posix: unittest-posix
build/posix/testud3tn
.PHONY: flash-stm32-stlink
flash-stm32-stlink: stm32
$(ST_FLASH_PREFIX)st-flash --reset write build/stm32/ud3tn.bin 0x08000000
.PHONY: flash-unittest-stm32-stlink
flash-unittest-stm32-stlink: unittest-stm32
$(ST_FLASH_PREFIX)st-flash --reset write build/stm32/testud3tn.bin 0x08000000
.PHONY: flash-stm32-openocd
flash-stm32-openocd: stm32
echo "reset init;" "flash write_image erase build/stm32/ud3tn.bin 0x08000000;" \
"reset;" "exit;" | ncat localhost 4444 | tail -n +2 > /dev/null;
.PHONY: flash-unittest-stm32-openocd
flash-unittest-stm32-openocd: unittest-stm32
echo "reset init;" "flash write_image erase build/stm32/testud3tn.bin 0x08000000;" \
"reset;" "exit;" | ncat localhost 4444 | tail -n +2 > /dev/null;
.PHONY: flash-stm32-openocd-oneshot
flash-stm32-openocd-oneshot: stm32
$(OOCD_PREFIX)openocd -c "script openocd.cfg" -c "reset init" \
-c "flash write_image erase build/stm32/ud3tn.bin 0x08000000" \
-c "reset" -c "shutdown"
.PHONY: flash-unittest-stm32-openocd-oneshot
flash-unittest-stm32-openocd-oneshot: unittest-stm32
$(OOCD_PREFIX)openocd -c "script openocd.cfg" -c "reset init" \
-c "flash write_image erase build/stm32/testud3tn.bin 0x08000000" \
-c "reset" -c "shutdown"
###############################################################################
# Tools
###############################################################################
.PHONY: gdb-posix
gdb-posix: posix
$(TOOLCHAIN_POSIX)gdb build/posix/ud3tn
.PHONY: gdb-stm32
gdb-stm32: stm32
$(TOOLCHAIN_STM32)gdb --eval-command="target remote :4443" \
build/stm32/ud3tn
.PHONY: gdb-unittest-stm32
gdb-unittest-stm32: unittest-stm32
$(TOOLCHAIN_STM32)gdb --eval-command="target remote :4443" \
build/stm32/testud3tn
.PHONY: openocd
openocd:
openocd
.PHONY: stutil
stutil:
$$(dirname $(ST_FLASH))/st-util -p 4443
.PHONY: connect
connect:
python3 ./tools/cla/stm32_mtcp_proxy.py \
--device /dev/serial/by-id/*STM32_Virtual*
###############################################################################
# Tests
###############################################################################
.PHONY: integration-test
integration-test:
pytest test/integration
.PHONY: integration-test-tcpspp
integration-test-tcpspp:
CLA=tcpspp pytest test/integration
.PHONY: integration-test-tcpcl
integration-test-tcpcl:
CLA=tcpcl pytest test/integration
.PHONY: integration-test-mtcp
integration-test-mtcp:
CLA=mtcp pytest test/integration
.PHONY: integration-test-stm32
integration-test-stm32:
CLA=usbotg pytest test/integration
# Directory for the virtual Python envionment
VENV := .venv
GET_PIP = curl -sS https://bootstrap.pypa.io/get-pip.py | $(VENV)/bin/python
ifeq "$(verbose)" "yes"
PIP = $(VENV)/bin/pip
else
PIP = $(VENV)/bin/pip -q
GET_PIP += > /dev/null
endif
.PHONY: virtualenv
virtualenv:
@echo "Create virtualenv in $(VENV)/ ..."
@python3 -m venv --without-pip $(VENV)
@echo "Install latest pip package ..."
@$(GET_PIP)
@echo "Install local dependencies to site-packages..."
@$(PIP) install -U -e ./pyd3tn ./python-ud3tn-utils
@echo "Install additional dependencies ..."
@$(PIP) install -U -r ./test/integration/requirements.txt
@$(PIP) install -U -r ./tools/analysis/requirements.txt
@$(PIP) install -U -r ./tools/cla/requirements.txt
@echo
@echo "=> To activate the virtualenv, source $(VENV)/bin/activate"
@echo " or use environment-setup tools like"
@echo " - virtualenv"
@echo " - virtualenvwrapper"
@echo " - direnv"
.PHONY: update-virtualenv
update-virtualenv:
$(PIP) install -U setuptools pip wheel
$(PIP) install -U -r ./test/integration/requirements.txt
$(PIP) install -U -r ./tools/analysis/requirements.txt
$(PIP) install -U -r ./tools/cla/requirements.txt
###############################################################################
# Code Quality Tests (and Release Tool)
###############################################################################
.PHONY: check-style
check-style:
bash ./tools/analysis/stylecheck.sh
.PHONY: clang-check-stm32
clang-check-stm32: ccmds-stm32
bash ./tools/analysis/clang-check.sh check \
"stm32" \
"components/agents/stm32" \
"components/cla/stm32" \
"components/platform/stm32"
.PHONY: clang-tidy-stm32
clang-tidy-stm32: ccmds-stm32
bash ./tools/analysis/clang-check.sh tidy \
"stm32" \
"components/agents/stm32" \
"components/cla/stm32" \
"components/platform/stm32"
.PHONY: clang-check-posix
clang-check-posix: ccmds-posix
bash ./tools/analysis/clang-check.sh check \
"posix" \
"components/agents/posix" \
"components/cla/posix" \
"components/platform/posix"
.PHONY: clang-tidy-posix
clang-tidy-posix: ccmds-posix
bash ./tools/analysis/clang-check.sh tidy \
"posix" \
"components/agents/posix" \
"components/cla/posix" \
"components/platform/posix"
###############################################################################
# Flags
###############################################################################
CPPFLAGS += -Wall
ifdef CONFIG_AGENT_REMOTE_CONFIGURATION
CPPFLAGS += -DCONFIG_AGENT_REMOTE_CONFIGURATION
endif
ifeq "$(type)" "release"
CPPFLAGS += -O2
else
CPPFLAGS += -g -O0 -DDEBUG
endif
ifneq "$(wextra)" "no"
ifeq "$(wextra)" "all"
CPPFLAGS += -Wextra -Wconversion -Wundef -Wshadow -Wsign-conversion -Wformat-security
else
CPPFLAGS += -Wextra -Wno-error=extra -Wno-unused-parameter
ifneq ($(TOOLCHAIN),clang)
CPPFLAGS += -Wno-override-init -Wno-unused-but-set-parameter
endif
endif
endif
ifeq "$(werror)" "yes"
CPPFLAGS += -Werror
endif
ifneq "$(verbose)" "yes"
Q := @
quiet := quiet_
MAKEFLAGS += --no-print-directory
endif
-include config.mk
###############################################################################
# uD3TN-Builds
###############################################################################
.PHONY: posix stm32
ifndef PLATFORM
posix:
@$(MAKE) PLATFORM=posix posix
posix-lib:
@$(MAKE) PLATFORM=posix posix-lib
unittest-posix:
@$(MAKE) PLATFORM=posix unittest-posix
stm32:
@$(MAKE) PLATFORM=stm32 stm32
unittest-stm32:
@$(MAKE) PLATFORM=stm32 unittest-stm32
ccmds-posix:
@$(MAKE) PLATFORM=posix build/posix/compile_commands.json
ccmds-stm32:
@$(MAKE) PLATFORM=stm32 build/stm32/compile_commands.json
else # ifndef PLATFORM
include mk/$(PLATFORM).mk
include mk/build.mk
posix: build/posix/ud3tn
posix-lib: build/posix/libud3tn.so
unittest-posix: build/posix/testud3tn
stm32: build/stm32/ud3tn.bin
unittest-stm32: build/stm32/testud3tn.bin
endif # ifndef PLATFORM