Skip to content

Commit

Permalink
Makefile for release
Browse files Browse the repository at this point in the history
  • Loading branch information
glaslos committed Jun 8, 2017
1 parent f7560b4 commit 3dc10e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ _testmain.go
*.exe
*.test
*.prof

dist/
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions app/tlsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file>]\n\n", os.Args[0])
flag.PrintDefaults()
Expand Down

0 comments on commit 3dc10e0

Please sign in to comment.