|
| 1 | +# ============================================================================== |
| 2 | +# define the default goal |
| 3 | +# |
| 4 | + |
| 5 | +.DEFAULT_GOAL := help |
| 6 | + |
| 7 | +## all: Run tidy, gen, add-copyright, format, lint, cover, build ✨ |
| 8 | +.PHONY: all |
| 9 | +all: tidy gen add-copyright verify lint cover restart |
| 10 | + |
| 11 | +# ============================================================================== |
| 12 | +# Build set |
| 13 | + |
| 14 | +ROOT_PACKAGE=github.com/OpenIMSDK/Open-IM-Server |
| 15 | +# TODO: This is version control for the future https://github.com/OpenIMSDK/Open-IM-Server/issues/574 |
| 16 | +VERSION_PACKAGE=github.com/OpenIMSDK/Open-IM-Server/pkg/version |
| 17 | + |
| 18 | +# ============================================================================== |
| 19 | +# Includes |
| 20 | + |
| 21 | +include scripts/make-rules/common.mk # make sure include common.mk at the first include line |
| 22 | +include scripts/make-rules/golang.mk |
| 23 | +include scripts/make-rules/image.mk |
| 24 | +include scripts/make-rules/copyright.mk |
| 25 | +include scripts/make-rules/gen.mk |
| 26 | +include scripts/make-rules/dependencies.mk |
| 27 | +include scripts/make-rules/tools.mk |
| 28 | +include scripts/make-rules/release.mk |
| 29 | +include scripts/make-rules/swagger.mk |
| 30 | + |
| 31 | +# ============================================================================== |
| 32 | +# Usage |
| 33 | + |
| 34 | +define USAGE_OPTIONS |
| 35 | + |
| 36 | +Options: |
| 37 | + |
| 38 | + DEBUG Whether or not to generate debug symbols. Default is 0. |
| 39 | + |
| 40 | + BINS Binaries to build. Default is all binaries under cmd. |
| 41 | + This option is available when using: make {build}(.multiarch) |
| 42 | + Example: make build BINS="openim-api openim-cmdutils". |
| 43 | + |
| 44 | + PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64. |
| 45 | + This option is available when using: make {build}.multiarch |
| 46 | + Example: make multiarch PLATFORMS="linux_s390x linux_mips64 |
| 47 | + linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64". |
| 48 | + |
| 49 | + V Set to 1 enable verbose build. Default is 0. |
| 50 | +endef |
| 51 | +export USAGE_OPTIONS |
| 52 | + |
| 53 | +# ============================================================================== |
| 54 | +# Targets |
| 55 | + |
| 56 | +## init: Initialize openim server project ✨ |
| 57 | +.PHONY: init |
| 58 | +init: |
| 59 | + @$(MAKE) gen.init |
| 60 | + |
| 61 | +## demo: Run demo get started with Makefiles quickly ✨ |
| 62 | +.PHONY: demo |
| 63 | +demo: |
| 64 | + @$(MAKE) go.demo |
| 65 | + |
| 66 | +## build: Build binaries by default ✨ |
| 67 | +.PHONY: build |
| 68 | +build: |
| 69 | + @$(MAKE) go.build |
| 70 | + |
| 71 | +## start: Start openim ✨ |
| 72 | +.PHONY: start |
| 73 | +start: |
| 74 | + @$(MAKE) go.start |
| 75 | + |
| 76 | +## stop: Stop openim ✨ |
| 77 | +.PHONY: stop |
| 78 | +stop: |
| 79 | + @$(MAKE) go.stop |
| 80 | + |
| 81 | +## restart: Restart openim ✨ |
| 82 | +.PHONY: restart |
| 83 | +restart: clean stop build init start |
| 84 | + |
| 85 | +## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨ |
| 86 | +.PHONY: multiarch |
| 87 | +multiarch: |
| 88 | + @$(MAKE) go.build.multiarch |
| 89 | + |
| 90 | +## verify: execute all verity scripts. ✨ |
| 91 | +.PHONY: verify |
| 92 | +verify: |
| 93 | + @$(MAKE) go.verify |
| 94 | + |
| 95 | +## install: Install deployment openim ✨ |
| 96 | +.PHONY: install |
| 97 | +install: |
| 98 | + @$(MAKE) go.install |
| 99 | + |
| 100 | +## check: Check OpenIM deployment ✨ |
| 101 | +.PHONY: check |
| 102 | +check: |
| 103 | + @$(MAKE) go.check |
| 104 | + |
| 105 | +## check-component |
| 106 | +.PHONY: check-component |
| 107 | +check-component: |
| 108 | + @$(MAKE) go.check-component |
| 109 | + |
| 110 | +## tidy: tidy go.mod ✨ |
| 111 | +.PHONY: tidy |
| 112 | +tidy: |
| 113 | + @$(GO) mod tidy |
| 114 | + |
| 115 | +## vendor: vendor go.mod ✨ |
| 116 | +.PHONY: vendor |
| 117 | +vendor: |
| 118 | + @$(GO) mod vendor |
| 119 | + |
| 120 | +## style: code style -> fmt,vet,lint ✨ |
| 121 | +.PHONY: style |
| 122 | +style: fmt vet lint |
| 123 | + |
| 124 | +## fmt: Run go fmt against code. ✨ |
| 125 | +.PHONY: fmt |
| 126 | +fmt: |
| 127 | + @$(GO) fmt ./... |
| 128 | + |
| 129 | +## vet: Run go vet against code. ✨ |
| 130 | +.PHONY: vet |
| 131 | +vet: |
| 132 | + @$(GO) vet ./... |
| 133 | + |
| 134 | +## lint: Check syntax and styling of go sources. ✨ |
| 135 | +.PHONY: lint |
| 136 | +lint: |
| 137 | + @$(MAKE) go.lint |
| 138 | + |
| 139 | +## format: Gofmt (reformat) package sources (exclude vendor dir if existed). ✨ |
| 140 | +.PHONY: format |
| 141 | +format: |
| 142 | + @$(MAKE) go.format |
| 143 | + |
| 144 | +## test: Run unit test. ✨ |
| 145 | +.PHONY: test |
| 146 | +test: |
| 147 | + @$(MAKE) go.test |
| 148 | + |
| 149 | +## cover: Run unit test and get test coverage. ✨ |
| 150 | +.PHONY: cover |
| 151 | +cover: |
| 152 | + @$(MAKE) go.test.cover |
| 153 | + |
| 154 | +## updates: Check for updates to go.mod dependencies. ✨ |
| 155 | +.PHONY: updates |
| 156 | + @$(MAKE) go.updates |
| 157 | + |
| 158 | +## imports: task to automatically handle import packages in Go files using goimports tool. ✨ |
| 159 | +.PHONY: imports |
| 160 | +imports: |
| 161 | + @$(MAKE) go.imports |
| 162 | + |
| 163 | +## clean: Remove all files that are created by building. ✨ |
| 164 | +.PHONY: clean |
| 165 | +clean: |
| 166 | + @$(MAKE) go.clean |
| 167 | + |
| 168 | +## image: Build docker images for host arch. ✨ |
| 169 | +.PHONY: image |
| 170 | +image: |
| 171 | + @$(MAKE) image.build |
| 172 | + |
| 173 | +## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS. ✨ |
| 174 | +.PHONY: image.multiarch |
| 175 | +image.multiarch: |
| 176 | + @$(MAKE) image.build.multiarch |
| 177 | + |
| 178 | +## push: Build docker images for host arch and push images to registry. ✨ |
| 179 | +.PHONY: push |
| 180 | +push: |
| 181 | + @$(MAKE) image.push |
| 182 | + |
| 183 | +## push.multiarch: Build docker images for multiple platforms and push images to registry. ✨ |
| 184 | +.PHONY: push.multiarch |
| 185 | +push.multiarch: |
| 186 | + @$(MAKE) image.push.multiarch |
| 187 | + |
| 188 | +## tools: Install dependent tools. ✨ |
| 189 | +.PHONY: tools |
| 190 | +tools: |
| 191 | + @$(MAKE) tools.install |
| 192 | + |
| 193 | +## gen: Generate all necessary files. ✨ |
| 194 | +.PHONY: gen |
| 195 | +gen: |
| 196 | + @$(MAKE) gen.run |
| 197 | + |
| 198 | +## swagger: Generate swagger document. ✨ |
| 199 | +.PHONY: swagger |
| 200 | +swagger: |
| 201 | + @$(MAKE) swagger.run |
| 202 | + |
| 203 | +## serve-swagger: Serve swagger spec and docs. ✨ |
| 204 | +.PHONY: swagger.serve |
| 205 | +serve-swagger: |
| 206 | + @$(MAKE) swagger.serve |
| 207 | + |
| 208 | +## verify-copyright: Verify the license headers for all files. ✨ |
| 209 | +.PHONY: verify-copyright |
| 210 | +verify-copyright: |
| 211 | + @$(MAKE) copyright.verify |
| 212 | + |
| 213 | +## add-copyright: Add copyright ensure source code files have license headers. ✨ |
| 214 | +.PHONY: add-copyright |
| 215 | +add-copyright: |
| 216 | + @$(MAKE) copyright.add |
| 217 | + |
| 218 | +## advertise: Project introduction, become a contributor ✨ |
| 219 | +.PHONY: advertise |
| 220 | +advertise: |
| 221 | + @$(MAKE) copyright.advertise |
| 222 | + |
| 223 | +## release: release the project ✨ |
| 224 | +.PHONY: release |
| 225 | +release: release.verify release.ensure-tag |
| 226 | + @scripts/release.sh |
| 227 | + |
| 228 | +## help: Show this help info. ✨ |
| 229 | +.PHONY: help |
| 230 | +help: Makefile |
| 231 | + $(call makehelp) |
| 232 | + |
| 233 | +## help-all: Show all help details info. ✨ |
| 234 | +.PHONY: help-all |
| 235 | +help-all: go.help copyright.help tools.help image.help dependencies.help gen.help release.help swagger.help help |
| 236 | + $(call makeallhelp) |
0 commit comments