Skip to content

Commit e1259cd

Browse files
authored
Merge pull request #8411 from guggero/make-help
Makefile: add `make help` command that describes goals
2 parents 35fa053 + f35a371 commit e1259cd

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

Makefile

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ $(GOIMPORTS_BIN):
9494
# INSTALLATION
9595
# ============
9696

97+
#? build: Build lnd and lncli binaries, place them in project directory
9798
build:
9899
@$(call print, "Building debug lnd and lncli.")
99100
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(DEV_GCFLAGS) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
100101
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(DEV_GCFLAGS) $(DEV_LDFLAGS) $(PKG)/cmd/lncli
101102

103+
#? build-itest: Build integration test binaries, place them in itest directory
102104
build-itest:
103105
@$(call print, "Building itest btcd and lnd.")
104106
CGO_ENABLED=0 $(GOBUILD) -tags="integration" -o itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG)
@@ -107,6 +109,7 @@ build-itest:
107109
@$(call print, "Building itest binary for ${backend} backend.")
108110
CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) integration $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)
109111

112+
#? build-itest-race: Build integration test binaries in race detector mode, place them in itest directory
110113
build-itest-race:
111114
@$(call print, "Building itest btcd and lnd with race detector.")
112115
CGO_ENABLED=0 $(GOBUILD) -tags="integration" -o itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG)
@@ -115,23 +118,27 @@ build-itest-race:
115118
@$(call print, "Building itest binary for ${backend} backend.")
116119
CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) integration $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)
117120

121+
#? install: Build and install lnd and lncli binaries, place them in $GOPATH/bin
118122
install:
119123
@$(call print, "Installing lnd and lncli.")
120124
$(GOINSTALL) -tags="${tags}" -ldflags="$(RELEASE_LDFLAGS)" $(PKG)/cmd/lnd
121125
$(GOINSTALL) -tags="${tags}" -ldflags="$(RELEASE_LDFLAGS)" $(PKG)/cmd/lncli
122126

127+
#? release-install: Build and install lnd and lncli release binaries, place them in $GOPATH/bin
123128
release-install:
124129
@$(call print, "Installing release lnd and lncli.")
125130
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lnd
126131
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lncli
127132

133+
#? release: Build the full set of reproducible release binaries for all supported platforms
128134
# Make sure the generated mobile RPC stubs don't influence our vendor package
129135
# by removing them first in the clean-mobile target.
130136
release: clean-mobile
131137
@$(call print, "Releasing lnd and lncli binaries.")
132138
$(VERSION_CHECK)
133139
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)"
134140

141+
#? docker-release: Same as release but within a docker container to support reproducible builds on BSD/MacOS platforms
135142
docker-release:
136143
@$(call print, "Building release helper docker image.")
137144
if [ "$(tag)" = "" ]; then echo "Must specify tag=<commit_or_tag>!"; exit 1; fi
@@ -153,6 +160,7 @@ scratch: build
153160
# TESTING
154161
# =======
155162

163+
#? check: Run unit and integration tests
156164
check: unit itest
157165

158166
db-instance:
@@ -170,44 +178,55 @@ ifeq ($(dbbackend),postgres)
170178
sleep $(POSTGRES_START_DELAY)
171179
endif
172180

