forked from liuguangw/billing_go
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
49 additions
and
36 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
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 |
---|---|---|
@@ -1,38 +1,43 @@ | ||
appVersion ?= 0.0.0 | ||
appVersion ?= 1.3.3 | ||
appBuildTime ?= $(shell TZ=Asia/Shanghai date "+%F %T GMT%:z") | ||
appGitCommitHash ?= $(shell git rev-parse HEAD) | ||
projectName ?= go_app | ||
projectName ?= billing | ||
appModuleName = github.com/liuguangw/billing_go/services | ||
buildLdFlags =-X $(appModuleName).appVersion=$(appVersion) | ||
buildLdFlags += -X '$(appModuleName).appBuildTime=$(appBuildTime)' | ||
buildLdFlags += -X $(appModuleName).gitCommitHash=$(appGitCommitHash) | ||
CGO_ENABLED ?= 0 | ||
GO_BUILD=go build -v -ldflags "-w -s $(buildLdFlags)" | ||
GO_BUILD=go build -ldflags "-w -s $(buildLdFlags)" | ||
EXTRA_FILES = config.yaml LICENSE README.md | ||
releasePath ?= ./release | ||
releasePath = ./release | ||
|
||
define build_app | ||
mkdir -p $(releasePath) | ||
echo "build $(projectName)\(linux/$(2)\)" | ||
define release_app | ||
@echo build for $(2) | ||
@mkdir -p $(releasePath) | ||
@echo "build $(projectName) (linux/$(2))" | ||
@GOOS=linux GOARCH=$(1) $(GO_BUILD) -o $(releasePath)/$(projectName) | ||
echo "build $(projectName)\(windows/$(2)\)" | ||
@echo "build $(projectName) (windows/$(2))" | ||
@GOOS=windows GOARCH=$(1) $(GO_BUILD) -o $(releasePath)/$(projectName).exe | ||
cp $(EXTRA_FILES) $(releasePath)/ | ||
mv $(releasePath) ./$(projectName)-$(2) | ||
tar -zcvf $(projectName)-$(2).tar.gz ./$(projectName)-$(2) | ||
rm -rf ./$(projectName)-$(2) | ||
@cp $(EXTRA_FILES) $(releasePath)/ | ||
@mv $(releasePath) ./$(projectName)-release-$(2) | ||
@tar -zcf $(projectName)-release-$(2).tar.gz $(projectName)-release-$(2) | ||
@rm -rf ./$(projectName)-release-$(2) | ||
@echo output path: $(projectName)-release-$(2).tar.gz | ||
endef | ||
|
||
build: | ||
@$(GO_BUILD) -o $(projectName) | ||
@echo build $(projectName) ok | ||
|
||
all: | ||
#build for x32 | ||
$(call build_app,386,x32) | ||
#build for x64 | ||
$(call build_app,amd64,x64) | ||
x32: | ||
$(call release_app,386,x32) | ||
|
||
x64: | ||
$(call release_app,amd64,x64) | ||
|
||
all:x32 x64 | ||
|
||
clean: | ||
rm -rf ./*.tar.gz | ||
@rm -rf ./billing* | ||
|
||
.PHONY: build all clean | ||
.PHONY: build x32 x64 all clean |
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