-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
92 lines (71 loc) · 2.58 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
#
# Copyright (c) 2019-2022 Blue Clover Devices
#
# SPDX-License-Identifier: Apache-2.0
#
PRJTAG := ly10-zephyr-fw
# Makefile default shell is /bin/sh which does not implement `source`.
SHELL := /bin/bash
BASE_PATH := $(realpath .)
DIST := $(BASE_PATH)/dist
.PHONY: default
default: build
.PHONY: GIT-VERSION-FILE
GIT-VERSION-FILE:
@sh ./GIT-VERSION-GEN
-include GIT-VERSION-FILE
VERSION_TAG := $(patsubst v%,%,$(GIT_DESC))
DOCKER_BUILD_ARGS :=
DOCKER_BUILD_ARGS += --network=host
DOCKER_RUN_ARGS :=
DOCKER_RUN_ARGS += --network=none
ZEPHYR_TAG := 3.0.0
ZEPHYR_SYSROOT := /usr/src/zephyr-$(ZEPHYR_TAG)/zephyr
ZEPHYR_USRROOT := $(HOME)/src/zephyr-$(ZEPHYR_TAG)/zephyr
BOARDS_APP :=
BOARDS_APP += blueclover_plt_demo_v2_nrf52832
APP_TARGETS := $(patsubst %,build.%/app/zephyr/zephyr.hex,$(BOARDS_APP))
build.%/app/zephyr/zephyr.hex:
if [ -d $(ZEPHYR_USRROOT) ]; then source $(ZEPHYR_USRROOT)/zephyr-env.sh ; \
elif [ -d $(ZEPHYR_SYSROOT) ]; then source $(ZEPHYR_SYSROOT)/zephyr-env.sh ; \
else echo "No Zephyr"; fi && \
west build --build-dir build.$*/app --pristine auto \
--board $* app
.PHONY: versions
versions:
@echo "GIT_DESC: $(GIT_DESC)"
@echo "VERSION_TAG: $(VERSION_TAG)"
.PHONY: build
build: $(APP_TARGETS)
.PHONY: clean
clean:
-rm -rf $(BINS) build build.*
.PHONY: prereq
prereq:
pip3 install -r requirements.txt
install -d zephyrproject
cd zephyrproject && west init --mr v$(ZEPHYR_TAG)
cd zephyrproject && west update
pip3 install -r $(ZEPHYR_USRROOT)/scripts/requirements.txt
.PHONY: dist-prep
dist-prep:
-install -d $(DIST)
.PHONY: dist-clean
dist-clean:
-rm -rf $(DIST)
.PHONY: dist
dist: dist-clean dist-prep build
install -m 666 build.blueclover_plt_demo_v2_nrf52832/app/zephyr/zephyr.hex dist/app-pltdemov2-$(VERSION_TAG).hex
install -m 666 build.blueclover_plt_demo_v2_nrf52832/app/zephyr/zephyr.elf dist/app-pltdemov2-$(VERSION_TAG).elf
install -m 666 build.blueclover_plt_demo_v2_nrf52832/app/zephyr/zephyr.map dist/app-pltdemov2-$(VERSION_TAG).map
sed 's/{{BOARD}}/pltdemov2/g; s/{{VERSION}}/$(VERSION_TAG)/g' test-suites/suite-demo-board-zephyr.yaml.template > dist/suite-pltdemov2-board-zephyr-$(VERSION_TAG).yaml
.PHONY: deploy
deploy:
pltcloud -t "$(API_TOKEN)" -f "dist/*" -v "v$(VERSION_TAG)" -p "$(PROJECT_UUID)"
.PHONY: docker
docker: dist-prep
docker build $(DOCKER_BUILD_ARGS) -t "bcdevices/$(PRJTAG)" .
-@docker rm -f "$(PRJTAG)-$(VERSION_TAG)" 2>/dev/null
docker run $(DOCKER_RUN_ARGS) --name "$(PRJTAG)-$(VERSION_TAG)" -t "bcdevices/$(PRJTAG)" \
/bin/bash -c "make build dist"
docker cp "$(PRJTAG)-$(VERSION_TAG):/usr/src/dist" $(BASE_PATH)