Files

188 lines
4.7 KiB
Makefile
Raw Permalink Normal View History

# ==============================================================================
# define the default goal
#
.DEFAULT_GOAL := help
2023-07-05 22:12:48 +08:00
## all: Run tidy, gen, add-copyright, format, lint, cover, build ✨
.PHONY: all
all: tidy gen add-copyright format lint cover build
# ==============================================================================
# Build set
ROOT_PACKAGE=github.com/OpenIMSDK/Open-IM-Server
# TODO: This is version control for the future
VERSION_PACKAGE=github.com/OpenIMSDK/Open-IM-Server/pkg/version
# ==============================================================================
# Includes
2023-06-30 17:52:55 +08:00
include scripts/make-rules/common.mk # make sure include common.mk at the first include line
include scripts/make-rules/golang.mk
include scripts/make-rules/image.mk
include scripts/make-rules/copyright.mk
include scripts/make-rules/gen.mk
include scripts/make-rules/dependencies.mk
include scripts/make-rules/tools.mk
2023-07-04 09:16:40 +08:00
include scripts/make-rules/release.mk
2023-07-04 20:18:39 +08:00
include scripts/make-rules/swagger.mk
# ==============================================================================
# Usage
define USAGE_OPTIONS
Options:
DEBUG Whether or not to generate debug symbols. Default is 0.
BINS Binaries to build. Default is all binaries under cmd.
This option is available when using: make {build}(.multiarch)
2023-07-07 19:45:32 +08:00
Example: make build BINS="openim-api openim-cmdutils".
PLATFORMS Platform to build for. Default is linux_arm64 and linux_amd64.
This option is available when using: make {build}.multiarch
2023-07-07 12:03:20 +08:00
Example: make multiarch PLATFORMS="linux_s390x linux_mips64
2023-07-05 10:21:38 +08:00
linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64".
V Set to 1 enable verbose build. Default is 0.
endef
export USAGE_OPTIONS
# ==============================================================================
# Targets
2023-07-05 22:12:48 +08:00
## build: Build binaries by default ✨
.PHONY: build
build:
@$(MAKE) go.build
2023-07-05 22:12:48 +08:00
## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
2023-07-04 09:16:40 +08:00
.PHONY: multiarch
multiarch:
2023-06-10 09:07:20 +08:00
@$(MAKE) go.build.multiarch
2023-07-05 22:12:48 +08:00
## tidy: tidy go.mod ✨
.PHONY: tidy
tidy:
@$(GO) mod tidy
2023-07-05 22:12:48 +08:00
## vendor: vendor go.mod ✨
.PHONY: vendor
vendor:
@$(GO) mod vendor
2023-07-05 22:12:48 +08:00
## style: code style -> fmt,vet,lint ✨
2023-06-09 10:06:15 +08:00
.PHONY: style
style: fmt vet lint
2023-07-05 22:12:48 +08:00
## fmt: Run go fmt against code. ✨
.PHONY: fmt
fmt:
@$(GO) fmt ./...
2023-07-05 22:12:48 +08:00
## vet: Run go vet against code. ✨
.PHONY: vet
vet:
@$(GO) vet ./...
2023-07-11 22:14:44 +08:00
## lint: Check syntax and styling of go sources. ✨
.PHONY: lint
lint:
@$(MAKE) go.lint
2023-07-05 22:12:48 +08:00
## format: Gofmt (reformat) package sources (exclude vendor dir if existed). ✨
.PHONY: format
2023-06-09 10:06:15 +08:00
format:
@$(MAKE) go.format
2023-07-05 22:12:48 +08:00
## test: Run unit test. ✨
.PHONY: test
test:
@$(MAKE) go.test
2023-07-05 22:12:48 +08:00
## cover: Run unit test and get test coverage. ✨
.PHONY: cover
cover:
@$(MAKE) go.test.cover
2023-07-07 12:03:20 +08:00
## updates: Check for updates to go.mod dependencies. ✨
.PHONY: updates
@$(MAKE) go.updates
2023-07-07 12:03:20 +08:00
## imports: task to automatically handle import packages in Go files using goimports tool. ✨
.PHONY: imports
imports:
@$(MAKE) go.imports
2023-07-05 22:12:48 +08:00
## clean: Remove all files that are created by building. ✨
.PHONY: clean
clean:
@$(MAKE) go.clean
2023-07-05 22:12:48 +08:00
## image: Build docker images for host arch. ✨
2023-06-30 10:31:13 +08:00
.PHONY: image
image:
@$(MAKE) image.build
2023-07-05 22:12:48 +08:00
## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS. ✨
2023-06-30 10:31:13 +08:00
.PHONY: image.multiarch
image.multiarch:
@$(MAKE) image.build.multiarch
2023-07-05 22:12:48 +08:00
## push: Build docker images for host arch and push images to registry. ✨
2023-06-30 10:31:13 +08:00
.PHONY: push
push:
@$(MAKE) image.push
2023-07-05 22:12:48 +08:00
## push.multiarch: Build docker images for multiple platforms and push images to registry. ✨
2023-06-30 10:31:13 +08:00
.PHONY: push.multiarch
push.multiarch:
@$(MAKE) image.push.multiarch
2023-07-05 22:12:48 +08:00
## tools: Install dependent tools. ✨
.PHONY: tools
tools:
@$(MAKE) tools.install
2023-07-05 22:12:48 +08:00
## gen: Generate all necessary files. ✨
.PHONY: gen
gen:
@$(MAKE) gen.run
2023-07-05 22:12:48 +08:00
## swagger: Generate swagger document. ✨
2023-07-04 20:18:39 +08:00
.PHONY: swagger
swagger:
@$(MAKE) swagger.run
2023-07-05 22:12:48 +08:00
## serve-swagger: Serve swagger spec and docs. ✨
2023-07-04 20:18:39 +08:00
.PHONY: swagger.serve
serve-swagger:
@$(MAKE) swagger.serve
2023-07-05 22:12:48 +08:00
## verify-copyright: Verify the license headers for all files. ✨
.PHONY: verify-copyright
verify-copyright:
@$(MAKE) copyright.verify
2023-07-05 22:12:48 +08:00
## add-copyright: Add copyright ensure source code files have license headers. ✨
.PHONY: add-copyright
add-copyright:
@$(MAKE) copyright.add
2023-07-05 22:12:48 +08:00
## release: release the project ✨
2023-07-04 14:26:24 +08:00
.PHONY: release
release: release.verify release.ensure-tag
@scripts/release.sh
2023-07-05 22:12:48 +08:00
## help: Show this help info. ✨
.PHONY: help
help: Makefile
$(call makehelp)
2023-07-05 22:12:48 +08:00
## help-all: Show all help details info. ✨
.PHONY: help-all
2023-07-05 22:12:48 +08:00
help-all: go.help copyright.help tools.help image.help dependencies.help gen.help release.help swagger.help help
2023-07-11 22:14:44 +08:00
$(call makeallhelp)