You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
2.7 KiB
125 lines
2.7 KiB
ifeq ($(OS),Windows_NT)
|
|
ifeq ($(shell uname -s),) # not in a bash-like shell
|
|
CLEANUP = del /F /Q
|
|
MKDIR = mkdir
|
|
else # in a bash-like shell, like msys
|
|
CLEANUP = rm -f
|
|
MKDIR = mkdir -p
|
|
endif
|
|
TARGET_EXTENSION=.exe
|
|
else
|
|
CLEANUP = rm -f
|
|
MKDIR = mkdir -p
|
|
TARGET_EXTENSION=out
|
|
endif
|
|
|
|
.PHONY: cleandep
|
|
.PHONY: clean
|
|
.PHONY: test
|
|
.PHONY: runners
|
|
|
|
PATHU = unity/src/
|
|
PATHS = src/
|
|
PATHT = test/
|
|
PATHTR = test/runners/
|
|
PATHL = lib/
|
|
PATHB = build/
|
|
PATHD = build/depends/
|
|
PATHO = build/objs/
|
|
PATHR = build/results/
|
|
|
|
BUILD_PATHS = $(PATHB) $(PATHD) $(PATHO) $(PATHR) $(PATHL)
|
|
|
|
COMPILE = gcc -c
|
|
LINK = gcc
|
|
DEPEND = gcc -MM -MG -MF
|
|
CFLAGS = -I. -I$(PATHU) -I$(PATHS) -I$(PATHL) -DTEST
|
|
|
|
CFLAGS += -std=c99
|
|
CFLAGS += -Wall
|
|
CFLAGS += -Wextra
|
|
CFLAGS += -Wpointer-arith
|
|
CFLAGS += -Wcast-align
|
|
# CFLAGS += -Wwrite-strings
|
|
CFLAGS += -Wswitch-default
|
|
CFLAGS += -Wunreachable-code
|
|
CFLAGS += -Winit-self
|
|
CFLAGS += -Wmissing-field-initializers
|
|
CFLAGS += -Wno-unknown-pragmas
|
|
CFLAGS += -Wstrict-prototypes
|
|
CFLAGS += -Wundef
|
|
CFLAGS += -Wold-style-definition
|
|
|
|
RUNNERS = $(patsubst $(PATHT)%.c,$(PATHTR)%_Runner.c, $(wildcard $(PATHT)*.c))
|
|
|
|
runners: $(RUNNERS) test
|
|
|
|
RESULTS = $(patsubst $(PATHTR)test_%_Runner.c,$(PATHR)test_%.txt, $(RUNNERS))
|
|
DEPS = $(patsubst $(PATHT)test_%.c,$(PATHD)test_%.d, $(wildcard $(PATHT)*.c))
|
|
|
|
PASSED = `grep -s PASS $(PATHR)*.txt`
|
|
FAIL = `grep -s FAIL $(PATHR)*.txt`
|
|
IGNORE = `grep -s IGNORE $(PATHR)*.txt`
|
|
|
|
test: $(BUILD_PATHS) $(RESULTS) $(DEPS)
|
|
@echo "===============UNIT TEST RESULTS===============\n"
|
|
@echo "---------------IGNORES---------------"
|
|
@echo "$(IGNORE)"
|
|
@echo "---------------FAILURES---------------"
|
|
@echo "$(FAIL)"
|
|
@echo "---------------PASSED---------------"
|
|
@echo "$(PASSED)"
|
|
@echo "\nDONE"
|
|
|
|
$(PATHR)%.txt: $(PATHB)%.$(TARGET_EXTENSION)
|
|
-./$< > $@ 2>&1
|
|
|
|
$(PATHB)test_%.$(TARGET_EXTENSION): $(PATHO)test_%.o $(PATHO)test_%_Runner.o $(PATHO)%.o $(PATHU)unity.o #$(PATHD)test_%.d
|
|
$(LINK) -o $@ $^
|
|
|
|
$(PATHO)%.o: $(PATHTR)%.c
|
|
$(COMPILE) $(CFLAGS) $< -o $@
|
|
|
|
$(PATHO)%.o:: $(PATHT)%.c
|
|
$(COMPILE) $(CFLAGS) $< -o $@
|
|
|
|
$(PATHO)%.o:: $(PATHS)%.c
|
|
$(COMPILE) $(CFLAGS) $< -o $@
|
|
|
|
$(PATHO)%.o:: $(PATHL)%.c
|
|
$(COMPILE) $(CFLAGS) $< -o $@
|
|
|
|
$(PATHO)%.o:: $(PATHU)%.c $(PATHU)%.h
|
|
$(COMPILE) $(CFLAGS) $< -o $@
|
|
|
|
$(PATHD)%.d:: $(PATHT)%.c
|
|
$(DEPEND) $@ $<
|
|
|
|
$(PATHTR)%.c:
|
|
ruby unity/auto/generate_test_runner.rb $(patsubst $(PATHTR)%_Runner.c,$(PATHT)%.c, $@) $@
|
|
|
|
$(PATHB):
|
|
$(MKDIR) $(PATHB)
|
|
|
|
$(PATHD):
|
|
$(MKDIR) $(PATHD)
|
|
|
|
$(PATHO):
|
|
$(MKDIR) $(PATHO)
|
|
|
|
$(PATHR):
|
|
$(MKDIR) $(PATHR)
|
|
|
|
clean:
|
|
$(CLEANUP) $(PATHO)*.o
|
|
$(CLEANUP) $(PATHB)*.$(TARGET_EXTENSION)
|
|
$(CLEANUP) $(PATHR)*.txt
|
|
$(CLEANUP) $(PATHTR)*.c
|
|
|
|
cleandep:
|
|
$(CLEANUP) $(PATHD)*.d
|
|
|
|
.PRECIOUS: $(PATHB)test_%.$(TARGET_EXTENSION)
|
|
.PRECIOUS: $(PATHD)%.d
|
|
.PRECIOUS: $(PATHO)%.o
|
|
.PRECIOUS: $(PATHR)%.txt
|
|
|