-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wanglei.w
committed
Mar 31, 2023
1 parent
d3e2ecd
commit c00ba4d
Showing
4 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# All targets. | ||
.PHONY: lint test build publish clean help | ||
|
||
# Current version of the project. | ||
VersionMain ?= 0.1.1 | ||
|
||
|
||
# Target binaries. You can build multiple binaries for a single project. | ||
TARGETS := wiki | ||
PLAT_FROM := linux darwin windows | ||
|
||
# Project main package location (can be multiple ones). | ||
CMD_DIR := . | ||
# Project output directory. | ||
OUTPUT_DIR := ./output | ||
# Git commit sha. | ||
COMMIT := $(shell git rev-parse --short HEAD) | ||
# Build Date | ||
BUILD_DATE=$(shelldate +%FT%T%z) | ||
# Version File | ||
VERSION_FILE=main | ||
|
||
lint: ## use golint to do lint | ||
golint ./... | ||
|
||
test: ## test | ||
go test -cover ./... | ||
|
||
build: ## build local binary for targets on | ||
@for target in $(TARGETS); do \ | ||
go build -o $(OUTPUT_DIR)/$${target} \ | ||
-ldflags "-s -w -X $(VERSION_FILE).Version=$(VersionMain)-$(COMMIT)" \ | ||
$(CMD_DIR)/.; \ | ||
done | ||
|
||
|
||
build-all: # build cross for targets | ||
@for plat in $(PLAT_FROM); do \ | ||
for target in $(TARGETS); do \ | ||
CGO_ENABLED=0 GOOS=$${plat} GOARCH=amd64 go build -o $(OUTPUT_DIR)/$${target}_$${plat}_amd64 \ | ||
-ldflags "-s -w -X $(VERSION_FILE).Version=$(VersionMain)-$(COMMIT)" \ | ||
$(CMD_DIR)/.; \ | ||
done \ | ||
done | ||
|
||
|
||
.PHONY: clean | ||
clean: # clean bin files | ||
-rm -vrf ${OUTPUT_DIR} | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters