2020-07-21 22:06:15 +02:00
|
|
|
PKG := github.com/lightninglabs/lightning-terminal
|
|
|
|
|
ESCPKG := github.com\/lightninglabs\/lightning-terminal
|
2020-05-26 16:31:21 +02:00
|
|
|
LND_PKG := github.com/lightningnetwork/lnd
|
2020-11-12 20:57:23 +01:00
|
|
|
LOOP_PKG := github.com/lightninglabs/loop
|
2020-05-26 16:31:21 +02:00
|
|
|
|
|
|
|
|
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
|
|
|
GOVERALLS_PKG := github.com/mattn/goveralls
|
|
|
|
|
GOACC_PKG := github.com/ory/go-acc
|
|
|
|
|
STATIK_PKG := github.com/rakyll/statik
|
|
|
|
|
|
|
|
|
|
GO_BIN := ${GOPATH}/bin
|
|
|
|
|
GOVERALLS_BIN := $(GO_BIN)/goveralls
|
|
|
|
|
LINT_BIN := $(GO_BIN)/golangci-lint
|
|
|
|
|
GOACC_BIN := $(GO_BIN)/go-acc
|
|
|
|
|
STATIK_BIN := $(GO_BIN)/statik
|
|
|
|
|
|
|
|
|
|
COMMIT := $(shell git describe --abbrev=40 --dirty --tags)
|
2020-06-18 09:57:29 +02:00
|
|
|
COMMIT_HASH := $(shell git rev-parse HEAD)
|
2020-05-26 16:31:21 +02:00
|
|
|
|
2020-11-12 20:57:23 +01:00
|
|
|
LOOP_COMMIT := $(shell cat go.mod | \
|
|
|
|
|
grep $(LOOP_PKG) | \
|
|
|
|
|
head -n1 | \
|
|
|
|
|
awk -F " " '{ print $$2 }' | \
|
|
|
|
|
awk -F "/" '{ print $$1 }')
|
|
|
|
|
|
2020-05-26 16:31:21 +02:00
|
|
|
LINT_COMMIT := v1.18.0
|
|
|
|
|
GOACC_COMMIT := ddc355013f90fea78d83d3a6c71f1d37ac07ecd5
|
|
|
|
|
|
|
|
|
|
DEPGET := cd /tmp && GO111MODULE=on go get -v
|
|
|
|
|
GOBUILD := GO111MODULE=on go build -v
|
|
|
|
|
GOINSTALL := GO111MODULE=on go install -v
|
|
|
|
|
GOTEST := GO111MODULE=on go test -v
|
|
|
|
|
GOMOD := GO111MODULE=on go mod
|
|
|
|
|
|
|
|
|
|
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
|
|
|
|
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
|
|
|
|
|
GOLISTCOVER := $(shell go list -deps -f '{{.ImportPath}}' ./... | grep '$(PKG)' | sed -e 's/^$(ESCPKG)/./')
|
|
|
|
|
|
|
|
|
|
RM := rm -f
|
|
|
|
|
CP := cp
|
|
|
|
|
MAKE := make
|
|
|
|
|
XARGS := xargs -L 1
|
|
|
|
|
|
|
|
|
|
LINT = $(LINT_BIN) run -v
|
|
|
|
|
|
|
|
|
|
include make/release_flags.mk
|
|
|
|
|
|
|
|
|
|
# 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).
|
2020-07-21 22:06:15 +02:00
|
|
|
make_ldflags = $(2) -X $(LND_PKG)/build.Commit=lightning-terminal-$(COMMIT) \
|
2020-05-26 16:31:21 +02:00
|
|
|
-X $(LND_PKG)/build.CommitHash=$(COMMIT_HASH) \
|
|
|
|
|
-X $(LND_PKG)/build.GoVersion=$(GOVERSION) \
|
2020-11-12 20:57:23 +01:00
|
|
|
-X $(LND_PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g') \
|
|
|
|
|
-X $(LOOP_PKG).Commit=$(LOOP_COMMIT)
|
2020-05-26 16:31:21 +02:00
|
|
|
|
|
|
|
|
LDFLAGS := $(call make_ldflags, $(LND_RELEASE_TAGS))
|
|
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
RELEASE_LDFLAGS := $(call make_ldflags, $(LND_RELEASE_TAGS), -s -w -buildid=)
|
|
|
|
|
|
|
|
|
|
GREEN := "\\033[0;32m"
|
|
|
|
|
NC := "\\033[0m"
|
|
|
|
|
define print
|
|
|
|
|
echo $(GREEN)$1$(NC)
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
default: scratch
|
|
|
|
|
|
|
|
|
|
all: scratch check install
|
|
|
|
|
|
|
|
|
|
# ============
|
|
|
|
|
# DEPENDENCIES
|
|
|
|
|
# ============
|
|
|
|
|
|
|
|
|
|
$(GOVERALLS_BIN):
|
|
|
|
|
@$(call print, "Fetching goveralls.")
|
|
|
|
|
go get -u $(GOVERALLS_PKG)
|
|
|
|
|
|
|
|
|
|
$(LINT_BIN):
|
|
|
|
|
@$(call print, "Fetching linter")
|
|
|
|
|
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
|
|
|
|
|
|
|
|
|
|
$(GOACC_BIN):
|
|
|
|
|
@$(call print, "Fetching go-acc")
|
|
|
|
|
$(DEPGET) $(GOACC_PKG)@$(GOACC_COMMIT)
|
|
|
|
|
|
|
|
|
|
$(STATIK_BIN):
|
|
|
|
|
@$(call print, "Fetching statik")
|
|
|
|
|
$(DEPGET) $(STATIK_PKG)
|
|
|
|
|
|
|
|
|
|
yarn-install:
|
|
|
|
|
@$(call print, "Installing app dependencies with yarn")
|
|
|
|
|
cd app; yarn
|
|
|
|
|
|
|
|
|
|
# ============
|
|
|
|
|
# INSTALLATION
|
|
|
|
|
# ============
|
2020-12-09 17:47:15 +01:00
|
|
|
statik-only: $(STATIK_BIN)
|
2020-05-26 16:31:21 +02:00
|
|
|
@$(call print, "Building statik package.")
|
|
|
|
|
statik -src=app/build
|
|
|
|
|
|
2020-12-09 17:47:15 +01:00
|
|
|
statik-build: app-build statik-only
|
|
|
|
|
|
2020-05-26 16:31:21 +02:00
|
|
|
build: statik-build go-build
|
|
|
|
|
install: statik-build go-install
|
|
|
|
|
|
|
|
|
|
go-build:
|
2020-07-21 22:06:15 +02:00
|
|
|
@$(call print, "Building lightning-terminal.")
|
2020-07-21 22:10:33 +02:00
|
|
|
$(GOBUILD) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litd-debug $(PKG)/cmd/litd
|
2020-05-26 16:31:21 +02:00
|
|
|
|
|
|
|
|
go-install:
|
2020-07-21 22:06:15 +02:00
|
|
|
@$(call print, "Installing lightning-terminal.")
|
2020-07-21 22:10:33 +02:00
|
|
|
$(GOINSTALL) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litd
|
2020-05-26 16:31:21 +02:00
|
|
|
|
2020-11-25 15:28:50 +01:00
|
|
|
go-install-cli:
|
|
|
|
|
@$(call print, "Installing all CLI binaries.")
|
|
|
|
|
$(GOINSTALL) -trimpath -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" github.com/lightningnetwork/lnd/cmd/lncli
|
|
|
|
|
$(GOINSTALL) -trimpath -ldflags "$(LDFLAGS)" github.com/lightninglabs/loop/cmd/loop
|
|
|
|
|
$(GOINSTALL) -trimpath github.com/lightninglabs/faraday/cmd/frcli
|
|
|
|
|
$(GOINSTALL) -trimpath github.com/lightninglabs/pool/cmd/pool
|
|
|
|
|
|
2020-05-26 16:31:21 +02:00
|
|
|
app-build: yarn-install
|
|
|
|
|
@$(call print, "Building production app.")
|
|
|
|
|
cd app; yarn build
|
|
|
|
|
|
|
|
|
|
release: statik-build
|
2020-07-21 22:06:15 +02:00
|
|
|
@$(call print, "Creating release of lightning-terminal.")
|
2020-05-26 16:31:21 +02:00
|
|
|
./release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(LND_RELEASE_TAGS)" "$(RELEASE_LDFLAGS)"
|
|
|
|
|
|
|
|
|
|
scratch: build
|
|
|
|
|
|
|
|
|
|
# =======
|
|
|
|
|
# TESTING
|
|
|
|
|
# =======
|
|
|
|
|
|
|
|
|
|
check: unit
|
|
|
|
|
|
|
|
|
|
unit:
|
|
|
|
|
@$(call print, "Running unit tests.")
|
|
|
|
|
$(UNIT)
|
|
|
|
|
|
|
|
|
|
unit-cover: $(GOACC_BIN)
|
|
|
|
|
@$(call print, "Running unit coverage tests.")
|
|
|
|
|
$(GOACC_BIN) $(COVER_PKG)
|
|
|
|
|
|
|
|
|
|
unit-race:
|
|
|
|
|
@$(call print, "Running unit race tests.")
|
|
|
|
|
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
|
|
|
|
|
|
|
|
|
|
goveralls: $(GOVERALLS_BIN)
|
|
|
|
|
@$(call print, "Sending coverage report.")
|
|
|
|
|
$(GOVERALLS_BIN) -coverprofile=coverage.txt -service=travis-ci
|
|
|
|
|
|
|
|
|
|
travis-race: lint unit-race
|
|
|
|
|
|
|
|
|
|
travis-cover: lint unit-cover goveralls
|
|
|
|
|
|
|
|
|
|
travis-itest: lint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# =============
|
|
|
|
|
# FLAKE HUNTING
|
|
|
|
|
# =============
|
|
|
|
|
flake-unit:
|
|
|
|
|
@$(call print, "Flake hunting unit tests.")
|
|
|
|
|
while [ $$? -eq 0 ]; do GOTRACEBACK=all $(UNIT) -count=1; done
|
|
|
|
|
|
|
|
|
|
# =========
|
|
|
|
|
# UTILITIES
|
|
|
|
|
# =========
|
|
|
|
|
fmt:
|
|
|
|
|
@$(call print, "Formatting source.")
|
|
|
|
|
gofmt -l -w -s $(GOFILES_NOVENDOR)
|
|
|
|
|
|
|
|
|
|
lint: $(LINT_BIN)
|
|
|
|
|
@$(call print, "Linting source.")
|
|
|
|
|
$(LINT)
|
|
|
|
|
|
|
|
|
|
mod:
|
|
|
|
|
@$(call print, "Tidying modules.")
|
|
|
|
|
$(GOMOD) tidy
|
|
|
|
|
|
|
|
|
|
mod-check:
|
|
|
|
|
@$(call print, "Checking modules.")
|
|
|
|
|
$(GOMOD) tidy
|
|
|
|
|
if test -n "$$(git status | grep -e "go.mod\|go.sum")"; then echo "Running go mod tidy changes go.mod/go.sum"; git status; git diff; exit 1; fi
|
|
|
|
|
|
|
|
|
|
list:
|
|
|
|
|
@$(call print, "Listing commands.")
|
|
|
|
|
@$(MAKE) -qp | \
|
|
|
|
|
awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | \
|
|
|
|
|
grep -v Makefile | \
|
|
|
|
|
sort
|
|
|
|
|
|
2020-12-09 17:47:14 +01:00
|
|
|
protos:
|
|
|
|
|
@$(call print, "Compiling protos.")
|
|
|
|
|
cd ./app; yarn protos
|
|
|
|
|
|
|
|
|
|
protos-check: protos
|
|
|
|
|
@$(call print, "Verifying compiled protos.")
|
|
|
|
|
if test -n "$$(git describe --dirty | grep dirty)"; then echo "Protos not properly formatted or not compiled with v3.4.0"; git status; git diff; exit 1; fi
|
|
|
|
|
|
2020-05-26 16:31:21 +02:00
|
|
|
clean:
|
|
|
|
|
@$(call print, "Cleaning source.$(NC)")
|
2020-07-21 22:06:15 +02:00
|
|
|
$(RM) ./lightning-terminal-debug
|
2020-05-26 16:31:21 +02:00
|
|
|
$(RM) coverage.txt
|
|
|
|
|
$(RM) -r statik
|