2
0

Makefile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .DEFAULT_GOAL := all
  2. .DELETE_ON_ERROR:
  3. .SUFFIXES:
  4. include .env
  5. export
  6. PROJECT := $(shell cat go.mod | grep '^module\s' | cut -b 8-)
  7. export VERSION ?= $(shell date -u '+%F')-snapshot
  8. BUILD_TIME := $(shell date -u '+%F_%T')
  9. COMMIT_HASH := $(shell git rev-parse --short HEAD)
  10. GOLDFLAGS := '-linkmode external -w -s -X $(PROJECT)/version.BuildVersion=$(VERSION) -X $(PROJECT)/version.BuildCommitId=$(COMMIT_HASH) -X ${PROJECT}/version.BuildTime=$(BUILD_TIME)'
  11. .PHONY: all
  12. all: gen deps fmt test
  13. .PHONY: gen
  14. gen: gen-json gen-proto
  15. .PHONY: gen-json
  16. gen-json:
  17. -@echo "-> $@"
  18. easyjson platform/afreeca/bridge_message.go
  19. .PHONY: gen-proto
  20. gen-proto:
  21. -@echo "-> $@"
  22. @protoc -I=. --go_out=paths=source_relative:. proto/message.proto
  23. @cp proto/message.pb.go model/message.pb.go
  24. -@rm proto/message.pb.go
  25. .PHONY: deps
  26. deps:
  27. -@echo "-> $@"
  28. git submodule update --remote --init
  29. go mod tidy
  30. .PHONY: fmt
  31. fmt:
  32. -@echo "-> $@"
  33. -go fmt $(shell go list ./...)
  34. .PHONY: test
  35. test:
  36. -@echo "-> $@"
  37. CGO_ENABLED=1 go test -tags musl $(shell go list ./...)
  38. -go vet $(shell go list ./...)
  39. .PHONY: build
  40. build:
  41. -@echo "-> $@"
  42. -$(if $(filter $(VERSION),0.0.0), $(error "Please, provide version name"), @echo "== Starting to build version: $(VERSION)")
  43. @bash ./build.sh $(PROJECT) $(VERSION) $(GOLDFLAGS)