From 89f793f1dc8fd364f4c6091ae7d0628004519b46 Mon Sep 17 00:00:00 2001 From: Lucas-Wye <229559117@qq.com> Date: Sat, 4 Jul 2020 19:39:39 +0800 Subject: [PATCH] promote: use Makefile and support cross-compile --- .gitignore | 4 ++++ Makefile | 35 +++++++++++++++++++++++++++++++++++ cmd/rwppa/main.go => main.go | 0 3 files changed, 39 insertions(+) create mode 100644 Makefile rename cmd/rwppa/main.go => main.go (100%) diff --git a/.gitignore b/.gitignore index 9429944..894b416 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,7 @@ # Other Runtime-Generated Files *.crt *.key + +# Binary +rwppa* + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..672f5bb --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +# Binary name +BINARY=rwppa +VERSION=1.0 + +# Builds +build: + GO111MODULE=on go build -o ${BINARY} -ldflags "-X main.Version=${VERSION}" + GO111MODULE=on go test -v + +# Installs to $GOPATH/bin +install: + GO111MODULE=on go install + +release_mac: + go clean + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 GO111MODULE=on go build -ldflags "-s -w -X main.Version=${VERSION}" + mv ./${BINARY} ${BINARY}-mac64 + +release_linux: + go clean + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-s -w -X main.Version=${VERSION}" + mv ./${BINARY} ${BINARY}-linux64 + +release_windows: + go clean + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 GO111MODULE=on go build -ldflags "-s -w -X main.Version=${VERSION}" + mv ./${BINARY}.exe ${BINARY}-win64.exe + +# Release for different platforms +release: release_mac release_linux release_windows + +clean: + go clean + rm ${BINARY}* +.PHONY: clean build release_mac release_linux release_windows diff --git a/cmd/rwppa/main.go b/main.go similarity index 100% rename from cmd/rwppa/main.go rename to main.go