The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

111 lines
3.7 KiB

4 weeks ago
  1. .PHONY: pretty clean ChangeLog.md
  2. # used programs
  3. RE2C = re2c
  4. SED = sed
  5. # main target
  6. all: json_unit
  7. # clean up
  8. clean:
  9. rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
  10. rm -fr benchmarks/files/numbers/*.json
  11. $(MAKE) clean -Cdoc
  12. $(MAKE) clean -Ctest
  13. ##########################################################################
  14. # unit tests
  15. ##########################################################################
  16. # build unit tests
  17. json_unit:
  18. @$(MAKE) -C test
  19. # run unit tests
  20. check: json_unit
  21. test/json_unit "*"
  22. check-fast: json_unit
  23. test/json_unit
  24. ##########################################################################
  25. # documentation tests
  26. ##########################################################################
  27. # compile example files and check output
  28. doctest:
  29. $(MAKE) check_output -C doc
  30. ##########################################################################
  31. # fuzzing
  32. ##########################################################################
  33. # the overall fuzz testing target
  34. fuzz_testing:
  35. rm -fr fuzz-testing
  36. mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
  37. $(MAKE) fuzz CXX=afl-clang++
  38. mv fuzz fuzz-testing
  39. find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
  40. @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzz"
  41. # the fuzzer binary
  42. fuzz: test/src/fuzz.cpp src/json.hpp
  43. $(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@
  44. ##########################################################################
  45. # static analyzer
  46. ##########################################################################
  47. # call cppcheck on the main header file
  48. cppcheck:
  49. cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1
  50. clang_sanitize: clean
  51. CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE)
  52. ##########################################################################
  53. # maintainer targets
  54. ##########################################################################
  55. # create scanner with re2c
  56. re2c: src/json.hpp.re2c
  57. $(RE2C) -W --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
  58. # pretty printer
  59. pretty:
  60. astyle --style=allman --indent=spaces=4 --indent-modifiers \
  61. --indent-switches --indent-preproc-block --indent-preproc-define \
  62. --indent-col1-comments --pad-oper --pad-header --align-pointer=type \
  63. --align-reference=type --add-brackets --convert-tabs --close-templates \
  64. --lineend=linux --preserve-date --suffix=none --formatted \
  65. src/json.hpp src/json.hpp.re2c test/src/*.cpp \
  66. benchmarks/benchmarks.cpp doc/examples/*.cpp
  67. ##########################################################################
  68. # benchmarks
  69. ##########################################################################
  70. # benchmarks
  71. json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
  72. cd benchmarks/files/numbers ; python generate.py
  73. $(CXX) -std=c++11 $(CXXFLAGS) -DNDEBUG -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@
  74. ./json_benchmarks
  75. ##########################################################################
  76. # changelog
  77. ##########################################################################
  78. NEXT_VERSION ?= "unreleased"
  79. ChangeLog.md:
  80. github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
  81. gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
  82. gsed -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md