add version

master
Oliver Tonnhofer 2013-09-04 14:19:36 +02:00
parent ff42de9c2b
commit f49bef69fd
3 changed files with 22 additions and 1 deletions

View File

@ -2,17 +2,24 @@
PROTOFILES=$(shell find . -name \*.proto)
PBGOFILES=$(patsubst %.proto,%.pb.go,$(PROTOFILES))
GOFILES=$(shell find . -name \*.go)
GOFILES=$(shell find . \( -name \*.go ! -name version.go \) )
# for protoc-gen-go
export PATH := $(GOPATH)/bin:$(PATH)
GOLDFLAGS=-ldflags '-r ${ORIGIN}:${ORIGIN}/../lib'
BUILD_DATE=$(shell date +%Y%m%d)
BUILD_REV=$(shell git rev-parse --short HEAD)
BUILD_VERSION=dev-$(BUILD_DATE)-$(BUILD_REV)
all: build test
imposm3: $(GOFILES) $(PROTOFILES)
@sed -i '' 's/buildVersion = ".*"/buildVersion = "$(BUILD_VERSION)"/' version.go
go build $(GOLDFLAGS)
@sed -i '' 's/buildVersion = ".*"/buildVersion = ""/' version.go
build: imposm3

View File

@ -34,6 +34,7 @@ func printCmds() {
fmt.Println("\timport")
fmt.Println("\tdiff")
fmt.Println("\tquery-cache")
fmt.Println("\tversion")
}
func main() {
@ -75,6 +76,9 @@ func main() {
}
case "query-cache":
query.Query(os.Args[2:])
case "version":
fmt.Println(imposmVersion)
os.Exit(0)
default:
printCmds()
log.Fatalf("invalid command: '%s'", os.Args[1])

10
version.go Normal file
View File

@ -0,0 +1,10 @@
package main
var imposmVersion string
func init() {
// buidVersion gets replaced during build
var buildVersion = ""
imposmVersion = "0.1"
imposmVersion += buildVersion
}