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

makefile 3.4 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. VERSION=$(shell cat "./VERSION" 2> /dev/null)
  18. GO_FLAGS := -ldflags "-X main.Branch=$(GIT_BRANCH) -X main.Revision=$(GIT_REVISION) -X main.Version=$(VERSION) -extldflags \"-static\" -s -w" -tags netgo
  19. GO = go
  20. GO_PATH = $(shell $(GO) env GOPATH)
  21. GO_OS = $(shell $(GO) env GOOS)
  22. ifeq ($(GO_OS), darwin)
  23. GO_OS = mac
  24. endif
  25. ifeq ($(shell uname -s), Darwin)
  26. SHA256_CMD = shasum -a 256
  27. else
  28. SHA256_CMD = sha256sum
  29. endif
  30. # License environment
  31. GO_LICENSE_CHECKER_DIR = license-header-checker-$(GO_OS)
  32. GO_LICENSE_CHECKER = $(GO_PATH)/bin/license-header-checker
  33. LICENSE_DIR = /tmp/tools/license
  34. # format import code
  35. format-import:
  36. go get -d github.com/dubbogo/tools/cmd/imports-formatter
  37. imports-formatter -path . -module seata.apache.org/seata-go -bl false
  38. unit-test:
  39. go test ./pkg/... -coverprofile=coverage.txt -covermode=atomic
  40. # Generate binaries for a Cortex release
  41. dist dist/seatago-linux-amd64 dist/seatago-darwin-amd64 dist/seatago-linux-amd64-sha-256 dist/seatago-darwin-amd64-sha-256:
  42. rm -fr ./dist
  43. mkdir -p ./dist
  44. GOOS="linux" GOARCH="amd64" CGO_ENABLED=0 go build $(GO_FLAGS) -o ./dist/seatago-linux-amd64 ./cmd
  45. GOOS="darwin" GOARCH="amd64" CGO_ENABLED=0 go build $(GO_FLAGS) -o ./dist/seatago-darwin-amd64 ./cmd
  46. $(SHA256_CMD) ./dist/seatago-darwin-amd64 | cut -d ' ' -f 1 > ./dist/seatago-darwin-amd64-sha-256
  47. $(SHA256_CMD) ./dist/seatago-linux-amd64 | cut -d ' ' -f 1 > ./dist/seatago-linux-amd64-sha-256
  48. # Generate binaries for a Cortex release
  49. build dist/seatago dist/seatago-sha-256:
  50. rm -fr ./dist
  51. mkdir -p ./dist
  52. CGO_ENABLED=0 go build $(GO_FLAGS) -o ./dist/seatago ./cmd
  53. $(SHA256_CMD) ./dist/seatago | cut -d ' ' -f 1 > ./dist/seatago-sha-256
  54. #docker-build:
  55. # docker build -t seatago/seatago:latest .
  56. integration-test:
  57. @go clean -testcache
  58. go test -tags integration -v ./test/...
  59. clean:
  60. @rm -rf coverage.txt
  61. @rm -rf dist
  62. prepareLic:
  63. echo 'The makefile is for ci test and has dependencies. Do not run it locally. If you want to run the unit tests, run command `go test ./...` directly.'
  64. $(GO_LICENSE_CHECKER) -version || (wget https://github.com/lsm-dev/license-header-checker/releases/download/v1.2.0/$(GO_LICENSE_CHECKER_DIR).zip -O $(GO_LICENSE_CHECKER_DIR).zip && unzip -o $(GO_LICENSE_CHECKER_DIR).zip && mkdir -p $(GO_PATH)/bin/ && cp $(GO_LICENSE_CHECKER_DIR)/64bit/license-header-checker $(GO_PATH)/bin/)
  65. ls /tmp/tools/license/license.txt || wget -P $(LICENSE_DIR) https://github.com/dubbogo/resources/raw/master/tools/license/license.txt
  66. .PHONY: license
  67. license: prepareLic
  68. $(GO_LICENSE_CHECKER) -v -a -r -i vendor $(LICENSE_DIR)/license.txt . go && [[ -z `git status -s` ]]