-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
67 lines (51 loc) · 1.69 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
################################################################################
# Compile firmware in the cloud and flash to a device
#
# make firmware
# Compile in the cloud
# make flash
# Flash to a device in DFU mode (flashing yellow)
#
################################################################################
BUILD_DIR ?= build
PLATFORM ?= photon
FIRMWARE_BIN ?= $(BUILD_DIR)/app-reminder.bin
firmware:
$(MKDIR_P) $(BUILD_DIR)
particle compile $(PLATFORM) firmware --saveTo $(FIRMWARE_BIN)
flash:
particle flash --usb $(FIRMWARE_BIN)
################################################################################
# Build and run unit tests
#
# make tests
# Compile and run the tests
# make watch
# Continuously compile and run the tests
#
# Makefile derived from https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
################################################################################
TARGET_EXEC ?= test
SRC_DIRS ?= tests
SRCS := $(shell find $(SRC_DIRS) -name *.cpp)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
INC_DIRS := $(SRC_DIRS)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
# Use -MMD and -MP to generate .d dependency files
CXXFLAGS += $(INC_FLAGS) -g -MMD -MP -DUNIT_TEST -std=c++11
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CXX) $(OBJS) -o $@ $(LDFLAGS) $(LDLIBS)
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CXXFLAGS) $(CFLAGS) -c $< -o $@
tests: $(BUILD_DIR)/$(TARGET_EXEC)
./$(BUILD_DIR)/$(TARGET_EXEC)
clean:
$(RM) -r $(BUILD_DIR)
-include $(DEPS)
# Use the rerun command to continuously build and run the unit tests
watch:
rerun -x -p '{*.cpp,*.h,Makefile}' make tests
MKDIR_P ?= mkdir -p
.PHONY: clean run watch firmware flash