diff --git a/.gitignore b/.gitignore index daf913b..ecc2f14 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ _cgo_export.* _testmain.go +release/* +nagome *.exe *.test *.prof diff --git a/.travis.yml b/.travis.yml index c3b5bfa..b4d0734 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ notifications: on_failure: always email: false -before_deploy: gox -osarch "linux/amd64 darwin/amd64 windows/amd64" -output "release/{{.Dir}}_{{.OS}}_{{.Arch}}" +before_deploy: make cross deploy: provider: releases api_key: diff --git a/cli.go b/cli.go index bdce072..49af3bf 100644 --- a/cli.go +++ b/cli.go @@ -56,7 +56,7 @@ func RunCli() { return } if *printVersion { - fmt.Println(App.Name, " ", App.Version) + fmt.Println(AppName, " ", Version) return } if *mkplug != "" { diff --git a/main.go b/main.go index 458199f..479337b 100644 --- a/main.go +++ b/main.go @@ -2,15 +2,15 @@ package main // Application holds app settings and valuables type Application struct { - Name string - Version string SavePath string SettingsSlots SettingsSlots } +// Application global information var ( - // App is global Application settings and valuables for this app - App = Application{Name: "Nagome", Version: "0.0.1"} + AppName = "Nagome" + Version string + App Application ) func main() { diff --git a/makefile b/makefile new file mode 100644 index 0000000..dccacd3 --- /dev/null +++ b/makefile @@ -0,0 +1,25 @@ +SOURCEDIR=. +SOURCES := $(shell find $(SOURCEDIR) -name '*.go') + +BINARY=nagome + +LDFLAGS=-ldflags "-X main.Version=`git describe`" + +.DEFAULT_GOAL: $(BINARY) + +$(BINARY): $(SOURCES) + go build ${LDFLAGS} -o ${BINARY} + +.PHONY: install +install: + go install ${LDFLAGS} ./... + + +.PHONY: cross +cross: + gox -osarch "linux/amd64 darwin/amd64 windows/amd64" -output "release/{{.Dir}}_{{.OS}}_{{.Arch}}" ${LDFLAGS} + +.PHONY: clean +clean: + if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi + diff --git a/user_path.go b/user_path.go index e420946..fc52633 100644 --- a/user_path.go +++ b/user_path.go @@ -11,5 +11,5 @@ func findUserConfigPath() string { home := os.Getenv("HOME") dir := filepath.Join(home, ".config") - return filepath.Join(dir, App.Name) + return filepath.Join(dir, AppName) } diff --git a/user_path_windows.go b/user_path_windows.go index 8935e7d..300d101 100644 --- a/user_path_windows.go +++ b/user_path_windows.go @@ -12,5 +12,5 @@ func findUserConfigPath() string { dir = filepath.Join(home, "Application Data") } - return filepath.Join(dir, App.Name) + return filepath.Join(dir, AppName) }