-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
106 lines (84 loc) · 2.67 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
include UnitTestRunner/UnitTestRunner.mk
include UnitTest/UnitTest.mk
include Unit/Unit.mk
MKDIR := mkdir
RMDIR := rm -rf
CC := gcc
PYTHON := python
UNITSTUBGEN := ./UnitTestSupport.py
BIN := ./bin
OBJ := ./obj
COV := ./cov
PRE := ./pre
LIB := ./UnitTestRunner/lib
OBJS := $(UNITTESTRUNNEROBJS) $(UNITTESTOBJS) $(UNITOBJS)
EXE := $(BIN)/main.exe
CFLAGS := -g -Wall -MMD -fprofile-abs-path -I$(UNITESTRUNNERINCLUDE) -I$(UNITESTINCLUDE) -I$(UNITTESTSTUBINCLUDE)
PREFLAGS:= -I$(UNITINCLUDE) -DUNITTEST=1
COVFLAGS:= -fprofile-arcs -ftest-coverage
LDFLAGS := -lgcov --coverage -L$(LIB)
LDLIBS := -lm
TESTAPPARGS ?= --colour -a -s
# Include the dependency files
-include $(OBJS:%.o=%.d)
.PHONY: all run coverage coverage-html clean stubgen check
# Check for dependencies
check:
echo "# Check for Compiler:"
$(CC) --version
echo "# Check for Python:"
$(PYTHON) --version
echo "# Check for gcovr:"
gcovr --version
# Build the executable
all: $(EXE)
# Link the executable
$(EXE): $(UNITTESTRUNNEROBJS) $(UNITTESTOBJS) $(UNITTESTSTUBOBJS) $(UNITOBJS) | $(BIN)
echo "# Linking $@"
$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
# Compile the UnitTestRunner source files
$(UNITTESTRUNNEROBJS): $(OBJ)/%.o: $(UNITTESTRUNNERSRC)/%.c | $(OBJ)
echo "# Compiling $<"
$(CC) $(CFLAGS) -c $< -o $@
# Compile the UnitTest source files
$(UNITTESTOBJS): $(OBJ)/%.o: $(UNITTESTSRC)/%.c | $(OBJ)
echo "# Compiling $<"
$(CC) $(CFLAGS) -c $< -o $@
# Compile the Unit source files
$(UNITOBJS): $(OBJ)/%.o: $(UNITSRC)/%.c | $(OBJ)
echo "# Compiling $<"
$(CC) $(CFLAGS) $(COVFLAGS) -c $< -o $@
$(UNITTESTSTUBOBJS): $(OBJ)/%.o: $(UNITTESTSTUBSRC)/%.c | $(OBJ)
echo "# Compiling $<"
$(CC) $(CFLAGS) -c $< -o $@
# Create the stubs for the UnitTest
stubgen:
echo # Generating unit stubs
$(PYTHON) $(UNITSTUBGEN) $(UNITSOURCE)
# Create needed directories
$(BIN) $(OBJ) $(COV) $(PRE):
$(MKDIR) -p $@
# Run the executable
run: $(EXE)
echo "# Running $<"
$< ${TESTAPPARGS}
# Run the executable with coverage analysis with summary on stdout
coverage: run | $(COV)
echo "# Running coverage analysis"
gcovr -r . -s
# Run the executable with coverage analysis with html output
coverage-html: run | $(COV)
echo "# Running coverage analysis with html output"
gcovr -r . --html --html-details -o ${COV}/index.html
# Preprocess the source files for automatic unit stub generation
#$(UNITPREPARE): $(PRE)/%.i: $(UNITSRC)/%.c | $(PRE)
# echo "# Preprocessing $<"
# $(CC) $(PREFLAGS) -E $< -o $@
# Generate the unit stubs
# preprocess: $(UNITPREPARE)
# Clean the build
clean:
echo "# Cleaning"
$(RMDIR) $(OBJ) $(BIN) $(COV) $(PRE) *.txt
#$(UNITTESTSTUBINCLUDE)/*.h $(UNITTESTSTUBSRC)/*.c
# End of makefile