-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
255 lines (203 loc) · 6.8 KB
/
Copy pathMakefile
File metadata and controls
255 lines (203 loc) · 6.8 KB
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
SHELL=/bin/bash
CPP_FLAGS=-Wall -Wextra -pedantic -std=c++23
CPP_TEST_LIBS=-lgtest -lgtest_main -lgmock -pthread
MOCK=lib/mockito-core-5.9.0.jar:lib/byte-buddy-1.18.9.jar:lib/objenesis-3.6.jar
OS=$(shell echo `uname`)
ifeq ($(OS),Darwin)
PREFIX=/usr/local/opt/llvm/bin/
endif
runjava: libjava
javac -cp dsa.jar src/java/Main.java
java -cp dsa.jar:src/java Main
# java -cp dsa.jar src/java/Main.java
runcpp:
g++ $(CPP_FLAGS) -O2 -o main src/cpp/main.cpp
./main
runpy:
python3 src/python/main.py
runts:
npm start
rungo:
go build -o main -ldflags="-s -w" ./src/go/dsa-tester
./main
# go run ./src/go/dsa-tester
runrust:
RUSTFLAGS=-Awarnings cargo build -q --release # don't set RUSTFLAGS env var in practice
./target/release/dsa-tester
# cargo run -q
lintjava:
java -jar lib/checkstyle-14.0.0-all.jar -c lib/checks.xml src/java/dsa
lintcpp:
cppcheck --std=c++14 --language=c++ src/cpp src/cpp/dsa/*.h*
flawfinder src/cpp/
# find src/cpp/dsa -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \) | xargs clang-format -i
# clang-tidy src/cpp/main.cpp -checks='*' -header-filter='src/cpp/dsa/*' -- -std=c++23
lintpy:
# Modern Python projects use ruff
autoflake -i --remove-all-unused-imports src/python/main.py
autoflake -i --remove-all-unused-imports src/python/dsa/*.py
autoflake -i --remove-all-unused-imports test/python/dsa/*.py
black src/python/main.py
black src/python/dsa/*.py
black test/python/dsa/*.py
isort src/python/main.py
isort src/python/dsa/*.py
isort test/python/dsa/*.py
pyupgrade src/python/main.py
pyupgrade src/python/dsa/*.py
pyupgrade test/python/dsa/*.py
mypy src/python/dsa/*.py
pycodestyle src/python/dsa/*.py
pydocstyle --convention=google src/python/dsa/*.py
lintts:
npm run lint
lintgo:
gofmt -w src/go/dsa-tester/main.go
gofmt -w src/go/dsa/*.go
go vet src/go/dsa-tester/main.go
go vet src/go/dsa/*.go
lintrust:
cargo fmt
cargo clippy -- -D clippy::all -D clippy::pedantic
coveragejava: testjava
rm bin/dsa/*Test.class # excluding tests from code coverage report
java -jar lib/org.jacoco.cli-0.8.15-nodeps.jar report jacoco.exec \
--classfiles bin --sourcefiles src/java --html java-coverage-report
open java-coverage-report/index.html
coveragecpp:
g++ $(CPP_FLAGS) --coverage -O0 -ggdb -g3 -Isrc/cpp/dsa -o main test/cpp/dsa/*.cpp $(CPP_TEST_LIBS)
./main
mv main-* test/cpp/dsa
@for f in test/cpp/dsa/main-*; do \
mv "$$f" "test/cpp/dsa/$${f##*/main-}"; \
done
gcov test/cpp/dsa/*.cpp
mv my*.gcov test/cpp/dsa
rm *.gcov
# Let's happily ignore all of these errors
lcov --ignore-errors format,format,unsupported,inconsistent,inconsistent --capture --directory test/cpp/dsa --output-file coverage.info
lcov --ignore-errors format --remove coverage.info "test/*" --output-file coverage.filtered.info
genhtml --ignore-errors unsupported,unsupported,inconsistent,inconsistent,corrupt,category,category coverage.filtered.info --output-directory cpp-coverage-report
open cpp-coverage-report/index.html
coveragepy:
coverage run -a -m unittest discover -v -s test/python/dsa -p "*test.py"
coverage html --omit=*test*,*__init__*,*typing_extensions*
mv htmlcov python-coverage-report
open python-coverage-report/index.html
coveragets:
npm run coverage
mv coverage typescript-coverage-report
open typescript-coverage-report/lcov-report/index.html
coveragego:
go generate src/go/dsa/mylist.go
go test -v -coverprofile=coverage.out ./src/go/dsa
grep -v -e "test_helpers" -e "mock_*" coverage.out > coverage.out.bak
rm coverage.out
mv coverage.out.bak coverage.out
go tool cover -html=coverage.out
coveragerust:
RUSTFLAGS="-C instrument-coverage" cargo test -q
$(PREFIX)llvm-profdata merge --sparse -o default.profdata src/rust/dsa/default*.profraw
rm -f target/debug/deps/dsa-*.o target/debug/deps/dsa-*.d
$(PREFIX)llvm-cov show -format=html -output-dir=rust-coverage-report \
-instr-profile=default.profdata ./target/debug/deps/dsa-* \
-ignore-filename-regex="/.cargo/|/.rustup/"
open rust-coverage-report/index.html
testjava:
javac -d bin src/java/dsa/*.java
javac -d bin -cp bin:lib/junit-platform-console-standalone-1.14.4.jar:$(MOCK) \
test/java/dsa/*.java
java -javaagent:lib/org.jacoco.agent-0.8.15-runtime.jar \
-javaagent:lib/byte-buddy-agent-1.18.9.jar \
-Xshare:off \
-jar lib/junit-platform-console-standalone-1.14.4.jar \
-cp bin:$(MOCK) --scan-classpath --fail-if-no-tests
testcpp:
g++ $(CPP_FLAGS) -fsanitize=address -fno-omit-frame-pointer -O1 -g -Isrc/cpp/dsa -o main test/cpp/dsa/*.cpp $(CPP_TEST_LIBS)
./main
testpy:
python3 -m unittest discover -v -s test/python/dsa -p "*test.py"
testts:
npm test
testgo:
go generate src/go/dsa/mylist.go
go test -v ./src/go/dsa
testrust:
cargo test -q --release
debugjava:
javac -g -d out -cp src/java/dsa/*.java src/java/Main.java
# cd out; jdb Main
debugcpp:
g++ $(CPP_FLAGS) -Og -ggdb -g3 -o main src/cpp/dsa/*.cpp src/cpp/main.cpp
# gdb main
debugpy:
# python3 -m pdb src/python/main.py
debugts:
# Doesn't work
# npm run debug
debuggo:
go build ./src/go/dsa-tester
# dlv debug ./src/go/dsa-tester
debugrust:
cargo build -q
# rust-lldb ./target/debug/dsa-tester
docsjava:
javadoc -d public/java src/java/dsa/*.java
open public/java/index.html
docscpp:
mkdir -p public/cpp
doxygen Doxyfile
open public/cpp/annotated.html
docspy:
sphinx-apidoc -f -o sphinx src/python/dsa
cd sphinx; make html
open public/python/html/modules.html
docsts:
mkdir -p public
npm run docs
mv docs public/typescript
open public/typescript/index.html
docsgo:
# pkgsite starts a local web server
# The documentation is located at http://127.0.0.1:8080/example.com/dsa
pkgsite
docsrust:
cargo doc
open target/doc/dsa/index.html
libjava:
javac src/java/dsa/*.java
cd src/java; jar -cf dsa.jar dsa/*.class; mv dsa.jar ../..
libcpp:
@echo "Can't produce C++ library due to presence of generics."
libpy:
python3 -m build
libts:
npm pack
updatejava:
@echo "Must update dependencies manually in installj.sh"
updatecpp:
@echo "Update C++ dependencies with your package manager."
updatepy:
pip-compile --extra=dev --generate-hashes --allow-unsafe pyproject.toml --upgrade
pip3 install -r requirements.txt
updatets:
npm update
npm install
updatego:
cd src/go/dsa; go get -u; go mod tidy
cd src/go/dsa-tester; go get -u; go mod tidy
updaterust:
cargo update
deptreets:
npm ls --omit=dev
deptreego:
go list -deps -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ./src/go/dsa/...
deptreerust:
cargo tree --edges normal
clean:
rm -rf *.jar main main* src/java/Main.class src/java/dsa/*.class out public \
src/python/dsa/__pycache__ test/python/dsa/__pycache__ \
.mypy_cache bin jacoco.exec *-coverage-report .coverage coverage.out \
dist target *.profdata *.profraw src/rust/dsa/*.profraw \
src/rust/dsa-tester/*.profraw test/cpp/dsa/*.gc* *.info \
src/typescript/*.js* src/typescript/dsa/*.js* test/typescript/dsa/*.js*