@@ -4,31 +4,61 @@ IMG ?= controller:latest
44export GO111MODULE =on
55export GOPROXY=https ://proxy.golang.org
66
7+ SHELL := /bin/bash -o pipefail
8+ VERSION_PACKAGE = github.com/replicatedhq/troubleshoot/pkg/version
9+ VERSION ?=` git describe --tags --dirty `
10+ DATE =` date -u +" %Y-%m-%dT%H:%M:%SZ" `
11+
12+ GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
13+ ifneq "$(GIT_TREE ) " ""
14+ define GIT_UPDATE_INDEX_CMD
15+ git update-index --assume-unchanged
16+ endef
17+ define GIT_SHA
18+ `git rev-parse HEAD`
19+ endef
20+ else
21+ define GIT_UPDATE_INDEX_CMD
22+ echo "Not a git repo, skipping git update-index"
23+ endef
24+ define GIT_SHA
25+ ""
26+ endef
27+ endif
28+
29+ define LDFLAGS
30+ -ldflags "\
31+ -X ${VERSION_PACKAGE}.version=${VERSION} \
32+ -X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
33+ -X ${VERSION_PACKAGE}.buildTime=${DATE} \
34+ "
35+ endef
36+
737all : test manager
838
939.PHONY : ffi
1040ffi : fmt vet
11- go build -o bin/troubleshoot.so -buildmode=c-shared ffi/main.go
41+ go build ${LDFLAGS} -o bin/troubleshoot.so -buildmode=c-shared ffi/main.go
1242
1343# Run tests
1444test : generate fmt vet manifests
1545 go test ./pkg/... ./cmd/... -coverprofile cover.out
1646
1747.PHONY : manager
1848manager : generate fmt vet
19- go build -o bin/manager github.com/replicatedhq/troubleshoot/cmd/manager
49+ go build ${LDFLAGS} -o bin/manager github.com/replicatedhq/troubleshoot/cmd/manager
2050
2151.PHONY : support-bundle
2252support-bundle : generate fmt vet
23- go build -o bin/support-bundle github.com/replicatedhq/troubleshoot/cmd/troubleshoot
53+ go build ${LDFLAGS} -o bin/support-bundle github.com/replicatedhq/troubleshoot/cmd/troubleshoot
2454
2555.PHONY : preflight
2656preflight : generate fmt vet
27- go build -o bin/preflight github.com/replicatedhq/troubleshoot/cmd/preflight
57+ go build ${LDFLAGS} -o bin/preflight github.com/replicatedhq/troubleshoot/cmd/preflight
2858
2959.PHONY : analyze
3060analyze : generate fmt vet
31- go build -o bin/analyze github.com/replicatedhq/troubleshoot/cmd/analyze
61+ go build ${LDFLAGS} -o bin/analyze github.com/replicatedhq/troubleshoot/cmd/analyze
3262
3363.PHONY : run
3464run : generate fmt vet
0 commit comments