You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.9 KiB

  1. .DEFAULT_GOAL := build
  2. PKG := github.com/lightninglabs/loop
  3. GOTEST := GO111MODULE=on go test -v
  4. GO_BIN := ${GOPATH}/bin
  5. GOBUILD := GO111MODULE=on go build -v
  6. GOINSTALL := GO111MODULE=on go install -v
  7. GOMOD := GO111MODULE=on go mod
  8. COMMIT := $(shell git describe --abbrev=40 --dirty)
  9. LDFLAGS := -ldflags "-X $(PKG).Commit=$(COMMIT)"
  10. DEV_TAGS = dev
  11. GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
  12. GOLIST := go list $(PKG)/... | grep -v '/vendor/'
  13. LINT_BIN := $(GO_BIN)/golangci-lint
  14. LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
  15. LINT_COMMIT := v1.18.0
  16. LINT = $(LINT_BIN) run -v
  17. DEPGET := cd /tmp && GO111MODULE=on go get -v
  18. XARGS := xargs -L 1
  19. TEST_FLAGS = -test.timeout=20m
  20. UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
  21. GREEN := "\\033[0;32m"
  22. NC := "\\033[0m"
  23. define print
  24. echo $(GREEN)$1$(NC)
  25. endef
  26. $(LINT_BIN):
  27. @$(call print, "Fetching linter")
  28. $(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
  29. unit:
  30. @$(call print, "Running unit tests.")
  31. $(UNIT)
  32. fmt:
  33. @$(call print, "Formatting source.")
  34. gofmt -l -w -s $(GOFILES_NOVENDOR)
  35. lint: $(LINT_BIN)
  36. @$(call print, "Linting source.")
  37. $(LINT)
  38. mod-tidy:
  39. @$(call print, "Tidying modules.")
  40. $(GOMOD) tidy
  41. mod-check:
  42. @$(call print, "Checking modules.")
  43. $(GOMOD) tidy
  44. 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
  45. # ============
  46. # INSTALLATION
  47. # ============
  48. build:
  49. @$(call print, "Building debug loop and loopd.")
  50. $(GOBUILD) -tags="$(DEV_TAGS)" -o loop-debug $(LDFLAGS) $(PKG)/cmd/loop
  51. $(GOBUILD) -tags="$(DEV_TAGS)" -o loopd-debug $(LDFLAGS) $(PKG)/cmd/loopd
  52. install:
  53. @$(call print, "Installing loop and loopd.")
  54. $(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/loop
  55. $(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/loopd
  56. rpc:
  57. @$(call print, "Compiling RPC protos.")
  58. cd looprpc; ./gen_protos.sh