| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
ifndef VERBOSE |
| 17 |
MAKEFLAGS += --no-print-directory |
| 18 |
endif |
| 19 |
|
| 20 |
.PHONY:all |
| 21 |
all: build-it |
| 22 |
|
| 23 |
.PHONY:debug |
| 24 |
debug: |
| 25 |
cmake -DCMAKE_BUILD_TYPE:string=Debug -S . -B build |
| 26 |
$(MAKE) -C build |
| 27 |
|
| 28 |
.PHONY:test |
| 29 |
test: build-it |
| 30 |
cd build; ctest |
| 31 |
|
| 32 |
.PHONY:clean |
| 33 |
clean: build/Makefile |
| 34 |
$(MAKE) -C build clean |
| 35 |
|
| 36 |
.PHONY:package |
| 37 |
package: build/Makefile |
| 38 |
$(MAKE) -C build package |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
.PHONY:bump bump-patch bump-minor bump-major |
| 46 |
bump: |
| 47 |
@test -n "$(VERSION)" || { echo "Usage: make bump VERSION=X.Y.Z (or bump-patch/bump-minor/bump-major)"; exit 1; } |
| 48 |
@tools/bump-version.sh $(VERSION) |
| 49 |
|
| 50 |
bump-patch: |
| 51 |
@tools/bump-version.sh --patch |
| 52 |
|
| 53 |
bump-minor: |
| 54 |
@tools/bump-version.sh --minor |
| 55 |
|
| 56 |
bump-major: |
| 57 |
@tools/bump-version.sh --major |
| 58 |
|
| 59 |
.PHONY:install |
| 60 |
install: build |
| 61 |
ifeq ($(OS),Msys) |
| 62 |
# Thanks to https://stackoverflow.com/a/46027426/204658 |
| 63 |
$(MAKE) -C build install DESTDIR=/ |
| 64 |
else |
| 65 |
$(MAKE) -C build install |
| 66 |
endif |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
UNAMEOEXISTS=$(shell uname -o &>/dev/null; echo $$?) |
| 74 |
ifeq ($(UNAMEOEXISTS),0) |
| 75 |
OS=$(shell uname -o) |
| 76 |
else |
| 77 |
OS=$(shell uname -s) |
| 78 |
endif |
| 79 |
|
| 80 |
|
| 81 |
ifeq ($(OS),Darwin) |
| 82 |
LDPATH=DYLD_LIBRARY_PATH=$(PWD)/build/src |
| 83 |
PREFIX=lib |
| 84 |
SUFFIX=.dylib |
| 85 |
else ifeq ($(OS),Cygwin) |
| 86 |
LDPATH=PATH=$(PWD)/build/src:"$$PATH" |
| 87 |
PREFIX=cyg |
| 88 |
SUFFIX=.dll |
| 89 |
else ifeq ($(OS),Msys) |
| 90 |
|
| 91 |
|
| 92 |
LDPATH=PATH=$(PWD)/build/src:"$$PATH" |
| 93 |
PREFIX=msys- |
| 94 |
SUFFIX=.dll |
| 95 |
else |
| 96 |
LDPATH=LD_LIBRARY_PATH=$(PWD)/build/src |
| 97 |
PREFIX=lib |
| 98 |
SUFFIX=.so |
| 99 |
endif |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
DIFF_TOOL=../../tools/cgreen_runner_output_diff |
| 111 |
XML_DIFF_TOOL=../../tools/cgreen_xml_output_diff |
| 112 |
DIFF_TOOL_ARGUMENTS = $(1)_tests \ |
| 113 |
../../tests \ |
| 114 |
$(1)_tests.expected |
| 115 |
|
| 116 |
.PHONY: unit |
| 117 |
unit: build-it |
| 118 |
cd build ; \ |
| 119 |
$(LDPATH) tools/cgreen-runner -c `find tests -name $(PREFIX)cgreen_c_tests$(SUFFIX)` ; \ |
| 120 |
r=$$((r + $$?)) ; \ |
| 121 |
$(LDPATH) tools/cgreen-runner -c `find tests -name $(PREFIX)cgreen_cpp_tests$(SUFFIX)` ; \ |
| 122 |
r=$$((r + $$?)) ; \ |
| 123 |
$(LDPATH) tools/cgreen-runner -c `find tools -name $(PREFIX)cgreen_runner_tests$(SUFFIX)` ; \ |
| 124 |
r=$$((r + $$?)) ; \ |
| 125 |
cd tests ; \ |
| 126 |
$(LDPATH) $(XML_DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,xml_output) ; \ |
| 127 |
r=$$((r + $$?)) ; \ |
| 128 |
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,assertion_messages) ; \ |
| 129 |
r=$$((r + $$?)) ; \ |
| 130 |
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,mock_messages) ; \ |
| 131 |
r=$$((r + $$?)) ; \ |
| 132 |
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,constraint_messages) ; \ |
| 133 |
r=$$((r + $$?)) ; \ |
| 134 |
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,custom_constraint_messages) ; \ |
| 135 |
r=$$((r + $$?)) ; \ |
| 136 |
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,ignore_messages) ; \ |
| 137 |
r=$$((r + $$?)) ; \ |
| 138 |
$(LDPATH) CGREEN_PER_TEST_TIMEOUT=1 $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,failure_messages) ; \ |
| 139 |
r=$$((r + $$?)) ; \ |
| 140 |
exit $$r |
| 141 |
|
| 142 |
.PHONY: doc |
| 143 |
doc: build |
| 144 |
cmake -DCGREEN_WITH_HTML_DOCS:bool=TRUE -S . -B build |
| 145 |
cmake --build build |
| 146 |
cmake -DCGREEN_WITH_HTML_DOCS:bool=False -S . -B build |
| 147 |
echo open $(PWD)/build/doc/cgreen-guide-en.html |
| 148 |
|
| 149 |
pdf: build |
| 150 |
cmake -DCGREEN_WITH_PDF_DOCS:bool=TRUE -S . -B build |
| 151 |
cmake --build build |
| 152 |
cmake -DCGREEN_WITH_PDF_DOCS:bool=FALSE -S . -B build |
| 153 |
echo open $(PWD)/build/doc/cgreen-guide-en.pdf |
| 154 |
|
| 155 |
chunked: doc |
| 156 |
asciidoctor-chunker build/doc/cgreen-guide-en.html -o docs |
| 157 |
echo open $(PWD)/docs/index.html |
| 158 |
|
| 159 |
.PHONY:valgrind |
| 160 |
valgrind: build-it |
| 161 |
@echo -n "Running all tests under Valgrind " |
| 162 |
@> valgrind.log |
| 163 |
@for lib in `ls build/tests/$(PREFIX)*_tests$(SUFFIX)` ; \ |
| 164 |
do \ |
| 165 |
echo -n "." ; \ |
| 166 |
LD_LIBRARY_PATH=build/src valgrind --leak-check=full build/tools/cgreen-runner $$lib >> valgrind.log 2>&1 ; \ |
| 167 |
done |
| 168 |
@echo |
| 169 |
grep --with-filename --line-number " lost: " valgrind.log | grep -v " 0 bytes" ; \ |
| 170 |
if [ $$? -eq 1 ] ; then echo "Nothing lost" ; fi |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
build build/Makefile: |
| 176 |
ifeq ($(OS),Darwin) |
| 177 |
|
| 178 |
cmake -S . -B build |
| 179 |
else |
| 180 |
cmake -S . -B build |
| 181 |
endif |
| 182 |
|
| 183 |
.PHONY:build-it |
| 184 |
build-it: build |
| 185 |
$(MAKE) -C build |
| 186 |
|
| 187 |
.SILENT: |