Makefile 3.6 KB
Newer Older
N
Niels 已提交
1
.PHONY: pretty clean ChangeLog.md
N
Niels 已提交
2

N
Niels 已提交
3 4
# used programs
RE2C = re2c
N
Niels 已提交
5
SED = sed
N
Niels 已提交
6

N
Niels 已提交
7
# main target
N
Niels 已提交
8 9 10 11
all: json_unit

# clean up
clean:
N
Niels 已提交
12
	rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
N
Niels 已提交
13
	rm -fr benchmarks/files/numbers/*.json
N
Niels 已提交
14
	$(MAKE) clean -Cdoc
N
Niels 已提交
15
	$(MAKE) clean -Ctest
N
Niels 已提交
16

N
Niels 已提交
17 18 19 20 21

##########################################################################
# unit tests
##########################################################################

N
Niels 已提交
22 23 24
# build unit tests
json_unit:
	@$(MAKE) -C test
N
Niels 已提交
25

N
Niels 已提交
26 27 28
# run unit tests
check: json_unit
	test/json_unit "*"
N
Niels 已提交
29

N
Niels 已提交
30 31 32
check-fast: json_unit
	test/json_unit

N
Niels 已提交
33

N
Niels 已提交
34 35 36 37 38 39
##########################################################################
# documentation tests
##########################################################################

# compile example files and check output
doctest:
N
Niels 已提交
40 41 42
	$(MAKE) check_output -C doc


43 44 45 46
##########################################################################
# fuzzing
##########################################################################

N
Niels 已提交
47 48 49 50 51 52
# the overall fuzz testing target
fuzz_testing:
	rm -fr fuzz-testing
	mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
	$(MAKE) fuzz CXX=afl-clang++
	mv fuzz fuzz-testing
53
	find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
N
Niels 已提交
54 55 56
	@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzz"

# the fuzzer binary
57
fuzz: test/src/fuzz.cpp src/json.hpp
N
Niels 已提交
58 59
	$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@

60

N
Niels 已提交
61 62 63
##########################################################################
# static analyzer
##########################################################################
N
Niels 已提交
64

N
Niels 已提交
65
# call cppcheck on the main header file
N
Niels 已提交
66
cppcheck:
N
Niels 已提交
67
	cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1
N
Niels 已提交
68 69 70 71 72 73 74

##########################################################################
# maintainer targets
##########################################################################

# create scanner with re2c
re2c: src/json.hpp.re2c
N
Niels 已提交
75
	$(RE2C) -W --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
N
Niels 已提交
76

N
Niels 已提交
77 78 79 80 81 82
# pretty printer
pretty:
	astyle --style=allman --indent=spaces=4 --indent-modifiers \
	   --indent-switches --indent-preproc-block --indent-preproc-define \
	   --indent-col1-comments --pad-oper --pad-header --align-pointer=type \
	   --align-reference=type --add-brackets --convert-tabs --close-templates \
N
Niels 已提交
83
	   --lineend=linux --preserve-date --suffix=none --formatted \
84 85
	   src/json.hpp src/json.hpp.re2c test/src/*.cpp \
	   benchmarks/benchmarks.cpp doc/examples/*.cpp
N
Niels 已提交
86

N
Niels 已提交
87 88 89 90

##########################################################################
# benchmarks
##########################################################################
N
Niels 已提交
91 92

# benchmarks
N
Niels 已提交
93
json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
N
Niels 已提交
94
	cd benchmarks/files/numbers ; python generate.py
N
Niels 已提交
95
	$(CXX) -std=c++11 $(CXXFLAGS) -DNDEBUG -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@
N
Niels 已提交
96
	./json_benchmarks
N
Niels 已提交
97 98 99 100 101 102


##########################################################################
# changelog
##########################################################################

N
Niels 已提交
103 104
NEXT_VERSION ?= "unreleased"

N
Niels 已提交
105
ChangeLog.md:
N
Niels 已提交
106
	github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
N
Niels 已提交
107
	gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
N
Niels 已提交
108
	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