Skip to content

Commit

Permalink
Update Makefile with new build requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Aug 18, 2015
1 parent 2304d03 commit 6fcbb7b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
28 changes: 18 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
UNAME := $(shell sh -c 'uname')
VERSION := $(shell sh -c 'git describe --always --tags')

ifeq ($(UNAME), Darwin)
export ADVERTISED_HOST := $(shell sh -c 'boot2docker ip')
endif
ifeq ($(UNAME), Linux)
export ADVERTISED_HOST := localhost
endif
build: prepare
$(GOPATH)/bin/godep go build -o telegraf -ldflags \
"-X main.Version $(VERSION)" \
./cmd/telegraf/telegraf.go

prepare:
godep go install ./...
go get github.com/tools/godep
$(GOPATH)/bin/godep go install ./...

docker-compose:
docker-compose up -d

test: prepare docker-compose
godep go test -v ./...
test:
ifeq ($(UNAME), Darwin)
ADVERTISED_HOST=$(shell sh -c 'boot2docker ip') $(MAKE) test-full
endif
ifeq ($(UNAME), Linux)
ADVERTISED_HOST=localhost $(MAKE) test-full
endif

test-full: prepare docker-compose
$(GOPATH)/bin/godep go test -v ./...

test-short: prepare
godep go test -v -short ./...
$(GOPATH)/bin/godep go test -v -short ./...

test-cleanup:
docker-compose kill
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ brew update
brew install telegraf
```

### From Source:

Telegraf manages dependencies via `godep`, which gets installed via the Makefile.
Assuming you have your GOPATH setup, `make build` should be enough to gather dependencies
and build telegraf.

### How to use it:

* Run `telegraf -sample-config > telegraf.toml` to create an initial configuration
Expand Down
10 changes: 6 additions & 4 deletions circle-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function exit_if_fail {
# build takes three arguments: GOOS & GOARCH & VERSION
function build {
echo -n "=> $1-$2: "
GOOS=$1 GOARCH=$2 godep go build -o telegraf-$1-$2 -ldflags "-X main.Version $3" ./cmd/telegraf/telegraf.go
GOOS=$1 GOARCH=$2 godep go build -o telegraf-$1-$2 \
-ldflags "-X main.Version $3" \
./cmd/telegraf/telegraf.go
du -h telegraf-$1-$2
}

Expand Down Expand Up @@ -59,9 +61,9 @@ exit_if_fail godep go vet ./...
exit_if_fail godep go test -v -short ./...

# Build binaries
build "linux" "amd64" `git rev-parse --short HEAD`
build "linux" "386" `git rev-parse --short HEAD`
build "linux" "arm" `git rev-parse --short HEAD`
build "linux" "amd64" `git describe --always --tags`
build "linux" "386" `git describe --always --tags`
build "linux" "arm" `git describe --always --tags`
# Artifact binaries
mv telegraf* $CIRCLE_ARTIFACTS

Expand Down
6 changes: 4 additions & 2 deletions cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ var fPidfile = flag.String("pidfile", "", "file to write our pid to")
var fPLuginsFilter = flag.String("filter", "", "filter the plugins to enable, separator is :")

// Telegraf version
var Version = "0.1.6-dev"
// -ldflags "-X main.Version `git describe --always --tags`"
var Version string

func main() {
flag.Parse()

if *fVersion {
fmt.Printf("Telegraf - Version %s\n", Version)
v := fmt.Sprintf("Telegraf - Version %s", Version)
fmt.Println(v)
return
}

Expand Down

0 comments on commit 6fcbb7b

Please sign in to comment.