Learning by doing: Reading books and trying to understand the (code) examples
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.

74 lines
1.9 KiB

  1. # ==========================================
  2. # Unity Project - A Test Framework for C
  3. # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
  4. # [Released under MIT License. Please refer to license.txt for details]
  5. # ==========================================
  6. #We try to detect the OS we are running on, and adjust commands as needed
  7. ifeq ($(OS),Windows_NT)
  8. CLEANUP = del /F /Q
  9. MKDIR = mkdir
  10. TARGET_EXTENSION=.exe
  11. else
  12. CLEANUP = rm -rf
  13. MKDIR = mkdir -p
  14. TARGET_EXTENSION=
  15. endif
  16. UNITY_ROOT=../../../../Unity
  17. C_COMPILER=gcc
  18. CFLAGS = -std=c11
  19. CFLAGS += -Wall
  20. #CFLAGS += -Wextra
  21. CFLAGS += -Werror
  22. CFLAGS += -Wpointer-arith
  23. CFLAGS += -Wcast-align
  24. CFLAGS += -Wwrite-strings
  25. CFLAGS += -Wswitch-default
  26. CFLAGS += -Wunreachable-code
  27. CFLAGS += -Winit-self
  28. CFLAGS += -Wmissing-field-initializers
  29. CFLAGS += -Wno-unknown-pragmas
  30. CFLAGS += -Wstrict-prototypes
  31. CFLAGS += -Wundef
  32. CFLAGS += -Wold-style-definition
  33. CFLAGS += -Wmissing-prototypes
  34. CFLAGS += -Wmissing-declarations
  35. CFLAGS += -g
  36. CFLAGS += -ftest-coverage
  37. CFLAGS += -fprofile-arcs
  38. TARGET_BASE=test_leddriver
  39. TARGET = $(TARGET_BASE)$(TARGET_EXTENSION)
  40. SRC_FILES=\
  41. $(UNITY_ROOT)/extras/fixture/src/unity_fixture.c \
  42. $(UNITY_ROOT)/src/unity.c \
  43. ../test/LedDriverTest.c \
  44. ../test/LedDriverTestRunner.c \
  45. ../test/AllTests.c \
  46. ../src/LedDriver.c
  47. INC_DIRS=-I$(UNITY_ROOT)/src -I$(UNITY_ROOT)/extras/fixture/src
  48. SYMBOLS=
  49. all: clean tests
  50. .PHONY: tests
  51. tests: build/$(TARGET)
  52. build/$(TARGET): test/*.c src/*.h src/*.c
  53. @echo "Compiling"; cd build; $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES) -o $(TARGET)
  54. @echo "Running tests"; ./build/$(TARGET)
  55. @echo "Preparing coverage"; cp build/LedDriver.gc* src/
  56. @echo "Running coverage"; cd src; gcovr -r . -b -p --html --html-details -o ../build/cover/test.html
  57. @echo "Clearing intermediate files"; rm src/*.gc* build/*.gc*
  58. .PHONY: clean
  59. clean:
  60. @echo "Cleaning $<"; $(CLEANUP) build/$(TARGET) build/*.* build/cover/*