181+
#? itest-only: Only run integration tests without re-building binaries
173182
itest-only: db-instance
174183
@$(call print, "Running integration tests with ${backend} backend.")
175184
rm -rf itest/*.log itest/.logs-*; date
176185
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS)
177186

187+
#? itest: Build and run integration tests
178188
itest: build-itest itest-only
179189

190+
#? itest-race: Build and run integration tests in race detector mode
180191
itest-race: build-itest-race itest-only
181192

193+
#? itest-parallel: Build and run integration tests in parallel mode, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
182194
itest-parallel: build-itest db-instance
183195
@$(call print, "Running tests")
184196
rm -rf itest/*.log itest/.logs-*; date
185197
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_parallel.sh $(ITEST_PARALLELISM) $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
186198

199+
#? itest-clean: Kill all running itest processes
187200
itest-clean:
188201
@$(call print, "Cleaning old itest processes")
189202
killall lnd-itest || echo "no running lnd-itest process found";
190203

204+
#? unit: Run unit tests
191205
unit: $(BTCD_BIN)
192206
@$(call print, "Running unit tests.")
193207
$(UNIT)
194208

209+
#? unit-module: Run unit tests of all submodules
195210
unit-module:
196211
@$(call print, "Running submodule unit tests.")
197212
scripts/unit_test_modules.sh
198213

214+
#? unit-debug: Run unit tests with debug log output enabled
199215
unit-debug: $(BTCD_BIN)
200216
@$(call print, "Running debug unit tests.")
201217
$(UNIT_DEBUG)
202218

219+
#? unit-cover: Run unit tests in coverage mode
203220
unit-cover: $(GOACC_BIN)
204221
@$(call print, "Running unit coverage tests.")
205222
$(GOACC)
206223

224+
#? unit-race: Run unit tests in race detector mode
207225
unit-race:
208226
@$(call print, "Running unit race tests.")
209227
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
210228

229+
#? unit-bench: Run benchmark tests
211230
unit-bench: $(BTCD_BIN)
212231
@$(call print, "Running benchmark tests.")
213232
$(UNIT_BENCH)
@@ -216,14 +235,17 @@ unit-bench: $(BTCD_BIN)
216235
# FLAKE HUNTING
217236
# =============
218237

238+
#? flakehunter: Run the integration tests continuously until one fails
219239
flakehunter: build-itest
220240
@$(call print, "Flake hunting ${backend} integration tests.")
221241
while [ $$? -eq 0 ]; do make itest-only icase='${icase}' backend='${backend}'; done
222242

243+
#? flake-unit: Run the unit tests continuously until one fails
223244
flake-unit:
224245
@$(call print, "Flake hunting unit tests.")
225246
while [ $$? -eq 0 ]; do GOTRACEBACK=all $(UNIT) -count=1; done
226247

248+
#? flakehunter-parallel: Run the integration tests continuously until one fails, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
227249
flakehunter-parallel:
228250
@$(call print, "Flake hunting ${backend} integration tests in parallel.")
229251
while [ $$? -eq 0 ]; do make itest-parallel tranches=1 parallel=${ITEST_PARALLELISM} icase='${icase}' backend='${backend}'; done
@@ -232,6 +254,7 @@ flakehunter-parallel:
232254
# FUZZING
233255
# =============
234256

257+
#? fuzz: Run the fuzzing tests
235258
fuzz:
236259
@$(call print, "Fuzzing packages '$(FUZZPKG)'.")
237260
scripts/fuzz.sh run "$(FUZZPKG)" "$(FUZZ_TEST_RUN_TIME)" "$(FUZZ_NUM_PROCESSES)"
@@ -240,99 +263,126 @@ fuzz:
240263
# UTILITIES
241264
# =========
242265

266+
#? fmt: Format source code and fix imports
243267
fmt: $(GOIMPORTS_BIN)
244268
@$(call print, "Fixing imports.")
245269
gosimports -w $(GOFILES_NOVENDOR)
246270
@$(call print, "Formatting source.")
247271
gofmt -l -w -s $(GOFILES_NOVENDOR)
248272

273+
#? fmt-check: Make sure source code is formatted and imports are correct
249274
fmt-check: fmt
250275
@$(call print, "Checking fmt results.")
251276
if test -n "$$(git status --porcelain)"; then echo "code not formatted correctly, please run `make fmt` again!"; git status; git diff; exit 1; fi
252277

278+
#? lint: Run static code analysis
253279
lint: docker-tools
254280
@$(call print, "Linting source.")
255281
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
256282

283+
#? tidy-module: Run `go mod` tidy for all modules
257284
tidy-module:
258285
echo "Running 'go mod tidy' for all modules"
259286
scripts/tidy_modules.sh
260287

288+
#? tidy-module-check: Make sure all modules are up to date
261289
tidy-module-check: tidy-module
262290
if test -n "$$(git status --porcelain)"; then echo "modules not updated, please run `make tidy-module` again!"; git status; exit 1; fi
263291

292+
#? list: List all available make targets
264293
list:
265-
@$(call print, "Listing commands.")
294+
@$(call print, "Listing commands:")
266295
@$(MAKE) -qp | \
267296
awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | \
268297
grep -v Makefile | \
269298
sort
270299

300+
#? help: List all available make targets with their descriptions
301+
help: Makefile
302+
@$(call print, "Listing commands:")
303+
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'
304+
305+
#? sqlc: Generate sql models and queries in Go
271306
sqlc:
272307
@$(call print, "Generating sql models and queries in Go")
273308
./scripts/gen_sqlc_docker.sh
274309

310+
#? sqlc-check: Make sure sql models and queries are up to date
275311
sqlc-check: sqlc
276312
@$(call print, "Verifying sql code generation.")
277313
if test -n "$$(git status --porcelain '*.go')"; then echo "SQL models not properly generated!"; git status --porcelain '*.go'; exit 1; fi
278314

315+
#? rpc: Compile protobuf definitions and generate REST proxy stubs
279316
rpc:
280317
@$(call print, "Compiling protos.")
281318
cd ./lnrpc; ./gen_protos_docker.sh
282319

320+
#? rpc-format: Format protobuf definition files
283321
rpc-format:
284322
@$(call print, "Formatting protos.")
285323
cd ./lnrpc; find . -name "*.proto" | xargs clang-format --style=file -i
286324

325+
#? rpc-check: Make sure protobuf definitions are up to date
287326
rpc-check: rpc
288327
@$(call print, "Verifying protos.")
289328
cd ./lnrpc; ../scripts/check-rest-annotations.sh
290329
if test -n "$$(git status --porcelain)"; then echo "Protos not properly formatted or not compiled with v3.4.0"; git status; git diff; exit 1; fi
291330

331+
#? rpc-js-compile: Compile protobuf definitions and generate JSON/WASM stubs
292332
rpc-js-compile:
293333
@$(call print, "Compiling JSON/WASM stubs.")
294334
GOOS=js GOARCH=wasm $(GOBUILD) -tags="$(WASM_RELEASE_TAGS)" $(PKG)/lnrpc/...
295335

336+
#? sample-conf-check: Make sure default values in the sample-lnd.conf file are set correctly
296337
sample-conf-check:
297338
@$(call print, "Checking that default values in the sample-lnd.conf file are set correctly")
298339
scripts/check-sample-lnd-conf.sh "$(RELEASE_TAGS)"
299340

341+
#? mobile-rpc: Compile mobile RPC stubs from the protobuf definitions
300342
mobile-rpc:
301343
@$(call print, "Creating mobile RPC from protos.")
302344
cd ./lnrpc; COMPILE_MOBILE=1 SUBSERVER_PREFIX=1 ./gen_protos_docker.sh
303345

346+
#? vendor: Create a vendor directory with all dependencies
304347
vendor:
305348
@$(call print, "Re-creating vendor directory.")
306349
rm -r vendor/; go mod vendor
307350

351+
#? apple: Build mobile RPC stubs and project template for iOS and macOS
308352
apple: mobile-rpc
309353
@$(call print, "Building iOS and macOS cxframework ($(IOS_BUILD)).")
310354
mkdir -p $(IOS_BUILD_DIR)
311355
$(GOMOBILE_BIN) bind -target=ios,iossimulator,macos -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(IOS_BUILD) $(MOBILE_PKG)
312356

357+
#? ios: Build mobile RPC stubs and project template for iOS
313358
ios: mobile-rpc
314359
@$(call print, "Building iOS cxframework ($(IOS_BUILD)).")
315360
mkdir -p $(IOS_BUILD_DIR)
316361
$(GOMOBILE_BIN) bind -target=ios,iossimulator -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(IOS_BUILD) $(MOBILE_PKG)
317362

363+
#? macos: Build mobile RPC stubs and project template for macOS
318364
macos: mobile-rpc
319365
@$(call print, "Building macOS cxframework ($(IOS_BUILD)).")
320366
mkdir -p $(IOS_BUILD_DIR)
321367
$(GOMOBILE_BIN) bind -target=macos -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(IOS_BUILD) $(MOBILE_PKG)
322368

369+
#? android: Build mobile RPC stubs and project template for Android
323370
android: mobile-rpc
324371
@$(call print, "Building Android library ($(ANDROID_BUILD)).")
325372
mkdir -p $(ANDROID_BUILD_DIR)
326373
$(GOMOBILE_BIN) bind -target=android -androidapi 21 -tags="mobile $(DEV_TAGS) $(RPC_TAGS)" -ldflags "$(RELEASE_LDFLAGS)" -v -o $(ANDROID_BUILD) $(MOBILE_PKG)
327374

375+
#? mobile: Build mobile RPC stubs and project templates for iOS and Android
328376
mobile: ios android
329377

378+
#? clean: Remove all generated files
330379
clean:
331380
@$(call print, "Cleaning source.$(NC)")
332381
$(RM) ./lnd-debug ./lncli-debug
333382
$(RM) ./lnd-itest ./lncli-itest
334383
$(RM) -r ./vendor .vendor-new
335384

385+
#? clean-mobile: Remove all generated mobile files
336386
clean-mobile:
337387
@$(call print, "Cleaning autogenerated mobile RPC stubs.")
338388
$(RM) -r mobile/build
@@ -345,6 +395,7 @@ clean-mobile:
345395
install \
346396
scratch \
347397
check \
398+
help \
348399
itest-only \
349400
itest \
350401
unit \

0 commit comments

Comments
 (0)