From 1add2f7a62ce8efdc7f28a10ac723aebc78c2750 Mon Sep 17 00:00:00 2001 From: ehlxr Date: Tue, 27 Mar 2018 16:18:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E7=82=B9=E6=9B=B4=E6=96=B0=EF=BC=9A20?= =?UTF-8?q?18-03-27=2016:18:23?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Makefile | 39 +++++++++++++++++++++++++++++++++++++++ README.md | 3 ++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53c37a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..47f4396 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +# https://golang.org/doc/install/source#environment +GOOS := $(shell go env | awk -F= '$$1=="GOOS" {print $$2}' | awk -F '"' '{print $$2}') # 此处 awk 需使用两个 $ +GOARCH := $(shell go env | awk -F= '$$1=="GOARCH" {print $$2}' | awk -F '"' '{print $$2}') +OSS = darwin dragonfly freebsd linux netbsd openbsd plan9 solaris windows +PKG = +# ifeq ($(strip $(GOOS)), windows) +# GOARCH := $(strip $(GOARCH)).exe +# endif + +.PHONY: build +build: + @ go build -ldflags "-s -w" -o dist/jwt_$(strip $(GOOS))_$(strip $(if \ + $(findstring windows,$(GOOS)),\ + $(strip $(GOARCH)).exe,\ + $(strip $(GOARCH))\ + )) + +.PHONY: amd64 +amd64: + @ $(foreach OS,\ + $(OSS),\ + $(shell CGO_ENABLED=0 GOOS=$(OS) GOARCH=amd64 go build -ldflags "-s -w" -o dist/jwt_$(OS)_amd64$(if $(findstring windows,$(OS)),.exe))) + @ echo done + +.PHONY: 386 +386: + @ $(foreach OS,\ + $(OSS),\ + $(shell CGO_ENABLED=0 GOOS=$(OS) GOARCH=386 go build -ldflags "-s -w" -o dist/jwt_$(OS)_386$(if $(findstring windows,$(OS)),.exe))) + @ echo done + +.PHONY: clean +clean: + @ rm -rf dist/jwt* jbls + +# 压缩。需要安装 https://github.com/upx/upx +.PHONY: upx +upx: + @ upx $(if $(PKG),$(PKG),dist/jwt*) \ No newline at end of file diff --git a/README.md b/README.md index 5b5f0a5..e372406 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# jwt \ No newline at end of file +# JWT +> This is a simple tool to sign, verify and show JSON Web Tokens ([JWT](http://jwt.io/)) from the command line, base [jwt-go](https://github.com/dgrijalva/jwt-go).