Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit e4e2388

Browse files
committed
Makefile: Use 'go install ...' for the install target
GOBIN (documented in [1]) defaults to DIR/bin, but it's a configurable variable in its own right. The old logic was just looking at GOPATH, though, and not respecting GOBIN. This commit updates our install target to lean on Go's build caching (instead of using Make's dependency trees) to ensure a fresh-enough build lands in the appropriate directory. This approach relies on Go 1.10+ to avoid [2], but we've required Go 1.10+ since b859ebf (Documentation/development: Bump minimum Go version to 1.10, 2018-04-03, #955). For the build documentation, I've switched to 'go env GOPATH' to get the (platform-specific [1]) default value when the environment variable is not set. And I've used cut [3] (instead of the awk [4] the Makefile used to use) to pull out the first component of GOPATH. Both are in POSIX, but cut is a simpler tool for this particular problem. [1]: https://golang.org/cmd/go/#hdr-GOPATH_environment_variable [2]: golang/go#18981 [3]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html [4]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html
1 parent 5f286e9 commit e4e2388

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Documentation/development.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
## Requirements
44

55
* Go 1.10+
6-
* Configured [GOPATH](http://golang.org/doc/code.html#GOPATH)
76

87
## Building
98

10-
First, clone the repo into the proper location in your $GOPATH:
9+
First, clone the repo into the proper location in your [`GOPATH`][GOPATH]:
1110

1211
```
1312
go get -u github.com/kubernetes-incubator/bootkube
14-
cd $GOPATH/src/github.com/kubernetes-incubator/bootkube
13+
cd $(go env GOPATH | cut -d: -f1)/src/github.com/kubernetes-incubator/bootkube
1514
```
1615

1716
Then build:
@@ -71,3 +70,5 @@ Commenting on the PR:
7170
* `coreosbot run e2e checkpointer`: can be used to specifically test new checkpointer code.
7271
* This will build a new checkpointer image from the PR, and includes that image as part of the checkpointer daemonset.
7372
* `coreosbot run conformance`: run upstream Kubernetes conformance tests
73+
74+
[GOPATH]: https://golang.org/cmd/go/#hdr-GOPATH_environment_variable

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export PATH:=$(PATH):$(PWD)
55
SHELL:=$(shell which bash)
66
LOCAL_OS:=$(shell uname | tr A-Z a-z)
77
GOFILES:=$(shell find . -name '*.go' | grep -v -E '(./vendor)')
8-
GOPATH_BIN:=$(shell echo ${GOPATH} | awk 'BEGIN { FS = ":" }; { print $1 }')/bin
8+
GOPATH ?= $(shell go env GOPATH)
9+
PRIMARY_GOPATH ?= $(shell echo ${GOPATH} | cut -d : -f 1)
10+
GOBIN ?= $(PRIMARY_GOPATH)/bin
911
LDFLAGS=-X github.com/kubernetes-incubator/bootkube/pkg/version.Version=$(shell $(CURDIR)/build/git-version.sh)
1012
TERRAFORM:=$(shell command -v terraform 2> /dev/null)
1113

@@ -41,7 +43,7 @@ endif
4143
@go test -v $(shell go list ./... | grep -v '/vendor/\|/e2e')
4244

4345
install: _output/bin/$(LOCAL_OS)/bootkube
44-
cp $< $(GOPATH_BIN)
46+
cp $< $(GOBIN)
4547

4648
_output/bin/%: GOOS=$(word 1, $(subst /, ,$*))
4749
_output/bin/%: GOARCH=$(word 2, $(subst /, ,$*))

0 commit comments

Comments
 (0)