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.

72 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=../../../../../Git/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_sprintf
  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/SprintfTest.c \
  44. ../test/SprintfTestRunner.c \
  45. ../test/AllTests.c
  46. INC_DIRS=-I$(UNITY_ROOT)/src -I$(UNITY_ROOT)/extras/fixture/src
  47. SYMBOLS=
  48. all: clean tests
  49. .PHONY: tests
  50. tests: build/$(TARGET)
  51. build/$(TARGET): test/*.c
  52. @echo "Compiling"; cd build; $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES) -o $(TARGET)
  53. @echo "Running tests"; ./build/$(TARGET)
  54. @echo "Preparing coverage"; cp build/*.gc* test/
  55. @echo "Running coverage"; cd test; gcovr -r . -b -p --html --html-details -o ../build/cover/$(TARGET).html
  56. @echo "Clearing intermediate files"; rm test/*.gc* build/*.gc*
  57. .PHONY: clean
  58. clean:
  59. @echo "Cleaning $<"; $(CLEANUP) build/$(TARGET) build/cover/*