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

Makefile: Respect GOBIN #949

Merged
merged 1 commit into from
Apr 3, 2018
Merged

Conversation

wking
Copy link
Contributor

@wking wking commented Mar 29, 2018

GOBIN (documented here) defaults to DIR/bin, but it's a configurable variable in its own right. This command updates our calculations, using ?= (documented here) to avoid expensive shell operations when we don't actually need the result (because a different target was called or because the user provided their own value).

I've also used go env GOPATH to get the (platform-specific) default value when the environment variable is not set.

And I've used cut instead of awk to pull out the first component of GOPATH. Both are in POSIX, but cut is a simpler tool for this particular problem.

This will have trivial context conflicts with the in-flight #948. I'm happy to rebase the other if/when one of them lands.

@coreosbot
Copy link

Can one of the admins verify this patch?

3 similar comments
@coreosbot
Copy link

Can one of the admins verify this patch?

@coreosbot
Copy link

Can one of the admins verify this patch?

@coreosbot
Copy link

Can one of the admins verify this patch?

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 29, 2018
@ericchiang
Copy link
Contributor

Should we just call go install instead? The build caching should make that much faster so we probably don't have to do a cp

@wking
Copy link
Contributor Author

wking commented Apr 3, 2018

Should we just call go install instead?

That sounds good to me, but I ran into golang/go#18981 attempting it. That issue was fixed by golang/go@8f70e1f8a91 in Go 1.10. Are we comfortable bumping our minimum version? Would you prefer on of the other workarounds mentioned in the upstream image? Or are you ok with this PR as it stands until we are comfortable making Go 1.10 the minimum version?

@ericchiang
Copy link
Contributor

ericchiang commented Apr 3, 2018 via email

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, kubernetes-retired#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
@wking
Copy link
Contributor Author

wking commented Apr 3, 2018

Rebased around #955 and converted to go install … with ba3f8efe4e2388.

@rphillips
Copy link
Contributor

ok to test

@rphillips rphillips merged commit dbf0b6a into kubernetes-retired:master Apr 3, 2018
@wking wking deleted the respect-gobin branch April 3, 2018 19:03
@wking
Copy link
Contributor Author

wking commented Apr 3, 2018

Hmm, I seem to have missed the go install … commit (maybe in a rebase?) :/. I'll file a fixup PR.

wking added a commit to wking/bootkube that referenced this pull request Apr 3, 2018
This was my intention with dbf0b6a (Makefile: Use 'go install ...'
for the install target, 2018-04-03, kubernetes-retired#949), but I seem to have missed
the actual code :/.  Instead, that command landed an earlier
implementation which we intended to drop based on kubernetes-retired#949 review [1].

This commit has the intended implementation.  For detailed motivation,
see the description in dbf0b6a.

[1]: kubernetes-retired#949 (comment)
wking added a commit to wking/bootkube that referenced this pull request Apr 3, 2018
This was my intention with dbf0b6a (Makefile: Use 'go install ...'
for the install target, 2018-04-03, kubernetes-retired#949), but I seem to have missed
the actual code :/.  Instead, that commit landed an earlier
implementation which we intended to drop based on kubernetes-retired#949 review [1].

This commit has the intended implementation.  For detailed motivation,
see the description in dbf0b6a.

[1]: kubernetes-retired#949 (comment)
rphillips pushed a commit that referenced this pull request Apr 3, 2018
This was my intention with dbf0b6a (Makefile: Use 'go install ...'
for the install target, 2018-04-03, #949), but I seem to have missed
the actual code :/.  Instead, that commit landed an earlier
implementation which we intended to drop based on #949 review [1].

This commit has the intended implementation.  For detailed motivation,
see the description in dbf0b6a.

[1]: #949 (comment)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants