summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>2018-04-01 13:51:35 +0200
committerPeter Korsgaard <peter@korsgaard.com>2018-04-01 16:36:28 +0200
commitc4c85c12eb7f39d2faf54f080de973f7d69224f0 (patch)
tree4baefc612132296a30225f5915ace55703f04801 /docs
parentb8c16d9c4f9d19236f6919edee60e6acd2871e38 (diff)
downloadbuildroot-c4c85c12eb7f39d2faf54f080de973f7d69224f0.tar.gz
buildroot-c4c85c12eb7f39d2faf54f080de973f7d69224f0.zip
package/pkg-golang: use 'build' instead of 'install'
So far, we were using the 'go install' mechanism to build a package and have its binary installed in $$($(2)_WORKSPACE)/bin/linux_$$(GO_GOARCH). This worked fine when building on x86-64 for ARM, but failed when building on x86-64 for x86-64 because the binaries were installed in $$($(2)_WORKSPACE)/bin/. Instead of doing some complicated logic to guess whether Go is going to put our binaries in $$($(2)_WORKSPACE)/bin/ or in $$($(2)_WORKSPACE)/bin/linux_$$(GO_GOARCH), we revert back to using "go build", as it was done before the introduction of the golang package infrastructure. "go build" lets us pass explicitly the destination path of the binary to be generated. There's just one complexity with how to decide on the name of the binary that should be produced, and we have two cases: - <pkg>_BUILD_TARGETS is the default, i.e ".". In this case we assume a single binary is produced by "go build", and we name if after the lower case package name. We allow this to be overridden thanks to <pkg>_BIN_NAME. - <pkg>_BUILD_TARGETS is non-default, and typically contains something like "foo bar" or "cmd/foo cmd/bar". In this case, we assume the binaries to be produced are "foo" and "bar", i.e we take the non-directory part of the build target to name the binaries. Because we're using this -o option, we no longer need to explicitly create the binary directory, it is done by "go build". Fixes: http://autobuild.buildroot.net/results/1f9cd7c48e8c8f41326632a9c0de83915d72c45b/ [Peter: use $(or instead of $(if as suggested by Arnout] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/manual/adding-packages-golang.txt13
1 files changed, 12 insertions, 1 deletions
diff --git a/docs/manual/adding-packages-golang.txt b/docs/manual/adding-packages-golang.txt
index b6d1f5e6b4..efcf696867 100644
--- a/docs/manual/adding-packages-golang.txt
+++ b/docs/manual/adding-packages-golang.txt
@@ -86,7 +86,18 @@ therefore only use a few of them, or none.
* +FOO_BUILD_TARGETS+ can be used to pass the list of targets that
should be built. If +FOO_BUILD_TARGETS+ is not specified, it
- defaults to +.+.
+ defaults to +.+. We then have two cases:
+
+** +FOO_BUILD_TARGETS+ is +.+. In this case, we assume only one binary
+ will be produced, and that by default we name it after the package
+ name. If that is not appropriate, the name of the produced binary
+ can be overridden using +FOO_BIN_NAME+.
+
+** +FOO_BUILD_TARGETS+ is not +.+. In this case, we iterate over the
+ values to build each target, and for each produced a binary that is
+ the non-directory component of the target. For example if
+ +FOO_BUILD_TARGETS = cmd/docker cmd/dockerd+ the binaries produced
+ are +docker+ and +dockerd+.
* +FOO_INSTALL_BINS+ can be used to pass the list of binaries that
should be installed in +/usr/bin+ on the target. If
OpenPOWER on IntegriCloud