-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMakefile
253 lines (193 loc) · 7.33 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
include scripts/set-shell.mk
include scripts/env-setup.mk
BR2_EXTERNAL := $(CURDIR)
ifeq ($(HW_CONFIG),)
HW_CONFIG := prod
endif
.PHONY: all config image clean \
docker-setup docker-make-image docker-make-clean \
docker-config docker-run docker-shell \
docker-config pkg-% docker-pkg-% \
docker-rebuild-changed rebuild-changed _rebuild_changed
all: image
include scripts/docker.mk
external-artifacts:
@./scripts/fetch-external-artifacts $(VARIANT)
config:
$(BUILD_ENV_ARGS) \
$(MAKE) -C buildroot O=$(VARIANT_OUTPUT) VARIANT=$(VARIANT) $(VARIANT_CONFIG)
pre-flight-checks:
@./scripts/run-preflight-checks $(VARIANT)
image: pre-flight-checks external-artifacts config
$(BUILD_ENV_ARGS) \
$(MAKE) -C buildroot O=$(VARIANT_OUTPUT) VARIANT=$(VARIANT) V=$(V)
clean-ccache:
rm -rf buildroot/output/ccache/*
clean:
find buildroot/$(VARIANT_OUTPUT) -mindepth 1 -maxdepth 1 \
\( ! -path buildroot/$(VARIANT_OUTPUT)/images \) \
-print -exec rm -rf {} \;
rm -rf buildroot/$(VARIANT_OUTPUT)/images/*
flush-rootfs:
find buildroot/$(VARIANT_OUTPUT)/target -name .stamp_target_installed -delete
rm -rf buildroot/$(VARIANT_OUTPUT)/target/*
# 'Package-specific:'
# ' pkg-<pkg> - Build and install <pkg> and all its dependencies'
# ' pkg-<pkg>-source - Only download the source files for <pkg>'
# ' pkg-<pkg>-extract - Extract <pkg> sources'
# ' pkg-<pkg>-patch - Apply patches to <pkg>'
# ' pkg-<pkg>-depends - Build <pkg>'\''s dependencies'
# ' pkg-<pkg>-configure - Build <pkg> up to the configure step'
# ' pkg-<pkg>-build - Build <pkg> up to the build step'
# ' pkg-<pkg>-dirclean - Remove <pkg> build directory'
# ' pkg-<pkg>-reconfigure - Restart the build from the configure step'
# ' pkg-<pkg>-rebuild - Restart the build from the build step'
pkg-%: config
$(BUILD_ENV_ARGS) \
$(MAKE) -C buildroot $* O=$(VARIANT_OUTPUT) VARIANT=$(VARIANT)
rebuild-changed: export BUILD_TEMP=/tmp SINCE=$(SINCE) IGNORE=$(_REBUILD_CHANGED_IGNORE)
rebuild-changed: _rebuild_changed
_REBUILD_CHANGED_IGNORE_DEFAULT := release_lockdown,piksi_ins,sample_daemon,llvm_o,llvm_v,build_tools
ifneq ($(IGNORE),)
_REBUILD_CHANGED_IGNORE := $(IGNORE),$(_REBUILD_CHANGED_IGNORE_DEFAULT)
else
_REBUILD_CHANGED_IGNORE := $(_REBUILD_CHANGED_IGNORE_DEFAULT)
endif
_rebuild_changed:
$(BUILD_ENV_ARGS) \
$(MAKE) -C buildroot \
$(shell BUILD_TEMP=$(BUILD_TEMP) SINCE=$(SINCE) IGNORE=$(IGNORE) \
scripts/changed_project_targets.py) \
O=$(VARIANT_OUTPUT) VARIANT=$(VARIANT)
_print_db:
$(BUILD_ENV_ARGS) \
$(MAKE) -C buildroot all O=$(VARIANT_OUTPUT) VARIANT=$(VARIANT) -np
docker-build-image:
docker build --no-cache --force-rm \
--build-arg VERSION_TAG=$(shell cat scripts/docker_version_tag) \
--build-arg USER=$(SANITIZED_USER) \
--build-arg UID=$(UID) \
--build-arg GID=$(GID) \
--tag $(DOCKER_TAG) -f scripts/Dockerfile .
docker-populate-volume:
docker run $(DOCKER_SETUP_ARGS) $(DOCKER_TAG) \
git submodule update --init --recursive
docker-setup: docker-build-image docker-populate-volume
docker-rebuild-changed:
docker run \
$(DOCKER_ARGS) \
-e BUILD_TEMP=/host/tmp \
-e SINCE=$(SINCE) \
-e IGNORE=$(_REBUILD_CHANGED_IGNORE) \
$(DOCKER_TAG) \
make _rebuild_changed
docker-make-image:
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
make image
docker-make-clean:
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
make clean
docker-make-clean-ccache:
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
make clean-ccache
docker-make-clean-volume:
docker volume rm $(DOCKER_BUILD_VOLUME)
docker-make-clean-all: docker-make-clean docker-make-clean-volume
docker-config:
docker run $(DOCKER_RUN_ARGS) $(DOCKER_TAG) \
make -C buildroot O=$(VARIANT_OUTPUT) VARIANT=$(VARIANT) $(VARIANT_CONFIG)
docker-pkg-%: docker-config
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
make -C buildroot $* O=$(VARIANT_OUTPUT) VARIANT=$(VARIANT)
docker-shell docker-run:
docker run $(DOCKER_RUN_ARGS) --name=$(DOCKER_TAG) \
--tty --interactive $(DOCKER_TAG) $(ARGS) || :
docker-exec:
docker exec $(DOCKER_ENV_ARGS) --interactive --tty \
$(DOCKER_TAG) /bin/bash -s 'export PS1="\u@\h:\w\$$"'
docker-make-firmware:
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
make firmware
docker-make-flush-rootfs:
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
make flush-rootfs
docker-cp:
docker run $(DOCKER_RUN_ARGS) --name=$(DOCKER_TAG)-copy -d $(DOCKER_TAG)
docker cp $(DOCKER_TAG)-copy:$(SRC) $(DST) || :
docker stop $(DOCKER_TAG)-copy
docker-jenkins:
docker-compose --file scripts/docker-compose.yml --project-directory ${PWD} run pbr
help:
@[[ -x $(shell which less) ]] && \
less $(CURDIR)/scripts/make_help.txt || \
cat $(CURDIR)/scripts/make_help.txt
clang-complete-config:
@./scripts/gen-clang-complete
docker-clang-complete-config:
@docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
./scripts/gen-clang-complete
run-clang-tidy:
@./scripts/run-clang-tidy $(ARGS)
docker-run-clang-tidy:
@docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
./scripts/run-clang-tidy $(ARGS)
run-clang:
@./scripts/run-clang $(ARGS)
docker-run-clang:
docker run $(DOCKER_ARGS) -e CLANG_STDIN=$(CLANG_STDIN) $(DOCKER_TAG) \
./scripts/run-clang $(ARGS)
clang-format:
@./scripts/run-clang-format
docker-clang-format:
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
./scripts/run-clang-format
docker-make-export-toolchain:
docker run $(DOCKER_ARGS) $(DOCKER_TAG) \
make export-toolchain
export-toolchain:
$(BUILD_ENV_ARGS) \
$(MAKE) -C buildroot O=$(VARIANT_OUTPUT) V=$(V) sdk
@echo '>>>' Uninstalling piksi toolchain wrappers...
$(BUILD_ENV_ARGS) \
$(MAKE) -C buildroot O=$(VARIANT_OUTPUT) V=$(V) force-uninstall-toolchain-wrappers
@echo '>>>' Creating buildroot toolchain archive...
tar -cJf piksi_br_toolchain.txz -C buildroot/$(VARIANT_OUTPUT)/host .
ccache-archive:
tar -C buildroot/ccache -czf piksi_br_ccache.tgz .
docker-ccache-archive:
docker run $(DOCKER_RUN_ARGS) $(DOCKER_TAG) \
make ccache-archive
docker-sync-setup:
@./scripts/check-docker-sync
@./scripts/gen-docker-sync $(DOCKER_BUILD_VOLUME) $(UID) $(DOCKER_HOST)
@docker volume create --name=$(DOCKER_BUILD_VOLUME)-sync
@echo "Done, run: make docker-sync-start"
docker-sync-logs:
@docker-sync logs -c .docker-sync.yml
docker-sync-start:
@docker-sync start -c .docker-sync.yml
docker-sync-stop:
@docker-sync stop -c .docker-sync.yml
docker-sync-restart:
@docker-sync stop -c .docker-sync.yml && docker-sync start -c .docker-sync.yml
docker-sync-clean:
@docker-sync clean -c .docker-sync.yml || echo "docker-sync clean failed..."
@rm -f .docker-compose.yml .docker-sync.yml
docker-sync-wait:
@echo -n "Waiting for docker-sync..."
@date >.check-docker-sync
@while [[ "$$(docker run $(DOCKER_RUN_ARGS) $(DOCKER_TAG) cat .check-docker-sync | tr -d $$'\r')" != \
"$$(cat .check-docker-sync)" ]]; do sleep 0.5; done
@echo " done."
docker-sync-check:
@date >.check-docker-sync
@sleep 1
@[[ "$$(docker run $(DOCKER_RUN_ARGS) $(DOCKER_TAG) cat .check-docker-sync | tr -d $$'\r')" == \
"$$(cat .check-docker-sync)" ]]
docker-aws-google-auth:
@./scripts/run-aws-google-auth
show-startup-order:
@find . -name 'S*'|grep etc/init.d|sed 's@\(.*\)etc/init.d/\(.*\)@\2 - \1etc/init.d/\2@'|sort
gen-variant-configs:
@./scripts/gen-variant-configs
.PHONY: help