forked from ampproject/amppackager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
36 lines (29 loc) · 970 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILDDATE ?= $(shell date --iso-8601=seconds)
REVISION ?= $(shell git rev-parse HEAD)
VERSION ?= $(shell git log --date=short --pretty=format:'%h@%cd' -n 1 .)
GOOPTS ?=
ifneq (,$(wildcard vendor))
GOOPTS := $(GOOPTS) -mod=vendor
endif
VERSION_LDFLAGS := \
-X github.com/prometheus/common/version.Branch=$(BRANCH) \
-X github.com/prometheus/common/version.BuildDate=$(BUILDDATE) \
-X github.com/prometheus/common/version.Revision=$(REVISION) \
-X github.com/prometheus/common/version.Version=$(VERSION)
all: test build
.PHONY: test
test:
go test $(GOOPTS) ./...
build: amppkg
.PHONY: amppkg
amppkg:
go build $(GOOPTS) -ldflags "$(VERSION_LDFLAGS)" -o amppkg ./cmd/amppkg/...
.PHONY: update-go-deps
update-go-deps:
@for m in $$(go list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
go get $$m; \
done
ifneq (,$(wildcard vendor))
go mod vendor
endif