aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/Makefile
blob: c827cc19f5641056885a315920db7dad5550dead (plain) (blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

# When building a new release the build system should set the VERSION
# environment variable to version being built or released
VERSION ?= $(shell echo "0.0.0-`git rev-parse --short HEAD`")

BIN ?= $(CURDIR)/bin
SHARE ?= $(CURDIR)/share
GO_FLAGS := -ldflags "-X github.com/vespa-engine/vespa/client/go/build.Version=$(VERSION)"

all: test checkfmt install

#
# Dist targets
#

# Bump the version of the vespa-cli formula and create a pull request to Homebrew repository
dist-homebrew:
	brew bump-formula-pr --tag vespa-$(VERSION)-1 --version $(VERSION) vespa-cli

#
# Cross-platform build targets
#

build-mac: GOOS=darwin
build-mac: xbuild

build-linux: GOOS=linux
build-linux: xbuild

build-win: GOOS=windows
build-win: xbuild

xbuild:
	mkdir -p bin/$(GOOS)_amd64
	env GOOS=$(GOOS) go build -o bin/$(GOOS)_amd64 $(GO_FLAGS) ./...

#
# Development targets
#

install:
	env GOBIN=$(BIN) go install $(GO_FLAGS) ./...

manpages: install
	mkdir -p $(SHARE)/man/man1
	$(BIN)/vespa man $(SHARE)/man/man1

clean:
	rm -rf $(BIN) $(SHARE)

test:
	go test ./...

checkfmt:
	@bash -c "diff --line-format='%L' <(echo -n) <(gofmt -l .)" || { echo "one or more files need to be formatted: try make fmt to fix this automatically"; exit 1; }

fmt:
	gofmt -w .