-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (63 loc) · 1.65 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
BUILDDIR=main/build
MAIN_INO=main/main.ino
LIB_DIRS=libraries/NTPLight libraries/TWAMP8266
CPP_FILES=$(foreach libdir,$(LIB_DIRS),$(wildcard $(libdir)/*.cpp))
H_FILES= $(foreach libdir,$(LIB_DIRS),$(wildcard $(libdir)/*.h))
.PHONY: flash tty clean format-diff format
all: help
help:
@echo "available targets:"
@echo " build : compile firmware"
@echo " flash : flash firmware"
@echo " tty : connect to serial console"
@echo " clean : remove build artefacts"
@echo " format-diff : show a diff of the changes clang-format would make"
@echo " format : Inplace format source file with clang-format"
clean:
@rm -rf $(BUILDDIR)
build:
@podman run \
--rm \
-v $$(pwd):/workspace \
arduino-cli \
arduino-cli compile -e \
--warnings all \
--fqbn esp8266:esp8266:d1_mini_clone \
--libraries /workspace/libraries \
/workspace/main
flash:
@podman run \
--rm \
-v $$(pwd):/workspace \
--device=/dev/ttyUSB0 \
arduino-cli \
arduino-cli upload \
-p /dev/ttyUSB0 \
--fqbn esp8266:esp8266:d1_mini_clone \
-i /workspace/main/build/esp8266.esp8266.d1_mini_clone/main.ino.bin
tty:
@screen /dev/ttyUSB0 115200
format-diff:
@clang-format \
--assume-filename=main.cpp \
--style=Google \
$(MAIN_INO) \
| diff -u $(MAIN_INO) - || true
@$(foreach infile,$(CPP_FILES) $(H_FILES), clang-format \
--style=Google \
$(infile) \
| diff -u $(infile) - || true\
;)
format:
@clang-format \
-i \
--assume-filename=main.cpp \
--style=Google \
$(MAIN_INO) \
|| true
@$(foreach infile,$(CPP_FILES) $(H_FILES), clang-format \
-i \
--style=Google \
$(infile) \
|| true\
;)