Skip to content

Commit

Permalink
made more binary friendly
Browse files Browse the repository at this point in the history
added version to main.go and a version file that can be bumped
added a makefile for consistency
removed the binaries directory
  • Loading branch information
Nika Jones committed Jun 6, 2017
1 parent 3004a05 commit 3b9e727
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
Binary file removed bin/lin/xcp
Binary file not shown.
Binary file removed bin/osx/xcp
Binary file not shown.
Binary file removed bin/win/xcp.exe
Binary file not shown.
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const (
)

var (
binaryVersion, binaryBuild string

flgVersion = flag.Bool("version", false, "The binary version information")
flgSvrPort = flag.String("p", "2975", "The port that is used for the copy-paste socket")
flgVerbose = flag.Bool("v", false, "Verbose, print out all of the logging.")
)
Expand Down Expand Up @@ -93,6 +96,15 @@ func printDot(stop, cont chan struct{}) {
}
}

func ver(show bool) {
if !show {
return
}

fmt.Printf("version: %s build: %s - MIT (c) 2017 by Nika Jones - with <3\n", binaryVersion, binaryBuild)
os.Exit(0)
}

// multicastServer forwards data from the client to all other connected clients
func multicastServer(svrName, svrPort string) {
log.Println("Starting the multicast server...")
Expand Down Expand Up @@ -329,6 +341,8 @@ func socketHandler(ws *websocket.Conn) {
func main() {
flag.Parse()

ver(*flgVersion)

if !*flgVerbose {
log.SetOutput(ioutil.Discard)
}
Expand Down
22 changes: 22 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SHELL := /bin/bash
BUILD_DATE = `date -u +"%a,|%d|%b|%Y|%T|%Z" | tr '|' ' '`
BUILD_VERSION = `cat VERSION`

default: mac

mac:
GOARCH=amd64 GOOS=darwin go build -o bin/osx/xcp -ldflags "-X \"main.binaryBuild=$(BUILD_DATE)\" -X main.binaryVersion=$(BUILD_VERSION)"

win:
GOARCH=amd64 GOOS=windows go build -o bin/win/xcp.exe -ldflags "-X \"main.binaryBuild=$(BUILD_DATE)\" -X \"main.binaryVersion=$(BUILD_VERSION)\""

lin:
GOARCH=amd64 GOOS=linux go build -o bin/lin/xcp -ldflags "-X \"main.binaryBuild=$(BUILD_DATE)\" -X \"main.binaryVersion=$(BUILD_VERSION)\""

release:
tar -czvf xcp-${BUILD_VERSION}-lin.tar.gz -C bin/lin/ xcp
tar -czvf xcp-${BUILD_VERSION}-macos.tar.gz -C bin/osx xcp
tar -czvf xcp-${BUILD_VERSION}-win.tar.gz -C bin/win xcp.exe
mkdir -p releases/${BUILD_VERSION} && mv *.tar.gz releases/${BUILD_VERSION}/.

all: mac win lin

0 comments on commit 3b9e727

Please sign in to comment.