-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
238 lines (197 loc) · 7.82 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
CURRENT_DIR:=$(PWD)
SOURCE_DIR:=$(CURRENT_DIR)
SOURCE_EXAMPLES_DIR:=$(SOURCE_DIR)/examples
THIRDPARTY_DIR:=$(SOURCE_DIR)/3rdparty
WORK_DIR:=$(CURRENT_DIR)/_work
BUILD_DIR:=$(WORK_DIR)/_build
INSTALL_DIR:=$(WORK_DIR)/_install
PACKAGE_DIR:=$(WORK_DIR)/_package
VERIFY_DIR=$(WORK_DIR)/_verify
BUILD_CPPCHECK_DIR:=$(BUILD_DIR)/cppcheck
CPUCOUNT=$(shell nproc)
CMAKE_OPTS=\
-DCMAKE_BUILD_TYPE=Debug \
-DRELEASE_VERSION=${RELEASE_VERSION} \
-DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \
-DCPACK_PACKAGE_DIRECTORY=$(PACKAGE_DIR) \
-DBUILD_TESTS=True \
-DBUILD_EXAMPLES=True \
-DENABLE_COVERAGE=True \
-DCMAKE_EXPORT_COMPILE_COMMANDS=True
VERIFY_CMAKE_OPTS=\
-DCMAKE_BUILD_TYPE=Release \
-DOCTARGS_ROOT_DIR=$(INSTALL_DIR)
CPPCHECK_OPTS=\
-i $(THIRDPARTY_DIR) \
--library=googletest \
--verbose \
--enable=all \
--std=c++11 \
--inconclusive \
--force \
--inline-suppr
CMAKE_BUILD=cmake --build . -j $(CPUCOUNT)
all: install_verify test
$(BUILD_DIR) $(INSTALL_DIR) $(PACKAGE_DIR):
mkdir -p $@
prepare: $(BUILD_DIR) $(PACKAGE_DIR) $(INSTALL_DIR)
(cd $(BUILD_DIR) && cmake $(CMAKE_OPTS) $(SOURCE_DIR) )
build: prepare
(cd $(BUILD_DIR) && $(CMAKE_BUILD) -- all)
install: build
(cd $(BUILD_DIR) && $(CMAKE_BUILD) -- install)
install_verify: install
rm -rf $(VERIFY_DIR)
mkdir -p $(VERIFY_DIR)
(cd $(VERIFY_DIR) && cmake $(VERIFY_CMAKE_OPTS) $(SOURCE_EXAMPLES_DIR) )
(cd $(VERIFY_DIR) && $(CMAKE_BUILD))
doxygen: prepare
(cd $(BUILD_DIR) && $(CMAKE_BUILD) -- doxygen)
doxygen_open: doxygen
(cd $(BUILD_DIR) && pdetach xdg-open ./doxygen/html/index.html)
doxygen_deploy: doxygen
rm -rf docs/html
mkdir -p docs
cp -r $(BUILD_DIR)/doxygen/html docs/
test: build
(cd $(BUILD_DIR) && $(CMAKE_BUILD) -- test ARGS=--output-on-failure)
package: install
(cd $(BUILD_DIR) && $(CMAKE_BUILD) -- package)
cppcheck: test
mkdir -p $(BUILD_CPPCHECK_DIR)
(cd $(BUILD_DIR) && cppcheck --project=compile_commands.json $(CPPCHECK_OPTS) --xml 2> cppcheck-report.xml)
(cd $(BUILD_DIR) && cppcheck-htmlreport --file=cppcheck-report.xml --report-dir=$(BUILD_CPPCHECK_DIR) --source-dir=$(SOURCE_DIR))
(cd $(BUILD_DIR) && pdetach xdg-open $(BUILD_CPPCHECK_DIR)/index.html)
run_examples_cat:
@echo "----------------------------"
@echo "CAT TEST 1"
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) $(SOURCE_DIR)/LICENSE)
@echo "----------------------------"
@echo "----------------------------"
@echo "CAT TEST 2"
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) < $(SOURCE_DIR)/LICENSE)
@echo "----------------------------"
@echo "----------------------------"
@echo "CAT TEST 3"
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) - < $(SOURCE_DIR)/LICENSE)
@echo "----------------------------"
@echo "----------------------------"
@echo "CAT TEST 4"
@echo "----------------------------"
@cat -n -E $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) -n --show-ends $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md)
@echo "----------------------------"
@echo "----------------------------"
@echo "CAT HELP"
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) --help)
@echo "----------------------------"
examples_cat: install
$(MAKE) run_examples_cat EXEDIR=$(INSTALL_DIR)/bin EXENAME=octargs_cat
run_examples_head:
@echo "----------------------------"
@echo "HEAD TEST 1"
@echo "----------------------------"
@head -n 5 -v $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md - - < $(SOURCE_DIR)/LICENSE
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) -n 5 -h $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md - - < $(SOURCE_DIR)/LICENSE)
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) -n=5 -h $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md - - < $(SOURCE_DIR)/LICENSE)
@echo "----------------------------"
@echo "----------------------------"
@echo "HEAD HELP"
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) --help)
@echo "----------------------------"
examples_head: install
$(MAKE) run_examples_head EXEDIR=$(INSTALL_DIR)/bin EXENAME=octargs_head
run_examples_win_head:
@echo "----------------------------"
@echo "WIN HEAD TEST 1"
@echo "----------------------------"
head -n 5 -v $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md - - < $(SOURCE_DIR)/LICENSE
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) /N:5 /H $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md - - < $(SOURCE_DIR)/LICENSE)
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) /N:5 /H $(SOURCE_DIR)/LICENSE $(SOURCE_DIR)/README.md - - < $(SOURCE_DIR)/LICENSE)
@echo "----------------------------"
@echo "----------------------------"
@echo "WIN HEAD HELP"
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) /?)
@echo "----------------------------"
examples_win_head: install
$(MAKE) run_examples_win_head EXEDIR=$(INSTALL_DIR)/bin EXENAME=octargs_win_head
run_examples_calc:
@echo "----------------------------"
@echo "CALC TEST 1"
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) 1 2 3 4 5 )
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) 5 -5 5 -5 5 )
@echo "----------------------------"
@echo "CALC TEST 2"
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) -o mul -t double 1.2 1.2 )
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) --operation max -t float 1.1 1.3 1.0 0.7 1.25 )
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) --operation min -t float 1.1 1.3 1.0 0.7 1.25 )
@echo "----------------------------"
@echo "CALC STEPS"
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) -s -o sum 1 2 3 4 5 -3 )
(cd $(EXEDIR) && ./$(EXENAME) -s -o mul 1 2 3 4 5 -3 )
(cd $(EXEDIR) && ./$(EXENAME) -s -o min 1 2 3 4 5 -3 )
(cd $(EXEDIR) && ./$(EXENAME) -s -o max 1 2 3 4 5 -3 )
@echo "----------------------------"
@echo "CALC HELP"
@echo "----------------------------"
@(cd $(EXEDIR) && ./$(EXENAME) --help)
@echo "----------------------------"
examples_sum: install
$(MAKE) run_examples_sum EXEDIR=$(INSTALL_DIR)/bin EXENAME=octargs_sum
run_examples_sum:
@echo "----------------------------"
@echo "SUM TEST 1"
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) 1 2 3 4 5 )
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) 5 -5 5 -5 5 )
@echo "----------------------------"
@echo "SUM STEPS"
@echo "----------------------------"
(cd $(EXEDIR) && ./$(EXENAME) 1 2 3 4 5 -3 )
@echo "----------------------------"
(cd $(EXEDIR) && LC_ALL=en_US.UTF-8 ./$(EXENAME) -s=tak 1 2 3 4 5 -3 || true)
@echo "----------------------------"
(cd $(EXEDIR) && LC_ALL=pl_PL.UTF-8 ./$(EXENAME) -s=tak 1 2 3 4 5 -3)
@echo "----------------------------"
@echo "SUM HELP"
@echo "----------------------------"
@(cd $(EXEDIR) && LC_ALL=en_US.UTF-8 ./$(EXENAME) --help)
@echo "----------------------------"
@(cd $(EXEDIR) && LC_ALL=pl_PL.UTF-8 ./$(EXENAME) --help)
@echo "----------------------------"
examples_calc: install
$(MAKE) run_examples_calc EXEDIR=$(INSTALL_DIR)/bin EXENAME=octargs_calc
coverage_prepare: build
(cd $(BUILD_DIR) && find . -name "*.gcda" -exec rm -f {} \; )
ctest_coverage: coverage_prepare
(cd $(BUILD_DIR) && cmake --build . -- ctest_coverage)
ctest_coverage_open: ctest_coverage
(cd $(BUILD_DIR) && pdetach xdg-open ./ctest_coverage/index.html)
total_coverage: coverage_prepare
$(MAKE) run_examples_cat EXEDIR=$(BUILD_DIR)/examples/cat EXENAME=octargs_cat
$(MAKE) run_examples_head EXEDIR=$(BUILD_DIR)/examples/head EXENAME=octargs_head
$(MAKE) run_examples_calc EXEDIR=$(BUILD_DIR)/examples/calc EXENAME=octargs_calc
(cd $(BUILD_DIR) && cmake --build . -- ctest_coverage)
total_coverage_open: total_coverage
(cd $(BUILD_DIR) && pdetach xdg-open ./ctest_coverage/index.html)
clean:
rm -rf $(WORK_DIR)
.PHONY: doxygen