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.

79 lines
2.0 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 cover
  50. build/$(TARGET): test/*.c src/*.h src/*.c
  51. @$(MKDIR) build
  52. @$(MKDIR) build/cover
  53. @echo "Compiling"; cd build; $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES) -o $(TARGET)
  54. .PHONY: tests
  55. tests: build/$(TARGET)
  56. @echo "Running tests"; ./build/$(TARGET)
  57. .PHONY: cover
  58. cover: tests
  59. @echo "Preparing coverage"; cp build/LedDriver.gc* src/
  60. @echo "Running coverage"; cd src; gcovr -r . -b -p --html --html-details -o ../build/cover/test.html
  61. @echo "Clearing intermediate files"; rm src/*.gc* build/*.gc*
  62. .PHONY: clean
  63. clean:
  64. @echo "Cleaning $<"; $(CLEANUP) build