This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
161 lines (133 loc) · 3.62 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
# USAGE:
# board selection:
# env var TARGET_BOARD
#
PROJECT_NAME := jolt_os
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
export JOLT_WALLET_PATH := $(dir $(MKFILE_PATH))
export IDF_TOOLS_PATH := $(JOLT_WALLET_PATH)/xtensa-esp32-elf
export IDF_PATH := $(JOLT_WALLET_PATH)/esp-idf
# Have to add current path to EXTRA_COMPONENT_DIRS so unit tester will work.
# Unfortunately, JoltOS gets built twice.
EXTRA_COMPONENT_DIRS := \
$(abspath .) \
$(abspath jolt_os) \
$(IDF_PATH)/tools/unit-test-app/components/
CFLAGS += \
-Werror \
-DJOLT_OS
# cfg.mk first to override sdkconfig.defaults
# set targetname via `TARGET_BOARD=target`
include $(JOLT_WALLET_PATH)/make/cfg.mk
include $(IDF_PATH)/make/project.mk
include $(JOLT_WALLET_PATH)/make/common.mk
# Executables that generate/apply binary patches
HDIFFZ=components/esp_hdiffz/HDiffPatch/hdiffz
HPATCHZ=components/esp_hdiffz/HDiffPatch/hpatchz
ifeq ("$(shell uname)", "Darwin")
# Mac OS X platform
INSTALL_SYSTEM_DEPENDENCIES = \
printf "No system-dependencies rules for MacOS\n" \
&& exit 1
else ifeq ("$(shell expr substr $$(uname -s) 1 5)", "Linux")
# GNU/Linux platform
OS=$(shell lsb_release -si)
ifeq ($(OS), Ubuntu)
INSTALL_SYSTEM_DEPENDENCIES = \
sudo apt-get update && sudo apt-get install -y \
bison \
ccache \
cmake \
flex \
git \
gperf \
libffi-dev \
libssl-dev \
libusb-1.0 \
libz-dev \
ninja-build \
protobuf-compiler \
python3 \
python3-pip \
python3-setuptools \
wget
else
INSTALL_SYSTEM_DEPENDENCIES = \
printf "No rules for your linux distribution: \"$(OS)\"\n" \
&& exit 1
endif
else
INSTALL_SYSTEM_DEPENDENCIES = \
printf "No system-dependencies rules for your operating system\n" \
&& exit 1
endif
.PHONY: install tests test-menu lint compilation_db cppcheck decode \
system-dependencies
all: $(PB_GENS)
system-dependencies:
$(INSTALL_SYSTEM_DEPENDENCIES)
$(HDIFFZ): system-dependencies
# Build the hdiffpatch generator binary
cd components/esp_hdiffz/HDiffPatch \
&& make
hdiffz: $(HDIFFZ) ;
install: system-dependencies
mkdir -p $(IDF_TOOLS_PATH)
pip3 install -r requirements.txt
pip3 install -r $(IDF_PATH)/requirements.txt
$(IDF_PATH)/tools/idf_tools.py install
tests: $(PB_GENS)
CFLAGS='-DUNIT_TESTING=1' \
$(MAKE) \
TEST_COMPONENTS='jolt_os' \
flash monitor;
test-menu: $(PB_GENS)
CFLAGS='-DJOLT_GUI_TEST_MENU=1' $(MAKE)
lint:
find jolt_os/ \
\( \
-iname '*.h' \
-o -iname '*.c' \
-o -iname '*.cpp' \
-o -iname '*.hpp' \
\) \
! -iname 'jolt_lib.c' \
! -path 'jolt_os/hal/lv_drivers/*' \
! -path 'jolt_os/hal/storage/cryptoauthlib/*' \
! -path 'jolt_os/jolt_gui/custom_fonts/*' \
| xargs clang-format -style=file -i -fallback-style=google
compile_commands.json:
rm -rf build
bear $(MAKE) -j
compilation_db: compile_commands.json
cppcheck: compile_commands.json
cppcheck \
--project=compile_commands.json \
--enable=all \
--suppressions-list=.cfg/cppcheck-suppressions.txt \
--inline-suppr \
–template=gcc \
--force \
-ijolt_os/hal/lv_drivers/ \
jolt_os/ 2>cppcheck.log
echo ""
echo "--------------------------"
echo "---- cppcheck results ----"
echo "--------------------------"
cat cppcheck.log
echo ""
clean-jolt:
rm -rf build/jolt_os
rm -rf build/jolt_wallet
rm -f $(PB_GENS)
clean: clean-jolt
compress: all
# Compress firmware build/jolt.bin -> build/jolt.bin.gz
python3 pyutils/ota_compress.py
decode:
# usage: make decode 0x40...:\0x3ff 0x40...
echo "\n"
xtensa-esp32-elf-addr2line -pfiaC -e build/$(PROJECT_NAME).elf $(filter-out $@,$(MAKECMDGOALS))
%:
@:
print-% : ; @echo $* = $($*)