Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # build all by default
  2. .DEFAULT_GOAL := all
  3. .PHONY: all
  4. all: clean tidy swagger build # lint暂时不能通过
  5. # ==============================================================================
  6. # Build options
  7. ROOT_PACKAGE=dy-admin
  8. VERSION_PACKAGE=dy-admin/pkg/version
  9. # ==============================================================================
  10. # Includes
  11. include scripts/make-rules/common.mk # make sure include common.mk at the first include line
  12. include scripts/make-rules/golang.mk
  13. include scripts/make-rules/swagger.mk
  14. include scripts/make-rules/image.mk
  15. # ==============================================================================
  16. # Usage
  17. define USAGE_OPTIONS
  18. Options:
  19. DEBUG Whether to generate debug symbols. Default is 0.
  20. BINS The binaries to build. Default is all of cmd.
  21. This option is available when using: make build/build.multiarch
  22. Example: make build BINS="appctl application"
  23. IMAGES Backend images to make.
  24. This option is available when using: make image/image.multiarch/push/push.multiarch
  25. Example: make image.multiarch IMAGES="appctl application"
  26. REGISTRY_PREFIX Docker registry prefix.
  27. Example:
  28. PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64.
  29. This option is available when using: make build.multiarch/image.multiarch/push.multiarch
  30. Example: make image.multiarch IMAGES="appctl application" PLATFORMS="linux_amd64 linux_arm64"
  31. VERSION The version information compiled into binaries.
  32. The default is obtained from gsemver or git.
  33. V Set to 1 enable verbose build. Default is 0.
  34. endef
  35. export USAGE_OPTIONS
  36. # ==============================================================================
  37. # Targets
  38. ## clean: 删除编译时产生的所有文件.
  39. .PHONY: clean
  40. clean:
  41. @echo "===========> Cleaning all build output"
  42. @-rm -vrf $(OUTPUT_DIR)
  43. ## build: 根据当前平台编译对应的application可执行文件.
  44. .PHONY: build
  45. build:
  46. @$(MAKE) go.build
  47. ## build.multiarch: 编译多平台的可执行文件. See option PLATFORMS.
  48. .PHONY: build.multiarch
  49. build.multiarch:
  50. @$(MAKE) go.build.multiarch
  51. ## lint: 代码静态检查.
  52. .PHONY: lint
  53. lint:
  54. @$(MAKE) go.lint
  55. ## install: 安装开发项目时的所有工具(网络不好请重试).
  56. .PHONY: install
  57. install:
  58. @$(MAKE) tools.install
  59. ## swagger: 生成swagger文档.
  60. .PHONY: swagger
  61. swagger:
  62. @$(MAKE) swagger.run
  63. ## serve-swagger: 启动swagger接口服务
  64. .PHONY: serve-swagger
  65. serve-swagger:
  66. @$(MAKE) swagger.serve
  67. ## tidy: 安装go mod 依赖
  68. .PHONY: tidy
  69. tidy:
  70. @$(GO) mod tidy -go=1.17
  71. ## image: 制作镜像并推送到指定仓库
  72. .PHONY: image
  73. image:
  74. @$(MAKE) image.build
  75. ## help: Show this help info.
  76. .PHONY: help
  77. help: Makefile
  78. @echo -e "\nUsage: make <TARGETS> <OPTIONS> ...\n\nTargets:"
  79. @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
  80. @echo "$$USAGE_OPTIONS"
  81. .PHONY: testmk
  82. testmk:
  83. @echo ${ROOT_DIR}
  84. @echo $(wildcard ${ROOT_DIR}/build/docker/*)
  85. # @echo $(foreach image,${IMAGES_DIR},$(notdir ${image}))
  86. # @echo $(filter-out tools,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
  87. # @echo $(addprefix image.build., $(addprefix $(IMAGE_PLAT)., $(IMAGES)))
  88. # @echo $(addprefix go.build., $(addprefix $(PLATFORM)., $(ROOT_DIR)))
  89. # @echo $(ROOT_PACKAGE)
  90. # @echo $(filter-out %docs, $(wildcard ${ROOT_DIR}/cmd/*))