2020-05-14 09:33:08 +00:00
|
|
|
.DEFAULT_GOAL := build
|
|
|
|
|
2019-03-07 09:19:27 +00:00
|
|
|
PKG := github.com/lightninglabs/loop
|
|
|
|
|
|
|
|
GOTEST := GO111MODULE=on go test -v
|
|
|
|
|
2019-10-07 15:29:07 +00:00
|
|
|
GO_BIN := ${GOPATH}/bin
|
2020-04-15 07:10:08 +00:00
|
|
|
GOBUILD := GO111MODULE=on go build -v
|
|
|
|
GOINSTALL := GO111MODULE=on go install -v
|
2020-06-01 10:41:36 +00:00
|
|
|
GOMOD := GO111MODULE=on go mod
|
2020-04-15 07:10:08 +00:00
|
|
|
|
|
|
|
COMMIT := $(shell git describe --abbrev=40 --dirty)
|
|
|
|
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
|
2020-10-15 11:49:05 +00:00
|
|
|
DEV_TAGS = dev
|
2019-10-07 15:29:07 +00:00
|
|
|
|
|
|
|
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
2019-03-07 09:19:27 +00:00
|
|
|
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
|
|
|
|
|
2019-10-07 15:29:07 +00:00
|
|
|
LINT_BIN := $(GO_BIN)/golangci-lint
|
|
|
|
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
|
|
LINT_COMMIT := v1.18.0
|
|
|
|
LINT = $(LINT_BIN) run -v
|
|
|
|
|
|
|
|
DEPGET := cd /tmp && GO111MODULE=on go get -v
|
2019-03-07 09:19:27 +00:00
|
|
|
XARGS := xargs -L 1
|
|
|
|
|
|
|
|
TEST_FLAGS = -test.timeout=20m
|
|
|
|
|
|
|
|
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
|
|
|
|
|
2020-06-01 10:41:36 +00:00
|
|
|
GREEN := "\\033[0;32m"
|
|
|
|
NC := "\\033[0m"
|
|
|
|
define print
|
|
|
|
echo $(GREEN)$1$(NC)
|
|
|
|
endef
|
|
|
|
|
2019-10-07 15:29:07 +00:00
|
|
|
$(LINT_BIN):
|
|
|
|
@$(call print, "Fetching linter")
|
|
|
|
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
|
|
|
|
|
2019-03-07 09:19:27 +00:00
|
|
|
unit:
|
|
|
|
@$(call print, "Running unit tests.")
|
|
|
|
$(UNIT)
|
2019-10-07 15:29:07 +00:00
|
|
|
|
|
|
|
fmt:
|
|
|
|
@$(call print, "Formatting source.")
|
|
|
|
gofmt -l -w -s $(GOFILES_NOVENDOR)
|
|
|
|
|
|
|
|
lint: $(LINT_BIN)
|
|
|
|
@$(call print, "Linting source.")
|
2020-04-15 07:10:08 +00:00
|
|
|
$(LINT)
|
|
|
|
|
2020-06-01 10:41:36 +00:00
|
|
|
mod-tidy:
|
|
|
|
@$(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
|
|
|
|
|
2020-04-15 07:10:08 +00:00
|
|
|
# ============
|
|
|
|
# INSTALLATION
|
|
|
|
# ============
|
|
|
|
|
|
|
|
build:
|
|
|
|
@$(call print, "Building debug loop and loopd.")
|
2020-10-15 11:49:05 +00:00
|
|
|
$(GOBUILD) -tags="$(DEV_TAGS)" -o loop-debug $(LDFLAGS) $(PKG)/cmd/loop
|
|
|
|
$(GOBUILD) -tags="$(DEV_TAGS)" -o loopd-debug $(LDFLAGS) $(PKG)/cmd/loopd
|
2020-04-15 07:10:08 +00:00
|
|
|
|
|
|
|
install:
|
|
|
|
@$(call print, "Installing loop and loopd.")
|
2020-10-15 11:49:05 +00:00
|
|
|
$(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/loop
|
|
|
|
$(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/loopd
|