135375f98Sopenharmony_ciCC = gcc 235375f98Sopenharmony_ciifeq ($(shell uname -s), Darwin) 335375f98Sopenharmony_ciCC = clang 435375f98Sopenharmony_ciendif 535375f98Sopenharmony_ciifeq ($(findstring clang, $(CC)), clang) 635375f98Sopenharmony_ciE = -Weverything 735375f98Sopenharmony_ciCFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes 835375f98Sopenharmony_ciCFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn 935375f98Sopenharmony_ciendif 1035375f98Sopenharmony_ciCFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror 1135375f98Sopenharmony_ci#CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros 1235375f98Sopenharmony_ciCFLAGS += -Wno-switch-enum -Wno-double-promotion 1335375f98Sopenharmony_ciCFLAGS += -Wno-poison-system-directories 1435375f98Sopenharmony_ciCFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ 1535375f98Sopenharmony_ci -Wstrict-prototypes -Wswitch-default -Wundef 1635375f98Sopenharmony_ci#DEBUG = -O0 -g 1735375f98Sopenharmony_ciCFLAGS += $(DEBUG) 1835375f98Sopenharmony_ciUNITY_SUPPORT_64 = -D UNITY_SUPPORT_64 1935375f98Sopenharmony_ciUNITY_INCLUDE_DOUBLE = -D UNITY_INCLUDE_DOUBLE 2035375f98Sopenharmony_ciDEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy 2135375f98Sopenharmony_ciDEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\) 2235375f98Sopenharmony_ciDEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy 2335375f98Sopenharmony_ciDEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\) 2435375f98Sopenharmony_ciDEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE) 2535375f98Sopenharmony_ciSRC1 = ../src/unity.c tests/test_unity_arrays.c build/test_unity_arraysRunner.c 2635375f98Sopenharmony_ciSRC2 = ../src/unity.c tests/test_unity_core.c build/test_unity_coreRunner.c 2735375f98Sopenharmony_ciSRC3 = ../src/unity.c tests/test_unity_doubles.c build/test_unity_doublesRunner.c 2835375f98Sopenharmony_ciSRC4 = ../src/unity.c tests/test_unity_floats.c build/test_unity_floatsRunner.c 2935375f98Sopenharmony_ciSRC5 = ../src/unity.c tests/test_unity_integers.c build/test_unity_integersRunner.c 3035375f98Sopenharmony_ciSRC6 = ../src/unity.c tests/test_unity_integers_64.c build/test_unity_integers_64Runner.c 3135375f98Sopenharmony_ciSRC7 = ../src/unity.c tests/test_unity_memory.c build/test_unity_memoryRunner.c 3235375f98Sopenharmony_ciSRC8 = ../src/unity.c tests/test_unity_strings.c build/test_unity_stringsRunner.c 3335375f98Sopenharmony_ciINC_DIR = -I ../src 3435375f98Sopenharmony_ciCOV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src 3535375f98Sopenharmony_ciBUILD_DIR = build 3635375f98Sopenharmony_ciTARGET = build/testunity-cov.exe 3735375f98Sopenharmony_ci 3835375f98Sopenharmony_ci# To generate coverage, call 'make -s', the default target runs. 3935375f98Sopenharmony_ci# For verbose output of all the tests, run 'make test'. 4035375f98Sopenharmony_cidefault: coverage 4135375f98Sopenharmony_ci.PHONY: default coverage test clean 4235375f98Sopenharmony_cicoverage: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8) 4335375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 4435375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC1), ../$i) $(COV_FLAGS) -o ../$(TARGET) 4535375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 4635375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 4735375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 4835375f98Sopenharmony_ci gcov unity.c | head -3 4935375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 5035375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 5135375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC2), ../$i) $(COV_FLAGS) -o ../$(TARGET) 5235375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 5335375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 5435375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 5535375f98Sopenharmony_ci gcov unity.c | head -3 5635375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 5735375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 5835375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC3), ../$i) $(COV_FLAGS) -o ../$(TARGET) 5935375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 6035375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 6135375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 6235375f98Sopenharmony_ci gcov unity.c | head -3 6335375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 6435375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 6535375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC4), ../$i) $(COV_FLAGS) -o ../$(TARGET) 6635375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 6735375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 6835375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 6935375f98Sopenharmony_ci gcov unity.c | head -3 7035375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 7135375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 7235375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC5), ../$i) $(COV_FLAGS) -o ../$(TARGET) 7335375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 7435375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 7535375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 7635375f98Sopenharmony_ci gcov unity.c | head -3 7735375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 7835375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 7935375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC6), ../$i) $(COV_FLAGS) -o ../$(TARGET) 8035375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 8135375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 8235375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 8335375f98Sopenharmony_ci gcov unity.c | head -3 8435375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 8535375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 8635375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC7), ../$i) $(COV_FLAGS) -o ../$(TARGET) 8735375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 8835375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 8935375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 9035375f98Sopenharmony_ci gcov unity.c | head -3 9135375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 9235375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 9335375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC8), ../$i) $(COV_FLAGS) -o ../$(TARGET) 9435375f98Sopenharmony_ci rm -f $(BUILD_DIR)/*.gcda 9535375f98Sopenharmony_ci ./$(TARGET) | grep 'Tests\|]]]' -A1 9635375f98Sopenharmony_ci cd $(BUILD_DIR) && \ 9735375f98Sopenharmony_ci gcov unity.c | head -3 9835375f98Sopenharmony_ci grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true 9935375f98Sopenharmony_ci 10035375f98Sopenharmony_citest: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8) 10135375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC1) -o $(TARGET) 10235375f98Sopenharmony_ci ./$(TARGET) 10335375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC2) -o $(TARGET) 10435375f98Sopenharmony_ci ./$(TARGET) 10535375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC3) -o $(TARGET) 10635375f98Sopenharmony_ci ./$(TARGET) 10735375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC4) -o $(TARGET) 10835375f98Sopenharmony_ci ./$(TARGET) 10935375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC5) -o $(TARGET) 11035375f98Sopenharmony_ci ./$(TARGET) 11135375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC6) -o $(TARGET) 11235375f98Sopenharmony_ci ./$(TARGET) 11335375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC7) -o $(TARGET) 11435375f98Sopenharmony_ci ./$(TARGET) 11535375f98Sopenharmony_ci $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC8) -o $(TARGET) 11635375f98Sopenharmony_ci ./$(TARGET) 11735375f98Sopenharmony_ci 11835375f98Sopenharmony_ci# Compile only, for testing that preprocessor detection works 11935375f98Sopenharmony_ciUNITY_C_ONLY =-c ../src/unity.c -o $(BUILD_DIR)/unity.o 12035375f98Sopenharmony_ciintDetection: 12135375f98Sopenharmony_ci $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_STDINT_H 12235375f98Sopenharmony_ci $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_LIMITS_H 12335375f98Sopenharmony_ci 12435375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_arraysRunner.c: tests/test_unity_arrays.c | $(BUILD_DIR) 12535375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_arrays.c > $@ 12635375f98Sopenharmony_ci 12735375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_coreRunner.c: tests/test_unity_core.c | $(BUILD_DIR) 12835375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_core.c > $@ 12935375f98Sopenharmony_ci 13035375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_doublesRunner.c: tests/test_unity_doubles.c | $(BUILD_DIR) 13135375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_doubles.c > $@ 13235375f98Sopenharmony_ci 13335375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_floatsRunner.c: tests/test_unity_floats.c | $(BUILD_DIR) 13435375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_floats.c > $@ 13535375f98Sopenharmony_ci 13635375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_integersRunner.c: tests/test_unity_integers.c | $(BUILD_DIR) 13735375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_integers.c > $@ 13835375f98Sopenharmony_ci 13935375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_integers_64Runner.c: tests/test_unity_integers_64.c | $(BUILD_DIR) 14035375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_integers_64.c > $@ 14135375f98Sopenharmony_ci 14235375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_memoryRunner.c: tests/test_unity_memory.c | $(BUILD_DIR) 14335375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_memory.c > $@ 14435375f98Sopenharmony_ci 14535375f98Sopenharmony_ci$(BUILD_DIR)/test_unity_stringsRunner.c: tests/test_unity_strings.c | $(BUILD_DIR) 14635375f98Sopenharmony_ci awk $(AWK_SCRIPT) tests/test_unity_strings.c > $@ 14735375f98Sopenharmony_ci 14835375f98Sopenharmony_ciAWK_SCRIPT=\ 14935375f98Sopenharmony_ci '/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0; line[u++]=NR } \ 15035375f98Sopenharmony_ci END{ print "\#include \"unity.h\" /* Autogenerated by awk in Makefile */" ; \ 15135375f98Sopenharmony_ci for (i=0; i<d; i++) { print declarations[i] ";" } \ 15235375f98Sopenharmony_ci print "int main(void)\n{\n UnityBegin(\"" FILENAME "\");" ; \ 15335375f98Sopenharmony_ci for (i=0; i<t; i++) { print " RUN_TEST(" tests[i] ", " line[i] ");" } \ 15435375f98Sopenharmony_ci print " return UNITY_END();\n}" }' 15535375f98Sopenharmony_ci 15635375f98Sopenharmony_ci$(BUILD_DIR): 15735375f98Sopenharmony_ci mkdir -p $(BUILD_DIR) 15835375f98Sopenharmony_ci 15935375f98Sopenharmony_ciclean: 16035375f98Sopenharmony_ci rm -f $(TARGET) $(BUILD_DIR)/*.gc* $(BUILD_DIR)/test_unity_*Runner.c 161