feat(make): complete mk's build module

Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
pull/407/head
Xinwei Xiong(cubxxw) 2 years ago
parent 04d3f3e6c5
commit 3aecfa1a1b

2
.gitignore vendored

@ -27,7 +27,7 @@ out-test
tools/ tools/
tmp/ tmp/
bin/ bin/
output/ _output/
### OpenIM deploy ### ### OpenIM deploy ###
deploy/open_im_demo deploy/open_im_demo

@ -1 +0,0 @@
Subproject commit e731cb86ec9314a0b30b4f8331d53854c2c9d858

@ -87,6 +87,8 @@ PLATFORMS ?= linux_amd64 linux_arm64
# The OS can be linux/windows/darwin when building binaries # The OS can be linux/windows/darwin when building binaries
# PLATFORMS ?= darwin_amd64 windows_amd64 linux_amd64 linux_arm64 # PLATFORMS ?= darwin_amd64 windows_amd64 linux_amd64 linux_arm64
# only support linux
GOOS=linux
# set a specific PLATFORM, defaults to the host platform # set a specific PLATFORM, defaults to the host platform
ifeq ($(origin PLATFORM), undefined) ifeq ($(origin PLATFORM), undefined)

@ -88,6 +88,11 @@ EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open
# BIN_DIR=/root/workspaces/OpenIM/_output/bin # BIN_DIR=/root/workspaces/OpenIM/_output/bin
# ============================================================================== # ==============================================================================
## go.build: Build binaries
.PHONY: go.build
go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
@echo "===========> Building binary $(BINS) $(VERSION) for $(PLATFORM)"
## go.build.verify: Verify that a suitable version of Go exists ## go.build.verify: Verify that a suitable version of Go exists
.PHONY: go.build.verify .PHONY: go.build.verify
go.build.verify: go.build.verify:
@ -106,12 +111,7 @@ go.build.%:
@echo "=====> BIN_DIR=$(BIN_DIR)" @echo "=====> BIN_DIR=$(BIN_DIR)"
@echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS)_$(ARCH)" @echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS)_$(ARCH)"
@mkdir -p $(OUTPUT_DIR)/platforms/$(OS)/$(ARCH) @mkdir -p $(OUTPUT_DIR)/platforms/$(OS)/$(ARCH)
@CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(OUTPUT_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_PACKAGE)/cmd/$(COMMAND) @CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(OUTPUT_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/cmd/$(COMMAND)/main.go
## go.build: Build binaries
.PHONY: go.build
go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
@echo "===========> Building binary $(BINS) $(VERSION) for $(PLATFORM)"
## go.multiarch: Build multi-arch binaries ## go.multiarch: Build multi-arch binaries
.PHONY: go.build.multiarch .PHONY: go.build.multiarch

@ -17,7 +17,7 @@
# Why download to the tools directory, thinking we might often switch Go versions using gvm. # Why download to the tools directory, thinking we might often switch Go versions using gvm.
# #
# sealer build use BUILD_TOOLS # openim build use BUILD_TOOLS
BUILD_TOOLS ?= golangci-lint goimports addlicense deepcopy-gen conversion-gen ginkgo go-junit-report go-gitlint BUILD_TOOLS ?= golangci-lint goimports addlicense deepcopy-gen conversion-gen ginkgo go-junit-report go-gitlint
# Code analysis tools # Code analysis tools
ANALYSIS_TOOLS = golangci-lint goimports golines go-callvis kube-score ANALYSIS_TOOLS = golangci-lint goimports golines go-callvis kube-score
@ -71,7 +71,6 @@ install.golangci-lint:
install.goimports: install.goimports:
@$(GO) install golang.org/x/tools/cmd/goimports@latest @$(GO) install golang.org/x/tools/cmd/goimports@latest
# Actions path: https://github.com/sealerio/sealer/tree/main/.github/workflows/go.yml#L37-L50
## install.addlicense: Install addlicense, used to add license header to source files ## install.addlicense: Install addlicense, used to add license header to source files
.PHONY: install.addlicense .PHONY: install.addlicense
install.addlicense: install.addlicense:

Loading…
Cancel
Save