From 3dc10e03b912fdb3171cdb010da47934d9ca14f2 Mon Sep 17 00:00:00 2001 From: glaslos Date: Thu, 8 Jun 2017 17:16:55 +0200 Subject: [PATCH] Makefile for release --- .gitignore | 2 ++ Makefile | 13 +++++++++++++ app/tlsh.go | 12 ++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index daf913b..989ad55 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ _testmain.go *.exe *.test *.prof + +dist/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ba8db5f --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +VERSION := v0.1.0 +BUILDSTRING := $(shell git log --pretty=format:'%h' -n 1) +VERSIONSTRING := tlsh version $(VERSION)+$(BUILDSTRING) +BUILDDATE := $(shell date -u -Iseconds) + +clean: + rm -rf dist/ + +LDFLAGS := "-X \"main.VERSION=$(VERSIONSTRING)\" -X \"main.BUILDDATE=$(BUILDDATE)\"" + +.PHONY: build_release +build_release: clean + cd app; gox -arch="amd64" -os="windows darwin linux" -output="../dist/tlsh-{{.Arch}}-{{.OS}}" -ldflags=$(LDFLAGS) diff --git a/app/tlsh.go b/app/tlsh.go index f97c533..b05a85d 100644 --- a/app/tlsh.go +++ b/app/tlsh.go @@ -8,10 +8,22 @@ import ( "github.com/glaslos/tlsh" ) +var ( + // VERSION is set by the makefile + VERSION = "v0.0.0" + // BUILDDATE is set by the makefile + BUILDDATE = "" +) + func main() { var file = flag.String("f", "", "path to the file to be hashed") var raw = flag.Bool("r", false, "set to get only the hash") + var version = flag.Bool("version", false, "print version") flag.Parse() + if *version { + fmt.Printf("%s %s\n", VERSION, BUILDDATE) + return + } if *file == "" { fmt.Fprintf(os.Stderr, "Usage of %s [-f ]\n\n", os.Args[0]) flag.PrintDefaults()