-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.unittest
74 lines (61 loc) · 1.73 KB
/
Makefile.unittest
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
BUILD_ROOT = build/test
ACUTEST = test/acutest.h
CXXFLAGS =
CXXFLAGS += -g
CXXFLAGS += -std=gnu++14
CXXFLAGS += -w
CXXFLAGS += -Wall
CXXFLAGS += -Wextra
CXXFLAGS += -Wfatal-errors
CXXFLAGS += -Werror
CXXFLAGS += -O0
CXXFLAGS += -fdata-sections
CXXFLAGS += -fdiagnostics-color=always
CXXFLAGS += -ffunction-sections
CXXFLAGS += -flto
CXXFLAGS += -fno-devirtualize
CXXFLAGS += -fno-threadsafe-statics
CXXFLAGS += -fpermissive
CXXFLAGS += -pedantic
CXXFLAGS += -D TEST
INCLUDE_DIRECTORIES = $(dir $(wildcard test/ test/*/ test/*/*/ src/*/))
COMPILER := $(CXX) $(CXXFLAGS) $(addprefix -I,$(INCLUDE_DIRECTORIES))
$(ACUTEST):
wget -O $(ACUTEST) https://raw.githubusercontent.com/mity/acutest/master/include/acutest.h
$(BUILD_ROOT):
mkdir -p $(BUILD_ROOT)
$(BUILD_ROOT)/%.o: test/%
$(COMPILER) -c $< -o $@
$(BUILD_ROOT)/%.o: test/*/%
$(COMPILER) -c $< -o $@
$(BUILD_ROOT)/%.o: src/*/%
$(COMPILER) -c $< -o $@
TEST_OBJS = \
array_utils.cpp.o \
combo.cpp.o \
combo_handler.cpp.o \
dalsik_eeprom.cpp.o \
extended_key_event.cpp.o \
held_up_key.cpp.o \
held_up_keys.cpp.o \
key.cpp.o \
key_event_handler.cpp.o \
keyboard.cpp.o \
keymap.cpp.o \
mock_eeprom.cpp.o \
mock_keymap.cpp.o \
pressed_keys.cpp.o \
tapdance.cpp.o \
tapdance_handler.cpp.o \
HID.cpp.o \
Serial.cpp.o \
test_suite.cpp.o
TEST_DEPS = $(addprefix $(BUILD_ROOT)/, $(TEST_OBJS))
$(BUILD_ROOT)/test_suite: $(TEST_DEPS)
echo ">> Linking $@"
$(COMPILER) $^ -o $@
test: $(ACUTEST) $(BUILD_ROOT) $(BUILD_ROOT)/test_suite
$(BUILD_ROOT)/test_suite $(TEST_NAME)
# https://www.youtube.com/watch?v=NPdagdEOBnI
# https://github.com/JeremiahK96/auto-makefile/blob/main/Makefile
# https://gist.github.com/dvdfreitag/70ca95aae0b50cdff7f4cc87649a52ce