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.

40 lines
1022 B

4 years ago
  1. .PHONY: all build run gotool clean help
  2. BINARY="server"
  3. GVA = "gva"
  4. all: check gva initdb run
  5. gva:
  6. go build -o ${GVA} cmd/main.go
  7. initdb:
  8. @if [ -f ${GVA} ] ; then ./gva initdb && rm ${GVA} ; fi
  9. linux-build:
  10. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
  11. windows-build:
  12. CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ${BINARY}.exe
  13. mac-build:
  14. CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ${BINARY}
  15. run:
  16. @go run main.go
  17. check:
  18. go fmt ./
  19. go vet ./
  20. clean:
  21. @if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi
  22. @if [ -f ${GVA} ] ; then rm ${GVA} ; fi
  23. help:
  24. @echo "make - 格式化 Go 代码, 并编译生成二进制文件"
  25. @echo "make linux-build - 编译 Go 代码, 生成Linux系统的二进制文件"
  26. @echo "make windows-build - 编译 Go 代码, 生成Windows系统的exe文件"
  27. @echo "make mac-build - 编译 Go 代码, 生成Mac系统的二进制文件"
  28. @echo "make run - 直接运行 main.go"
  29. @echo "make clean - 移除二进制文件"
  30. @echo "make check - 运行 Go 工具 'fmt' and 'vet'"