2018-03-28 04:22:52 -07:00
PKG := github.com/lightningnetwork/lnd
2019-01-24 14:51:06 +01:00
MOBILE_PKG := $( PKG) /mobile
2022-02-07 13:58:22 +01:00
TOOLS_DIR := tools
2018-03-28 22:16:18 -07:00
2024-07-08 15:34:47 +02:00
GOCC ?= go
2024-03-06 17:25:58 +02:00
PREFIX ?= /usr/local
2018-06-04 18:35:45 -07:00
BTCD_PKG := github.com/btcsuite/btcd
2022-02-07 13:58:20 +01:00
GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports
2018-03-28 22:16:18 -07:00
GO_BIN := ${ GOPATH } /bin
BTCD_BIN := $( GO_BIN) /btcd
2022-02-07 13:58:22 +01:00
GOIMPORTS_BIN := $( GO_BIN) /gosimports
2023-01-27 15:38:38 -05:00
GOMOBILE_BIN := $( GO_BIN) /gomobile
2018-03-28 22:16:18 -07:00
2019-01-24 14:51:06 +01:00
MOBILE_BUILD_DIR := ${ GOPATH } /src/$( MOBILE_PKG) /build
IOS_BUILD_DIR := $( MOBILE_BUILD_DIR) /ios
2021-10-07 18:48:36 +02:00
IOS_BUILD := $( IOS_BUILD_DIR) /Lndmobile.xcframework
2019-01-24 14:51:06 +01:00
ANDROID_BUILD_DIR := $( MOBILE_BUILD_DIR) /android
ANDROID_BUILD := $( ANDROID_BUILD_DIR) /Lndmobile.aar
2018-03-28 22:16:18 -07:00
2020-12-21 13:03:14 +01:00
COMMIT := $( shell git describe --tags --dirty)
2018-01-29 17:11:03 +01:00
2024-07-30 00:44:47 +01:00
# Determine the minor version of the active Go installation.
2024-07-08 15:34:47 +02:00
ACTIVE_GO_VERSION := $( shell $( GOCC) version | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p' )
2024-07-30 00:44:47 +01:00
ACTIVE_GO_VERSION_MINOR := $( shell echo $( ACTIVE_GO_VERSION) | cut -d. -f2)
2023-10-04 15:41:19 -07:00
2023-11-20 18:19:43 +00:00
# GO_VERSION is the Go version used for the release build, docker files, and
# GitHub Actions. This is the reference version for the project. All other Go
# versions are checked against this version.
2025-10-21 14:14:15 -03:00
GO_VERSION = 1.25.3
2023-11-20 18:19:43 +00:00
2025-02-18 12:33:43 +01:00
GOBUILD := $( GOCC) build -v
GOINSTALL := $( GOCC) install -v
GOTEST := $( GOCC) test
2018-03-28 22:16:18 -07:00
2021-11-29 13:11:04 +01:00
GOFILES_NOVENDOR = $( shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name "*pb.go" -not -name "*pb.gw.go" -not -name "*.pb.json.go" )
2018-03-28 22:16:18 -07:00
2018-08-09 23:17:07 -07:00
RM := rm -f
CP := cp
MAKE := make
2018-10-25 17:10:49 -07:00
XARGS := xargs -L 1
2018-08-09 23:17:07 -07:00
i n c l u d e m a k e / t e s t i n g _ f l a g s . m k
2020-04-21 10:19:58 +02:00
i n c l u d e m a k e / r e l e a s e _ f l a g s . m k
2020-09-23 14:55:08 +02:00
i n c l u d e m a k e / f u z z _ f l a g s . m k
2018-08-09 23:17:07 -07:00
2018-09-26 04:31:40 -07:00
DEV_TAGS := $( if ${ tags } ,$( DEV_TAGS) ${ tags } ,$( DEV_TAGS) )
2020-04-21 10:19:58 +02:00
# We only return the part inside the double quote here to avoid escape issues
# when calling the external release script. The second parameter can be used to
# add additional ldflags if needed (currently only used for the release).
2022-10-01 15:09:34 -07:00
make_ldflags = $( 1) -X $( PKG) /build.Commit= $( COMMIT)
2020-04-09 17:04:55 -07:00
2021-12-18 13:52:47 -08:00
DEV_GCFLAGS := -gcflags "all=-N -l"
2022-10-01 15:09:34 -07:00
DEV_LDFLAGS := -ldflags " $( call make_ldflags) "
2020-04-21 10:19:58 +02:00
# For the release, we want to remove the symbol table and debug information (-s)
# and omit the DWARF symbol table (-w). Also we clear the build ID.
2022-10-01 15:09:34 -07:00
RELEASE_LDFLAGS := $( call make_ldflags, -s -w -buildid= )
2020-04-09 17:04:55 -07:00
2020-03-28 10:39:17 +01:00
# Linting uses a lot of memory, so keep it under control by limiting the number
# of workers if requested.
i f n e q ( $( workers ) , )
LINT_WORKERS = --concurrency= $( workers)
e n d i f
2024-03-06 13:38:51 +01:00
DOCKER_TOOLS = docker run \
--rm \
2024-07-08 15:34:47 +02:00
-v $( shell bash -c " $( GOCC) env GOCACHE || (mkdir -p /tmp/go-cache; echo /tmp/go-cache) " ) :/tmp/build/.cache \
-v $( shell bash -c " $( GOCC) env GOMODCACHE || (mkdir -p /tmp/go-modcache; echo /tmp/go-modcache) " ) :/tmp/build/.modcache \
2024-04-26 13:21:25 +02:00
-v $( shell bash -c "mkdir -p /tmp/go-lint-cache; echo /tmp/go-lint-cache" ) :/root/.cache/golangci-lint \
2024-03-06 13:38:51 +01:00
-v $$ ( pwd ) :/build lnd-tools
2018-03-28 22:16:18 -07:00
GREEN := "\\033[0;32m"
NC := "\\033[0m"
d e f i n e p r i n t
echo $( GREEN) $1 $( NC)
e n d e f
default : scratch
all : scratch check install
# ============
# DEPENDENCIES
# ============
2022-02-07 13:58:22 +01:00
$(BTCD_BIN) :
2018-11-30 15:20:50 -08:00
@$( call print, "Installing btcd." )
2024-07-08 15:34:47 +02:00
cd $( TOOLS_DIR) ; $( GOCC) install -trimpath $( BTCD_PKG)
2018-01-29 17:11:03 +01:00
2022-02-07 13:58:22 +01:00
$(GOIMPORTS_BIN) :
2020-07-15 16:36:59 +02:00
@$( call print, "Installing goimports." )
2024-07-08 15:34:47 +02:00
cd $( TOOLS_DIR) ; $( GOCC) install -trimpath $( GOIMPORTS_PKG)
2020-07-15 16:36:59 +02:00
2018-03-28 22:16:18 -07:00
# ============
# INSTALLATION
# ============
2018-01-29 17:11:03 +01:00
2024-01-22 10:31:48 +02:00
#? build: Build lnd and lncli binaries, place them in project directory
2018-03-28 22:16:18 -07:00
build :
2018-04-29 04:49:14 -07:00
@$( call print, "Building debug lnd and lncli." )
2021-12-18 13:52:47 -08:00
$( GOBUILD) -tags= " $( DEV_TAGS) " -o lnd-debug $( DEV_GCFLAGS) $( DEV_LDFLAGS) $( PKG) /cmd/lnd
$( GOBUILD) -tags= " $( DEV_TAGS) " -o lncli-debug $( DEV_GCFLAGS) $( DEV_LDFLAGS) $( PKG) /cmd/lncli
2018-03-28 04:22:52 -07:00
2024-01-22 10:31:48 +02:00
#? build-itest: Build integration test binaries, place them in itest directory
2018-11-02 09:49:32 +01:00
build-itest :
2020-12-03 11:30:27 +01:00
@$( call print, "Building itest btcd and lnd." )
2022-08-12 15:16:35 +08:00
CGO_ENABLED = 0 $( GOBUILD) -tags= "integration" -o itest/btcd-itest$( EXEC_SUFFIX) $( DEV_LDFLAGS) $( BTCD_PKG)
2023-01-26 11:35:43 +01:00
CGO_ENABLED = 0 $( GOBUILD) -tags= " $( ITEST_TAGS) " $( ITEST_COVERAGE) -o itest/lnd-itest$( EXEC_SUFFIX) $( DEV_LDFLAGS) $( PKG) /cmd/lnd
2020-12-03 11:30:27 +01:00
@$( call print, " Building itest binary for ${ backend } backend. " )
2022-08-12 15:16:35 +08:00
CGO_ENABLED = 0 $( GOTEST) -v ./itest -tags= " $( DEV_TAGS) $( RPC_TAGS) integration $( backend) " -c -o itest/itest.test$( EXEC_SUFFIX)
2020-07-31 10:32:30 +02:00
2024-01-22 10:31:48 +02:00
#? build-itest-race: Build integration test binaries in race detector mode, place them in itest directory
2021-07-19 18:11:21 +02:00
build-itest-race :
@$( call print, "Building itest btcd and lnd with race detector." )
2022-08-12 15:16:35 +08:00
CGO_ENABLED = 0 $( GOBUILD) -tags= "integration" -o itest/btcd-itest$( EXEC_SUFFIX) $( DEV_LDFLAGS) $( BTCD_PKG)
2022-08-11 19:39:40 +08:00
CGO_ENABLED = 1 $( GOBUILD) -race -tags= " $( ITEST_TAGS) " -o itest/lnd-itest$( EXEC_SUFFIX) $( DEV_LDFLAGS) $( PKG) /cmd/lnd
2021-07-19 18:11:21 +02:00
@$( call print, " Building itest binary for ${ backend } backend. " )
2022-08-12 15:16:35 +08:00
CGO_ENABLED = 0 $( GOTEST) -v ./itest -tags= " $( DEV_TAGS) $( RPC_TAGS) integration $( backend) " -c -o itest/itest.test$( EXEC_SUFFIX)
2021-07-19 18:11:21 +02:00
2024-03-06 17:25:58 +02:00
#? install-binaries: Build and install lnd and lncli binaries, place them in $GOPATH/bin
install-binaries :
2018-03-28 22:16:18 -07:00
@$( call print, "Installing lnd and lncli." )
2022-10-17 09:46:09 -07:00
$( GOINSTALL) -tags= " ${ tags } " -ldflags= " $( RELEASE_LDFLAGS) " $( PKG) /cmd/lnd
$( GOINSTALL) -tags= " ${ tags } " -ldflags= " $( RELEASE_LDFLAGS) " $( PKG) /cmd/lncli
2018-03-28 04:22:52 -07:00
2024-03-06 17:25:58 +02:00
#? manpages: generate and install man pages
manpages :
@$( call print, "Generating man pages lncli.1 and lnd.1." )
./scripts/gen_man_pages.sh $( DESTDIR) $( PREFIX)
2024-05-08 09:25:19 +02:00
#? install: Build and install lnd and lncli binaries and place them in $GOPATH/bin.
install : install -binaries
2025-05-26 08:38:15 +02:00
#? install-all: Performs all the same tasks as the install command along with generating and installing the man pages for the lnd and lncli binaries. This command is useful in an environment where a user has root access and so has write access to the man page directory.
2024-05-08 09:25:19 +02:00
install-all : install manpages
2024-03-06 17:25:58 +02:00
2024-01-22 10:31:48 +02:00
#? release-install: Build and install lnd and lncli release binaries, place them in $GOPATH/bin
2021-01-13 14:26:29 +01:00
release-install :
@$( call print, "Installing release lnd and lncli." )
env CGO_ENABLED = 0 $( GOINSTALL) -v -trimpath -ldflags= " $( RELEASE_LDFLAGS) " -tags= " $( RELEASE_TAGS) " $( PKG) /cmd/lnd
env CGO_ENABLED = 0 $( GOINSTALL) -v -trimpath -ldflags= " $( RELEASE_LDFLAGS) " -tags= " $( RELEASE_TAGS) " $( PKG) /cmd/lncli
2025-05-24 14:50:47 +02:00
#? cross-release-install: Build lnd and lncli release binaries for single/all supported platforms to /tmp (useful for checking cross compilation or priming release build cache).
cross-release-install :
@$( call print, "Cross compiling release lnd and lncli." )
for sys in $( BUILD_SYSTEM) ; do \
echo " Building lnd and lncli for $$ sys " ; \
export CGO_ENABLED = 0 GOOS = $$ ( echo $$ sys | cut -d- -f1) GOARCH = $$ ( echo $$ sys | cut -d- -f2) ; \
if [ " $$ GOARCH " = "armv6" ] ; then \
export GOARCH = arm; GOARM = 6; \
elif [ " $$ GOARCH " = "armv7" ] ; then \
export GOARCH = arm; GOARM = 7; \
fi ; \
$( GOBUILD) -trimpath -ldflags= " $( RELEASE_LDFLAGS) " -tags= " $( RELEASE_TAGS) " -o /tmp/lnd-$$ sys $( PKG) /cmd/lnd; \
$( GOBUILD) -trimpath -ldflags= " $( RELEASE_LDFLAGS) " -tags= " $( RELEASE_TAGS) " -o /tmp/lncli-$$ sys $( PKG) /cmd/lncli; \
echo; \
done
2025-05-26 08:38:15 +02:00
#? release: Build the full set of reproducible release binaries for all supported platforms. Make sure the generated mobile RPC stubs don't influence our vendor package by removing them first in the clean-mobile target.
2021-02-05 13:11:35 +01:00
release : clean -mobile
2020-04-21 10:19:58 +02:00
@$( call print, "Releasing lnd and lncli binaries." )
$( VERSION_CHECK)
2024-10-23 12:02:30 +02:00
./scripts/release.sh build-release " $( VERSION_TAG) " " $( BUILD_SYSTEM) " " $( RELEASE_TAGS) " " $( RELEASE_LDFLAGS) " " $( GO_VERSION) "
2020-04-21 10:19:58 +02:00
2024-01-22 10:31:48 +02:00
#? docker-release: Same as release but within a docker container to support reproducible builds on BSD/MacOS platforms
2021-02-17 16:58:29 +01:00
docker-release :
2021-01-08 10:40:17 +01:00
@$( call print, "Building release helper docker image." )
if [ " $( tag) " = "" ] ; then echo "Must specify tag=<commit_or_tag>!" ; exit 1; fi
docker build -t lnd-release-helper -f make/builder.Dockerfile make/
2021-02-17 16:58:29 +01:00
# Run the actual compilation inside the docker image. We pass in all flags
# that we might want to overwrite in manual tests.
2022-10-01 15:09:34 -07:00
$( DOCKER_RELEASE_HELPER) make release tag = " $( tag) " sys = " $( sys) " COMMIT = " $( COMMIT) "
2021-01-08 10:40:17 +01:00
2022-02-10 16:01:59 +01:00
docker-tools :
@$( call print, "Building tools docker image." )
docker build -q -t lnd-tools $( TOOLS_DIR)
2018-11-28 17:17:38 -08:00
scratch : build
2018-03-28 04:22:52 -07:00
2018-03-28 22:16:18 -07:00
# =======
2018-03-28 04:22:52 -07:00
# TESTING
2018-03-28 22:16:18 -07:00
# =======
2018-03-28 04:22:52 -07:00
2024-01-22 10:31:48 +02:00
#? check: Run unit and integration tests
2018-03-28 22:16:18 -07:00
check : unit itest
2018-03-28 04:22:52 -07:00
2021-06-14 16:24:02 +02:00
db-instance :
i f e q ( $( dbbackend ) , p o s t g r e s )
# Remove a previous postgres instance if it exists.
docker rm lnd-postgres --force || echo "Starting new postgres container"
2021-12-27 09:36:51 +01:00
# Start a fresh postgres instance. Allow a maximum of 500 connections so
2024-11-06 10:21:34 -08:00
# that multiple lnd instances with a maximum number of connections of 20
# each can run concurrently. Note that many of the settings here are
# specifically for integration testing and are not fit for running
# production nodes. The increase in max connections ensures that there
# are enough entries allocated for the RWConflictPool to allow multiple
# conflicting transactions to track serialization conflicts. The
# increase in predicate locks and locks per transaction is to allow the
# queries to lock individual rows instead of entire tables, helping
# reduce serialization conflicts. Disabling sequential scan for small
# tables also helps prevent serialization conflicts by ensuring lookups
# lock only relevant rows in the index rather than the entire table.
docker run --name lnd-postgres -e POSTGRES_PASSWORD = postgres -p 6432:5432 -d postgres:13-alpine -N 1500 -c max_pred_locks_per_transaction = 1024 -c max_locks_per_transaction = 128 -c enable_seqscan = off
2024-11-14 21:48:14 -08:00
docker logs -f lnd-postgres >itest/postgres.log 2>& 1 &
2021-06-14 16:24:02 +02:00
# Wait for the instance to be started.
2021-10-01 10:25:51 +02:00
sleep $( POSTGRES_START_DELAY)
2021-06-14 16:24:02 +02:00
e n d i f
2024-11-14 21:48:14 -08:00
clean-itest-logs :
rm -rf itest/*.log itest/.logs-*
2024-01-22 10:31:48 +02:00
#? itest-only: Only run integration tests without re-building binaries
2024-11-14 21:48:14 -08:00
itest-only : clean -itest -logs db -instance
2019-05-24 14:17:48 +02:00
@$( call print, " Running integration tests with ${ backend } backend. " )
2024-11-14 21:48:14 -08:00
date
2024-10-25 03:33:37 +08:00
EXEC_SUFFIX = $( EXEC_SUFFIX) scripts/itest_part.sh 0 1 $( SHUFFLE_SEED) $( TEST_FLAGS) $( ITEST_FLAGS) -test.v
2023-01-26 11:35:43 +01:00
$( COLLECT_ITEST_COVERAGE)
2018-03-28 04:22:52 -07:00
2024-01-22 10:31:48 +02:00
#? itest: Build and run integration tests
2020-12-03 11:30:27 +01:00
itest : build -itest itest -only
2020-11-04 11:03:33 +01:00
2024-01-22 10:31:48 +02:00
#? itest-race: Build and run integration tests in race detector mode
2021-07-19 18:11:21 +02:00
itest-race : build -itest -race itest -only
2024-01-22 10:31:48 +02:00
#? itest-parallel: Build and run integration tests in parallel mode, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
2024-11-14 21:48:14 -08:00
itest-parallel : clean -itest -logs build -itest db -instance
2020-11-04 11:03:33 +01:00
@$( call print, "Running tests" )
2024-11-14 21:48:14 -08:00
date
2024-10-25 03:33:37 +08:00
EXEC_SUFFIX = $( EXEC_SUFFIX) scripts/itest_parallel.sh $( ITEST_PARALLELISM) $( NUM_ITEST_TRANCHES) $( SHUFFLE_SEED) $( TEST_FLAGS) $( ITEST_FLAGS)
2023-01-26 11:35:43 +01:00
$( COLLECT_ITEST_COVERAGE)
2020-07-31 10:32:30 +02:00
2024-01-22 10:31:48 +02:00
#? itest-clean: Kill all running itest processes
2021-11-11 00:47:14 +08:00
itest-clean :
@$( call print, "Cleaning old itest processes" )
killall lnd-itest || echo "no running lnd-itest process found" ;
2024-01-22 10:31:48 +02:00
#? unit: Run unit tests
2022-02-07 13:58:22 +01:00
unit : $( BTCD_BIN )
2018-03-28 22:16:18 -07:00
@$( call print, "Running unit tests." )
$( UNIT)
2018-03-28 04:22:52 -07:00
2024-01-22 10:31:48 +02:00
#? unit-module: Run unit tests of all submodules
2023-09-04 19:17:53 +08:00
unit-module :
@$( call print, "Running submodule unit tests." )
scripts/unit_test_modules.sh
2024-01-22 10:31:48 +02:00
#? unit-debug: Run unit tests with debug log output enabled
2022-02-07 13:58:22 +01:00
unit-debug : $( BTCD_BIN )
2021-02-17 08:47:14 -08:00
@$( call print, "Running debug unit tests." )
$( UNIT_DEBUG)
2024-01-22 10:31:48 +02:00
#? unit-cover: Run unit tests in coverage mode
2025-02-18 19:16:10 +01:00
unit-cover : $( BTCD_BIN )
2018-03-28 22:16:18 -07:00
@$( call print, "Running unit coverage tests." )
2025-02-19 16:40:37 +01:00
$( UNIT_COVER)
2019-05-21 12:33:07 +02:00
2024-01-22 10:31:48 +02:00
#? unit-race: Run unit tests in race detector mode
2025-02-18 19:16:10 +01:00
unit-race : $( BTCD_BIN )
2018-03-28 22:16:18 -07:00
@$( call print, "Running unit race tests." )
2018-12-02 15:24:14 -08:00
env CGO_ENABLED = 1 GORACE = "history_size=7 halt_on_errors=1" $( UNIT_RACE)
2018-03-28 22:16:18 -07:00
2024-01-22 10:31:48 +02:00
#? unit-bench: Run benchmark tests
2023-01-26 20:03:03 +01:00
unit-bench : $( BTCD_BIN )
@$( call print, "Running benchmark tests." )
$( UNIT_BENCH)
2018-03-28 22:16:18 -07:00
# =============
# FLAKE HUNTING
# =============
2025-02-24 18:47:44 +08:00
#? flakehunter-itest: Run the integration tests continuously until one fails
flakehunter-itest : build -itest
2019-05-24 14:17:48 +02:00
@$( call print, " Flake hunting ${ backend } integration tests. " )
2020-12-03 11:30:25 +01:00
while [ $$ ? -eq 0 ] ; do make itest-only icase = '${icase}' backend = '${backend}' ; done
2018-03-28 22:16:18 -07:00
2025-02-24 18:47:44 +08:00
#? flakehunter-unit: Run the unit tests continuously until one fails
flakehunter-unit :
@$( call print, "Flake hunting unit test." )
scripts/unit-test-flake-hunter.sh ${ pkg } ${ case }
2018-03-28 22:16:18 -07:00
2025-07-08 20:30:23 +02:00
#? flakehunter-unit-all: Run all unit tests continuously until one fails
flakehunter-unit-all : $( BTCD_BIN )
@$( call print, "Flake hunting unit tests." )
while [ $$ ? -eq 0 ] ; do make unit; done
#? flakehunter-unit-race: Run all unit tests in race detector mode continuously until one fails
flakehunter-unit-race : $( BTCD_BIN )
@$( call print, "Flake hunting unit tests in race detector mode." )
while [ $$ ? -eq 0 ] ; do make unit-race; done
2025-02-24 18:47:44 +08:00
#? flakehunter-itest-parallel: Run the integration tests continuously until one fails, running up to ITEST_PARALLELISM test tranches in parallel (default 4)
flakehunter-itest-parallel :
2020-11-07 13:23:30 +01:00
@$( call print, " Flake hunting ${ backend } integration tests in parallel. " )
while [ $$ ? -eq 0 ] ; do make itest-parallel tranches = 1 parallel = ${ ITEST_PARALLELISM } icase = '${icase}' backend = '${backend}' ; done
2020-09-23 14:55:08 +02:00
# =============
# FUZZING
# =============
2024-01-22 10:31:48 +02:00
#? fuzz: Run the fuzzing tests
2022-11-11 10:44:37 -06:00
fuzz :
2020-09-23 14:55:08 +02:00
@$( call print, " Fuzzing packages ' $( FUZZPKG) '. " )
2022-11-11 10:44:37 -06:00
scripts/fuzz.sh run " $( FUZZPKG) " " $( FUZZ_TEST_RUN_TIME) " " $( FUZZ_NUM_PROCESSES) "
2020-09-23 14:55:08 +02:00
2018-03-28 22:16:18 -07:00
# =========
# UTILITIES
# =========
2018-03-28 04:22:52 -07:00
2024-01-22 10:31:48 +02:00
#? fmt: Format source code and fix imports
2022-02-07 13:58:22 +01:00
fmt : $( GOIMPORTS_BIN )
2018-11-06 15:18:24 +01:00
@$( call print, "Fixing imports." )
2022-02-07 13:58:20 +01:00
gosimports -w $( GOFILES_NOVENDOR)
2018-03-28 22:16:18 -07:00
@$( call print, "Formatting source." )
2018-10-24 19:06:58 -07:00
gofmt -l -w -s $( GOFILES_NOVENDOR)
2018-03-28 04:22:52 -07:00
2024-01-22 10:31:48 +02:00
#? fmt-check: Make sure source code is formatted and imports are correct
2022-08-23 03:22:51 +08:00
fmt-check : fmt
@$( call print, "Checking fmt results." )
if test -n " $$ (git status --porcelain) " ; then echo "code not formatted correctly, please run `make fmt` again!" ; git status; git diff; exit 1; fi
2023-11-20 18:19:43 +00:00
#? check-go-version-yaml: Verify that the Go version is correct in all YAML files
check-go-version-yaml :
@$( call print, " Checking for target Go version (v $( GO_VERSION) ) in YAML files (*.yaml, *.yml) " )
./scripts/check-go-version-yaml.sh $( GO_VERSION)
#? check-go-version-dockerfile: Verify that the Go version is correct in all Dockerfile files
check-go-version-dockerfile :
@$( call print, " Checking for target Go version (v $( GO_VERSION) ) in Dockerfile files (*Dockerfile) " )
./scripts/check-go-version-dockerfile.sh $( GO_VERSION)
#? check-go-version: Verify that the Go version is correct in all project files
check-go-version : check -go -version -dockerfile check -go -version -yaml
#? lint-source: Run static code analysis
lint-source : docker -tools
2018-03-28 22:16:18 -07:00
@$( call print, "Linting source." )
2024-11-29 11:12:00 +02:00
$( DOCKER_TOOLS) custom-gcl run -v $( LINT_WORKERS)
2018-03-28 04:22:52 -07:00
2023-11-20 18:19:43 +00:00
#? lint: Run static code analysis
lint : check -go -version lint -source
2023-12-25 09:28:40 +02:00
#? protolint: Lint proto files using protolint
protolint :
@$( call print, "Linting proto files." )
docker run --rm --volume " $$ (pwd):/workspace " --workdir /workspace yoheimuta/protolint lint lnrpc/
2024-01-22 10:31:48 +02:00
#? tidy-module: Run `go mod` tidy for all modules
2023-09-06 02:17:00 +08:00
tidy-module :
echo "Running 'go mod tidy' for all modules"
scripts/tidy_modules.sh
2024-01-22 10:31:48 +02:00
#? tidy-module-check: Make sure all modules are up to date
2023-09-06 02:17:00 +08:00
tidy-module-check : tidy -module
if test -n " $$ (git status --porcelain) " ; then echo "modules not updated, please run `make tidy-module` again!" ; git status; exit 1; fi
2024-01-22 10:31:48 +02:00
#? list: List all available make targets
2018-03-28 22:16:18 -07:00
list :
2024-01-22 10:31:48 +02:00
@$( call print, "Listing commands:" )
2018-03-28 22:16:18 -07:00
@$( MAKE) -qp | \
awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | \
grep -v Makefile | \
sort
2018-01-29 17:11:03 +01:00
2024-01-22 10:31:48 +02:00
#? help: List all available make targets with their descriptions
help : Makefile
@$( call print, "Listing commands:" )
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'
2025-02-20 20:40:19 -03:00
#? backwards-compat-test: Run basic backwards compatibility test
backwards-compat-test :
@$( call print, "Running backwards compatability test" )
./scripts/bw-compatibility-test/test.sh
2024-01-22 10:31:48 +02:00
#? sqlc: Generate sql models and queries in Go
2023-05-29 10:20:43 -07:00
sqlc :
@$( call print, "Generating sql models and queries in Go" )
./scripts/gen_sqlc_docker.sh
2024-01-22 10:31:48 +02:00
#? sqlc-check: Make sure sql models and queries are up to date
2023-05-29 10:20:43 -07:00
sqlc-check : sqlc
@$( call print, "Verifying sql code generation." )
if test -n " $$ (git status --porcelain '*.go') " ; then echo "SQL models not properly generated!" ; git status --porcelain '*.go' ; exit 1; fi
2024-01-22 10:31:48 +02:00
#? rpc: Compile protobuf definitions and generate REST proxy stubs
2018-03-28 22:16:18 -07:00
rpc :
@$( call print, "Compiling protos." )
2021-01-15 13:44:50 +01:00
cd ./lnrpc; ./gen_protos_docker.sh
2018-03-28 04:22:52 -07:00
2024-01-22 10:31:48 +02:00
#? rpc-format: Format protobuf definition files
2019-05-22 15:24:40 -07:00
rpc-format :
@$( call print, "Formatting protos." )
cd ./lnrpc; find . -name "*.proto" | xargs clang-format --style= file -i
2024-01-22 10:31:48 +02:00
#? rpc-check: Make sure protobuf definitions are up to date
2020-03-11 10:17:45 +01:00
rpc-check : rpc
2019-05-22 15:24:40 -07:00
@$( call print, "Verifying protos." )
2021-07-27 12:59:54 +02:00
cd ./lnrpc; ../scripts/check-rest-annotations.sh
2022-01-26 22:52:03 -08:00
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
2019-05-22 15:24:40 -07:00
2024-01-22 10:31:48 +02:00
#? rpc-js-compile: Compile protobuf definitions and generate JSON/WASM stubs
2021-08-03 13:37:58 +02:00
rpc-js-compile :
@$( call print, "Compiling JSON/WASM stubs." )
2021-11-15 17:13:38 -08:00
GOOS = js GOARCH = wasm $( GOBUILD) -tags= " $( WASM_RELEASE_TAGS) " $( PKG) /lnrpc/...
2021-08-03 13:37:58 +02:00
2024-01-22 10:31:48 +02:00
#? sample-conf-check: Make sure default values in the sample-lnd.conf file are set correctly
2020-10-08 09:10:59 +02:00
sample-conf-check :
2023-06-22 08:53:14 +02:00
@$( call print, "Checking that default values in the sample-lnd.conf file are set correctly" )
scripts/check-sample-lnd-conf.sh " $( RELEASE_TAGS) "
2020-10-08 09:10:59 +02:00
2024-01-22 10:31:48 +02:00
#? mobile-rpc: Compile mobile RPC stubs from the protobuf definitions
2021-01-15 13:44:54 +01:00
mobile-rpc :
2022-05-11 13:18:17 -04:00
@$( call print, "Creating mobile RPC from protos." )
cd ./lnrpc; COMPILE_MOBILE = 1 SUBSERVER_PREFIX = 1 ./gen_protos_docker.sh
2019-01-24 14:51:05 +01:00
2024-01-22 10:31:48 +02:00
#? vendor: Create a vendor directory with all dependencies
2019-01-24 14:51:06 +01:00
vendor :
@$( call print, "Re-creating vendor directory." )
2024-07-08 15:34:47 +02:00
rm -r vendor/; $( GOCC) mod vendor
2019-01-24 14:51:06 +01:00
2024-01-22 10:31:48 +02:00
#? apple: Build mobile RPC stubs and project template for iOS and macOS
2023-01-27 15:38:38 -05:00
apple : mobile -rpc
2022-03-27 01:20:30 +04:00
@$( call print, " Building iOS and macOS cxframework ( $( IOS_BUILD) ). " )
mkdir -p $( IOS_BUILD_DIR)
2023-01-25 12:23:43 -05:00
$( GOMOBILE_BIN) bind -target= ios,iossimulator,macos -tags= " mobile $( DEV_TAGS) $( RPC_TAGS) " -ldflags " $( RELEASE_LDFLAGS) " -v -o $( IOS_BUILD) $( MOBILE_PKG)
2022-03-27 01:20:30 +04:00
2024-01-22 10:31:48 +02:00
#? ios: Build mobile RPC stubs and project template for iOS
2023-01-27 15:38:38 -05:00
ios : mobile -rpc
2022-03-27 01:15:08 +04:00
@$( call print, " Building iOS cxframework ( $( IOS_BUILD) ). " )
2019-01-24 14:51:06 +01:00
mkdir -p $( IOS_BUILD_DIR)
2023-01-25 12:23:43 -05:00
$( GOMOBILE_BIN) bind -target= ios,iossimulator -tags= " mobile $( DEV_TAGS) $( RPC_TAGS) " -ldflags " $( RELEASE_LDFLAGS) " -v -o $( IOS_BUILD) $( MOBILE_PKG)
2019-01-24 14:51:06 +01:00
2024-01-22 10:31:48 +02:00
#? macos: Build mobile RPC stubs and project template for macOS
2023-01-27 15:38:38 -05:00
macos : mobile -rpc
2022-03-27 01:19:37 +04:00
@$( call print, " Building macOS cxframework ( $( IOS_BUILD) ). " )
mkdir -p $( IOS_BUILD_DIR)
2023-01-25 12:23:43 -05:00
$( GOMOBILE_BIN) bind -target= macos -tags= " mobile $( DEV_TAGS) $( RPC_TAGS) " -ldflags " $( RELEASE_LDFLAGS) " -v -o $( IOS_BUILD) $( MOBILE_PKG)
2022-03-27 01:19:37 +04:00
2024-01-22 10:31:48 +02:00
#? android: Build mobile RPC stubs and project template for Android
2023-01-27 15:38:38 -05:00
android : mobile -rpc
2019-01-24 14:51:06 +01:00
@$( call print, " Building Android library ( $( ANDROID_BUILD) ). " )
mkdir -p $( ANDROID_BUILD_DIR)
2023-01-27 15:38:38 -05:00
$( GOMOBILE_BIN) bind -target= android -androidapi 21 -tags= " mobile $( DEV_TAGS) $( RPC_TAGS) " -ldflags " $( RELEASE_LDFLAGS) " -v -o $( ANDROID_BUILD) $( MOBILE_PKG)
2019-01-24 14:51:06 +01:00
2024-01-22 10:31:48 +02:00
#? mobile: Build mobile RPC stubs and project templates for iOS and Android
2019-01-24 14:51:06 +01:00
mobile : ios android
2024-01-22 10:31:48 +02:00
#? clean: Remove all generated files
2018-03-28 04:22:52 -07:00
clean :
2018-03-28 22:16:18 -07:00
@$( call print, " Cleaning source. $( NC) " )
2018-09-13 14:17:33 -07:00
$( RM) ./lnd-debug ./lncli-debug
2018-11-02 09:49:32 +01:00
$( RM) ./lnd-itest ./lncli-itest
2018-09-13 14:17:33 -07:00
$( RM) -r ./vendor .vendor-new
2018-03-28 22:16:18 -07:00
2024-01-22 10:31:48 +02:00
#? clean-mobile: Remove all generated mobile files
2021-02-05 13:11:35 +01:00
clean-mobile :
@$( call print, "Cleaning autogenerated mobile RPC stubs." )
$( RM) -r mobile/build
$( RM) mobile/*_generated.go
2018-03-28 22:16:18 -07:00
.PHONY : all \
2018-09-09 10:48:37 +02:00
btcd \
2018-03-28 22:16:18 -07:00
default \
build \
install \
scratch \
check \
2024-01-22 10:31:48 +02:00
help \
2018-10-11 10:31:04 +02:00
itest-only \
2018-03-28 22:16:18 -07:00
itest \
unit \
2021-02-17 08:47:14 -08:00
unit-debug \
2018-03-28 22:16:18 -07:00
unit-cover \
unit-race \
flakehunter \
flake-unit \
fmt \
lint \
list \
rpc \
2019-05-22 15:24:40 -07:00
rpc-format \
rpc-check \
2021-08-03 13:37:58 +02:00
rpc-js-compile \
2019-01-24 14:51:05 +01:00
mobile-rpc \
2019-01-24 14:51:06 +01:00
vendor \
ios \
2019-01-24 14:51:06 +01:00
android \
mobile \
2018-03-28 22:16:18 -07:00
clean