Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (149 loc) · 5.51 KB
/
Copy pathMakefile
File metadata and controls
181 lines (149 loc) · 5.51 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
.PHONY: all build deps cbind clean test \
test_multiformat_exts test_integration test_autotls_docker_integration \
bench_dial bench_kad_find_closest \
bench_dial bench_pubsub_queues \
setup lock gen_multicodec format clean-nim \
lint
NIM_VERSION ?= 2.2.14
NPH_VERSION ?= 0.7.0
NIMC ?= nim
NIMFLAGS ?=
V ?= 0
ifeq ($(V),0)
VERBOSITY_FLAG = --verbosity:0
else
VERBOSITY_FLAG =
endif
# Off by default: mingw gcc ships no ASan runtime.
ASAN ?= 0
ifeq ($(ASAN),1)
ASAN_FLAGS = \
--mm:orc \
-d:useMalloc \
--debugger:native \
--passC:-fno-omit-frame-pointer \
--passC:-fsanitize=address \
--passL:-fsanitize=address
export ASAN_OPTIONS = detect_leaks=0
endif
NIM_FLAGS = \
$(VERBOSITY_FLAG) \
--skipUserCfg \
-f \
$(ASAN_FLAGS) \
$(NIMFLAGS)
RUNNER_FLAGS = --output-level=VERBOSE --console
# Allow: make test [path]
# Captures the optional path argument and synthesises a do-nothing rule for it
# so Make does not complain about a missing target.
ifeq ($(firstword $(MAKECMDGOALS)),test)
_TEST_PATH_ARG := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
ifneq ($(_TEST_PATH_ARG),)
override TEST_PATH := $(_TEST_PATH_ARG)
$(eval $(_TEST_PATH_ARG):;@true)
endif
endif
TEST_PATH ?=
all: setup
nix/libp2p.lock: libp2p.nimble
nimble --lockFile:$@ --requires:"nim == $(NIM_VERSION)" lock
nix/deps.nix: nix/libp2p.lock
./tools/gen-deps.sh nix/libp2p.lock nix/deps.nix
deps: nix/deps.nix
build: deps
nix build
cbind:
$(MAKE) -C cbind
clean:
$(RM) nix/deps.nix nimble.paths tests/nimble.paths
$(MAKE) -C cbind clean
nimble.paths: libp2p.nimble
nimble --noLockfile --requires:"nim == $(NIM_VERSION)" --resolver:minver -l setup -y
tests/nimble.paths: tests/tests.nimble libp2p.nimble
cd tests && nimble --requires:"nim == $(NIM_VERSION)" --resolver:minver -l setup -y
# nim-libplum vendors libplum (PCP / NAT-PMP / UPnP-IGD) as a git submodule and
# compiles its C sources into libp2p via nim's {.compile.} pragmas, so there is
# no separate NAT library to build or link here.
test: nimble.paths tests/nimble.paths
ifeq ($(TEST_PATH),)
$(NIMC) c $(NIM_FLAGS) \
--nimcache:nimcache/test_all \
tests/test_all.nim
./tests/test_all $(RUNNER_FLAGS) --xml:tests/results_test_all.xml
$(MAKE) test_multiformat_exts
else
$(NIMC) c $(NIM_FLAGS) \
--nimcache:nimcache/test_all \
-d:path=$(TEST_PATH) \
tests/test_all.nim
./tests/test_all $(RUNNER_FLAGS) --xml:tests/results_test_all.xml
endif
test_multiformat_exts: nimble.paths tests/nimble.paths
$(NIMC) c $(NIM_FLAGS) \
--nimcache:nimcache/test_all_multiformat \
-d:libp2p_multicodec_exts=../tests/libp2p/multiformat_exts/multicodec_exts.nim \
-d:libp2p_multiaddress_exts=../tests/libp2p/multiformat_exts/multiaddress_exts.nim \
-d:libp2p_multihash_exts=../tests/libp2p/multiformat_exts/multihash_exts.nim \
-d:libp2p_multibase_exts=../tests/libp2p/multiformat_exts/multibase_exts.nim \
-d:libp2p_contentids_exts=../tests/libp2p/multiformat_exts/contentids_exts.nim \
-d:path=multiformat_exts \
tests/test_all.nim
./tests/test_all $(RUNNER_FLAGS) --xml:tests/results_test_all_multiformat.xml
test_integration: nimble.paths tests/nimble.paths
$(NIMC) c $(NIM_FLAGS) \
$(if $(CICOV),--nimcache:nimcache/integration,) \
tests/integration/test_all.nim
./tests/integration/test_all $(RUNNER_FLAGS) --xml:tests/results_integration.xml
BENCH_LOG_LEVEL ?= WARN
QUEUE_BENCH_BYTES ?= 1048576
QUEUE_BENCH_MESSAGES ?= 100000
bench_dial: nimble.paths tests/nimble.paths
mkdir -p $(CURDIR)/build
$(NIMC) c $(NIM_FLAGS) \
--nimcache:nimcache/bench_dial \
-d:chronicles_log_level=$(BENCH_LOG_LEVEL) \
-o:$(CURDIR)/build/bench_dial \
tests/benchmarks/bench_dial.nim
./build/bench_dial
bench_kad_find_closest: nimble.paths tests/nimble.paths
mkdir -p $(CURDIR)/build
$(NIMC) c $(NIM_FLAGS) \
--nimcache:nimcache/bench_kad_find_closest \
-d:chronicles_log_level=$(BENCH_LOG_LEVEL) \
-o:$(CURDIR)/build/bench_kad_find_closest \
tests/benchmarks/bench_kad_find_closest.nim
./build/bench_kad_find_closest
bench_pubsub_queues: nimble.paths tests/nimble.paths
mkdir -p $(CURDIR)/build
$(NIMC) c $(NIM_FLAGS) \
--nimcache:nimcache/bench_pubsub_queues \
-d:release \
-d:chronicles_log_level=$(BENCH_LOG_LEVEL) \
-d:queueBenchBytes=$(QUEUE_BENCH_BYTES) \
-d:queueBenchMessages=$(QUEUE_BENCH_MESSAGES) \
-o:$(CURDIR)/build/bench_pubsub_queues \
tests/benchmarks/bench_pubsub_queues.nim
./build/bench_pubsub_queues
test_autotls_docker_integration:
docker compose -f tests/integration/autotls_docker/docker-compose.yml build test
status=0; docker compose -f tests/integration/autotls_docker/docker-compose.yml run --rm test || status=$$?; \
[ $$status -eq 0 ] || docker compose -f tests/integration/autotls_docker/docker-compose.yml logs; \
docker compose -f tests/integration/autotls_docker/docker-compose.yml down -v; \
exit $$status
setup:
$(MAKE) nimble.paths tests/nimble.paths
lock: nix/libp2p.lock
$(MAKE) -C cbind nimble.lock
gen_multicodec:
nimble gen_multicodec
format:
find . -path '*/nimbledeps' -prune -o -type f \( -name '*.nim' -o -name '*.nimble' \) -print0 | xargs -0 nph
clean-nim:
[ ! -d nimbledeps ] || rm -rf nimbledeps
[ ! -d tests/nimbledeps ] || rm -rf tests/nimbledeps
rm nimble.paths tests/nimble.paths 2>/dev/null || true
lint:
nimble setup --requires:"lint#v1"
{ git diff HEAD --name-only --diff-filter=ACMR -z -- '*.nim'; \
git ls-files --others --exclude-standard -z -- '*.nim'; } | \
sort -zu | xargs -0 -r nim r -d:release linter.nim --semantic