mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-05 16:15:56 +00:00
Add Makefile and versioning/build time in pilosa/pilosactl
This commit is contained in:
parent
5e30496c50
commit
2d09731dfd
3 changed files with 65 additions and 9 deletions
47
Makefile
47
Makefile
|
|
@ -1,10 +1,45 @@
|
|||
.PHONY: vendor
|
||||
.PHONY: glide vendor-update docker pilosa pilosactl crossbuild install
|
||||
|
||||
default:
|
||||
GLIDE := $(shell command -v glide 2>/dev/null)
|
||||
VERSION := $(shell git describe --tags)
|
||||
IDENTIFIER := $(VERSION)-$(GOOS)-$(GOARCH)
|
||||
CLONE_URL=github.com/pilosa/pilosa
|
||||
BUILD_TIME=`date -u +%FT%T%z`
|
||||
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
|
||||
|
||||
vendor:
|
||||
godep save ./...
|
||||
cp -r $(GOPATH)/src/github.com/gogo/protobuf/proto/testdata vendor/github.com/gogo/protobuf/proto/testdata
|
||||
default: test pilosa pilosactl
|
||||
|
||||
docker:
|
||||
$(GLIDE):
|
||||
curl https://glide.sh/get | sh
|
||||
touch $(GLIDE)
|
||||
|
||||
glide: $(GLIDE)
|
||||
|
||||
vendor: $(GLIDE) glide.yaml
|
||||
glide install
|
||||
|
||||
glide.lock: $(GLIDE) glide.yaml
|
||||
glide update
|
||||
|
||||
vendor-update: glide.lock
|
||||
|
||||
test: vendor
|
||||
go test $(shell cd $(GOPATH)/src/$(CLONE_URL); go list ./... | grep -v vendor)
|
||||
|
||||
pilosa: vendor
|
||||
go build $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa
|
||||
|
||||
pilosactl: vendor
|
||||
go build $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosactl
|
||||
|
||||
crossbuild: vendor
|
||||
mkdir -p build/pilosa-$(IDENTIFIER)
|
||||
make pilosa FLAGS="-o build/pilosa-$(IDENTIFIER)/pilosa"
|
||||
make pilosactl FLAGS="-o build/pilosa-$(IDENTIFIER)/pilosactl"
|
||||
|
||||
install: vendor
|
||||
go install $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa
|
||||
go install $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosactl
|
||||
|
||||
docker: vendor
|
||||
docker build -t pilosa:latest .
|
||||
|
|
|
|||
|
|
@ -17,13 +17,19 @@ import (
|
|||
"github.com/pilosa/pilosa"
|
||||
)
|
||||
|
||||
// Version holds the version information passed in at compile time.
|
||||
var Version string
|
||||
// Version and BuildTime hold the version/build time information passed in at compile time.
|
||||
var (
|
||||
Version string
|
||||
BuildTime string
|
||||
)
|
||||
|
||||
func init() {
|
||||
if Version == "" {
|
||||
Version = "v0.0.0"
|
||||
}
|
||||
if BuildTime == "" {
|
||||
BuildTime = "not recorded"
|
||||
}
|
||||
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
|
@ -36,7 +42,7 @@ const (
|
|||
func main() {
|
||||
m := NewMain()
|
||||
m.Server.Handler.Version = Version
|
||||
fmt.Fprintf(m.Stderr, "Pilosa %s\n", Version)
|
||||
fmt.Fprintf(m.Stderr, "Pilosa %s, build time %s\n", Version, BuildTime)
|
||||
|
||||
// Parse command line arguments.
|
||||
if err := m.ParseFlags(os.Args[1:]); err != nil {
|
||||
|
|
|
|||
|
|
@ -42,11 +42,26 @@ var (
|
|||
|
||||
// ErrPathRequired is returned when executing a command without a required path.
|
||||
ErrPathRequired = errors.New("path required")
|
||||
Version string
|
||||
BuildTime string
|
||||
)
|
||||
|
||||
func init() {
|
||||
if Version == "" {
|
||||
Version = "v0.0.0"
|
||||
}
|
||||
if BuildTime == "" {
|
||||
BuildTime = "not recorded"
|
||||
}
|
||||
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
func main() {
|
||||
m := NewMain()
|
||||
|
||||
fmt.Fprintf(m.Stderr, "Pilosactl %s, build time %s\n", Version, BuildTime)
|
||||
|
||||
// Parse command line arguments.
|
||||
if err := m.ParseFlags(os.Args[1:]); err == flag.ErrHelp {
|
||||
os.Exit(2)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue