add version
parent
ff42de9c2b
commit
f49bef69fd
9
Makefile
9
Makefile
|
@ -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
|
||||
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
var imposmVersion string
|
||||
|
||||
func init() {
|
||||
// buidVersion gets replaced during build
|
||||
var buildVersion = ""
|
||||
imposmVersion = "0.1"
|
||||
imposmVersion += buildVersion
|
||||
}
|
Loading…
Reference in New Issue