Add go build option '-i' only for native builds #1937
Merged
+14
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
go build
option-i
that installs the packages that are dependencies of the target (to speed up future builds).This was removed in #1179 because it caused problems when cross-compiling, when the install was being done on the incorrect (not native) path (this comment gives a clear example).
The
GOHOSTOS
environment variable was added to the Makefile to detect when the build was being done against the native platform, and only then add the-i
option.Also the
GO_BUILD_FLAGS
variable was added to encapsulate this option (and possible future ones), instead of just hard coding it into thego build
command. According to thego build
documentation the-i
option is not exactly a build flag (it's listed separately) but for the purposes of this PR it can be considered as such.As noted in this comment this option won't be needed in Go 1.10.
Some simple commands to test the modification:
Closes #1905.