-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
154 lines (131 loc) · 4.06 KB
/
Makefile
File metadata and controls
154 lines (131 loc) · 4.06 KB
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
.PHONY: all list-projects clean
DOCKER_IMAGE ?= aabadie/dotbot:latest
DOCKER_TARGETS ?= all
PACKAGES_DIR_OPT ?=
SEGGER_DIR ?= /opt/segger
BUILD_CONFIG ?= Debug
BUILD_TARGET ?= nrf52840dk
PROJECT_FILE ?= $(BUILD_TARGET).emProject
QUIET ?= 0
VERBOSE_OPTS ?= -verbose -echo
ifeq ($(QUIET),1)
VERBOSE_OPTS =
endif
ifeq (nrf5340dk-app,$(BUILD_TARGET))
PROJECTS ?= \
01bsp_device \
01bsp_gpio \
01bsp_i2c \
01bsp_lighthouse \
01bsp_nvmc \
01bsp_qdec \
01bsp_qspi \
01bsp_radio_txrx \
01bsp_radio_txrx_lr \
01bsp_rng \
01bsp_rpm \
01bsp_timer \
01bsp_timer_hf \
01bsp_uart \
01bsp_wdt \
01drv_lis2mdl \
01drv_lis3mdl \
01drv_lz4 \
01drv_motors \
01drv_move \
01drv_pid \
01drv_rgbled \
01drv_uzlib \
03app_nrf5340_app \
#
else ifeq (nrf5340dk-net,$(BUILD_TARGET))
PROJECTS ?= \
01bsp_device \
01bsp_gpio \
01bsp_i2c \
01bsp_nvmc \
01bsp_qdec \
01bsp_radio_txrx \
01bsp_radio_txrx_lr \
01bsp_rng \
01bsp_rpm \
01bsp_timer \
01bsp_timer_hf \
01bsp_uart \
01bsp_wdt \
01drv_lis2mdl \
01drv_motors \
01drv_pid \
01drv_rgbled \
#
else
PROJECTS ?= $(shell find projects/ -maxdepth 1 -mindepth 1 -type d | tr -d "/" | sed -e s/projects// | sort)
endif
ifneq (,$(filter dotbot-v2 dotbot-v3,$(BUILD_TARGET)))
PROJECTS := $(filter-out 03app_dotbot_gateway 03app_dotbot_gateway_lr 03app_sailbot 03app_xgo 03app_nrf5340_net 03app_freebot 03app_lh2_mini_mote%,$(PROJECTS))
ARTIFACT_PROJECTS := 03app_dotbot
endif
ifneq (,$(filter nrf52833dk,$(BUILD_TARGET)))
PROJECTS := $(filter-out 01crypto_% 01bsp_qspi,$(PROJECTS))
endif
# remove incompatible apps (nrf5340) for nrf52833dk/nrf52840dk build
ifneq (,$(filter nrf52833dk nrf52840dk,$(BUILD_TARGET)))
PROJECTS := $(filter-out 01drv_move 03app_nrf5340_% 03app_freebot 03app_xgo,$(PROJECTS))
ARTIFACT_PROJECTS := 03app_dotbot_gateway 03app_dotbot_gateway_lr
endif
ifneq (,$(filter nrf5340dk-app,$(BUILD_TARGET)))
ARTIFACT_PROJECTS := 03app_dotbot_gateway 03app_dotbot_gateway_lr
endif
ifneq (,$(filter nrf5340dk-net,$(BUILD_TARGET)))
ARTIFACT_PROJECTS := 03app_nrf5340_net
endif
DIRS ?= bsp crypto drv projects
SRCS ?= $(foreach dir,$(DIRS),$(shell find $(dir) -name "*.[c|h]"))
CLANG_FORMAT ?= clang-format
CLANG_FORMAT_TYPE ?= file
ARTIFACT_ELF = $(foreach app,$(ARTIFACT_PROJECTS),projects/$(app)/Output/$(BUILD_TARGET)/$(BUILD_CONFIG)/Exe/$(app)-$(BUILD_TARGET).elf)
ARTIFACT_HEX = $(ARTIFACT_ELF:.elf=.hex)
ARTIFACTS = $(ARTIFACT_ELF) $(ARTIFACT_HEX)
.PHONY: $(PROJECTS) $(ARTIFACT_PROJECTS) artifacts docker docker-release format check-format
all: $(PROJECTS)
$(PROJECTS):
@echo "\e[1mBuilding project $@\e[0m"
"$(SEGGER_DIR)/bin/emBuild" $(PROJECT_FILE) -project $@ -config $(BUILD_CONFIG) $(PACKAGES_DIR_OPT) -rebuild $(VERBOSE_OPTS)
@echo "\e[1mDone\e[0m\n"
list-projects:
@echo "\e[1mAvailable projects:\e[0m"
@echo $(PROJECTS) | tr ' ' '\n'
clean:
"$(SEGGER_DIR)/bin/emBuild" $(PROJECT_FILE) -config $(BUILD_CONFIG) -clean $(VERBOSE_OPTS)
distclean: clean
rm -rf artifacts/
format:
@$(CLANG_FORMAT) -i --style=$(CLANG_FORMAT_TYPE) $(SRCS)
check-format:
@$(CLANG_FORMAT) --dry-run --Werror --style=$(CLANG_FORMAT_TYPE) $(SRCS)
artifacts: $(ARTIFACT_PROJECTS)
@mkdir -p artifacts
@for artifact in "$(ARTIFACTS)"; do \
cp $${artifact} artifacts/.; \
done
@ls -l artifacts/
UID := $(shell id -u)
GID := $(shell id -g)
docker:
docker run --rm -i \
-u $(UID):$(GID) \
-e BUILD_TARGET="$(BUILD_TARGET)" \
-e BUILD_CONFIG="$(BUILD_CONFIG)" \
-e PACKAGES_DIR_OPT="-packagesdir $(SEGGER_DIR)/packages" \
-e PROJECTS="$(PROJECTS)" \
-e SEGGER_DIR="$(SEGGER_DIR)" \
-v $(PWD):/dotbot $(DOCKER_IMAGE) \
make $(DOCKER_TARGETS)
.PHONY: doc docclean
docclean:
make -C doc/doxygen clean --no-print-directory
make -C doc/sphinx clean --no-print-directory
rm -rf $(addprefix doc/sphinx/_,api examples projects)
doc:
make -C doc/sphinx html --no-print-directory SPHINXOPTS="-W --keep-going -n"
# make -C doc/sphinx linkcheck html --no-print-directory SPHINXOPTS="-W --keep-going -n"