lnd.xprv/Makefile

212 lines
4.5 KiB
Makefile
Raw Normal View History

PKG := github.com/lightningnetwork/lnd
ESCPKG := github.com\/lightningnetwork\/lnd
BTCD_PKG := github.com/btcsuite/btcd
GOVERALLS_PKG := github.com/mattn/goveralls
2018-08-03 23:28:16 +03:00
LINT_PKG := gopkg.in/alecthomas/gometalinter.v2
GO_BIN := ${GOPATH}/bin
BTCD_BIN := $(GO_BIN)/btcd
GOVERALLS_BIN := $(GO_BIN)/goveralls
2018-08-03 23:28:16 +03:00
LINT_BIN := $(GO_BIN)/gometalinter.v2
HAVE_BTCD := $(shell command -v $(BTCD_BIN) 2> /dev/null)
HAVE_GOVERALLS := $(shell command -v $(GOVERALLS_BIN) 2> /dev/null)
HAVE_LINTER := $(shell command -v $(LINT_BIN) 2> /dev/null)
BTCD_DIR :=${GOPATH}/src/$(BTCD_PKG)
COMMIT := $(shell git describe --abbrev=40 --dirty)
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
BTCD_COMMIT := $(shell cat go.sum | \
grep $(BTCD_PKG) | \
tail -n1 | \
awk -F " " '{ print $$2 }' | \
awk -F "-" '{ print $$3 }' | \
awk -F "/" '{ print $$1 }')
GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GOTEST := GO111MODULE=on go test -v
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
GOLISTCOVER := $(shell go list -f '{{.ImportPath}}' ./... | sed -e 's/^$(ESCPKG)/./')
GOLISTLINT := $(shell go list -f '{{.Dir}}' ./... | grep -v 'lnrpc')
RM := rm -f
CP := cp
MAKE := make
XARGS := xargs -L 1
include make/testing_flags.mk
DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
PROD_TAGS := $(if ${tags},$(PROD_TAGS) ${tags},$(PROD_TAGS))
COVER = for dir in $(GOLISTCOVER); do \
$(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" \
-covermode=count \
-coverprofile=$$dir/profile.tmp $$dir; \
\
2018-09-09 11:48:37 +03:00
if [ $$? != 0 ] ; \
then \
exit 1; \
2018-09-09 11:48:37 +03:00
fi ; \
\
if [ -f $$dir/profile.tmp ]; then \
cat $$dir/profile.tmp | \
tail -n +2 >> profile.cov; \
$(RM) $$dir/profile.tmp; \
fi \
done
LINT = $(LINT_BIN) \
--disable-all \
--enable=gofmt \
--enable=vet \
--enable=golint \
--line-length=72 \
--deadline=4m $(GOLISTLINT) 2>&1 | \
grep -v 'ALL_CAPS\|OP_' 2>&1 | \
tee /dev/stderr
CGO_STATUS_QUO := ${CGO_ENABLED}
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):
2018-08-03 23:28:16 +03:00
@$(call print, "Fetching gometalinter.v2")
GO111MODULE=off go get -u $(LINT_PKG)
btcd:
@$(call print, "Installing btcd...")
go get -v github.com/btcsuite/btcd/@v0.0.0-20180823030728-$(BTCD_COMMIT)
# ============
# INSTALLATION
# ============
build:
@$(call print, "Building debug lnd and lncli.")
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(LDFLAGS) $(PKG)
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(LDFLAGS) $(PKG)/cmd/lncli
install:
@$(call print, "Installing lnd and lncli.")
$(GOINSTALL) -tags="$(PROD_TAGS)" $(LDFLAGS) $(PKG)
$(GOINSTALL) -tags="$(PROD_TAGS)" $(LDFLAGS) $(PKG)/cmd/lncli
scratch: build
# =======
# TESTING
# =======
check: unit itest
itest-only:
@$(call print, "Running integration tests.")
$(ITEST)
itest: btcd build itest-only
unit: btcd
@$(call print, "Running unit tests.")
$(UNIT)
unit-cover:
@$(call print, "Running unit coverage tests.")
echo "mode: count" > profile.cov
$(COVER)
unit-race:
@$(call print, "Running unit race tests.")
export CGO_ENABLED=1; env GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
export CGO_ENABLED=$(CGO_STATUS_QUO)
2018-10-11 11:31:04 +03:00
goveralls: $(GOVERALLS_BIN)
@$(call print, "Sending coverage report.")
$(GOVERALLS_BIN) -coverprofile=profile.cov -service=travis-ci
# =============
# FLAKE HUNTING
# =============
flakehunter: build
@$(call print, "Flake hunting integration tests.")
while [ $$? -eq 0 ]; do $(ITEST); done
flake-unit:
@$(call print, "Flake hunting unit tests.")
GOTRACEBACK=all $(UNIT) -count=1
while [ $$? -eq 0 ]; do /bin/sh -c "GOTRACEBACK=all $(UNIT) -count=1"; done
# =========
# UTILITIES
# =========
fmt:
@$(call print, "Formatting source.")
$(GOLIST) | $(XARGS) go fmt -x
lint: $(LINT_BIN)
@$(call print, "Linting source.")
GO111MODULE=off $(LINT_BIN) --install 1> /dev/null
test -z "$$($(LINT))"
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
rpc:
@$(call print, "Compiling protos.")
cd ./lnrpc; ./gen_protos.sh
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) ./lnd-debug ./lncli-debug
$(RM) -r ./vendor .vendor-new
.PHONY: all \
2018-09-09 11:48:37 +03:00
btcd \
default \
build \
install \
scratch \
check \
itest-only \
itest \
unit \
unit-cover \
unit-race \
2018-10-11 11:31:04 +03:00
goveralls \
flakehunter \
flake-unit \
fmt \
lint \
list \
rpc \
clean