Commit graph

9 commits

Author SHA1 Message Date
Mirza Krak 60d455f20b package/pkg-golang: do not set static linking for host target
The current logic will set the "-static" flag when building go
host packages if BR2_STATIC_LIBS is set, this will not work as
there is no support to link host packages statically.

Fix this by applying this logic only for target builds.

Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-06-10 20:44:08 +02:00
Mirza Krak d65b6b337b package/pkg-golang: add cflags/ldflags to GO_HOST_ENV
If a go host package is built using cgo, it needs access
to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it
might depend on.

Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
Acked-by: Adam Duskett <aduskett@gmail.com>
Tested-by: Adam Duskett <aduskett@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-06-08 21:42:32 +02:00
Mirza Krak aba08cd218 package/pkg-golang: add support for building host packages
With this you can add:

    $(eval $(host-golang-package))

to a package .mk file to build for host.

Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
Acked-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Tested-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Tested-by: Adam Duskett <aduskett@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-03-17 17:21:10 +01:00
Yann E. MORIN 5af65f6557 infra/pkg-golang: enforce number of parallel jobs
By default, the go compiler will spawn as many jobs as there are CPUs
available, thus possibily over-shooting the limits set by the user.

Make it abide by the user's wish, and specify the number of jobs allowed
to run.

We can do so without fear of a package failing to build in parallel,
because they were already all building in parallel, as that is the
default for the go compiler.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-11-29 21:21:36 +01:00
Mirza Krak 4eccbe3ef9 package/pkg-golang: post-pone evaluation of variables
As explained in pkg-generic.mk, all variable references inside the
inner-xxx-package should use $$(...). Otherwise, they are evaluated
too early, and will not contain the expected value. In the content of
the pkg-golang infrastructure, the <pkg>_SRC_DOMAIN, <pkg>_SRC_VENDOR
and <pkg>_SRC_SOFTWARE variables were not properly escaping their
reference to the $$($(2)_SITE) variable.

This was not visible until now, as only target Go packages were
supported, where $(2)_SITE was always defined prior to this macro
being expanded. With the upcoming support of host Go packages, we need
to fix this, as $(2)_SITE may be defined later, inherited from
$(3)_SITE.

Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
[Thomas: rework commit log.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-08-15 14:32:46 +02:00
Thomas Petazzoni dbe32d364a package/pkg-golang: add PATH in GO_TARGET_ENV
Some Go packages use pkg-config to detect native libraries, so we must
have $(BR_PATH) in the PATH so that our pkg-config in HOST_DIR gets
used.

Fixes:

  http://autobuild.buildroot.net/results/f85414244c25aba07a05109b5cd7658ae44a64ea/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2018-04-02 17:23:36 +02:00
Thomas Petazzoni 888404d7fb package/pkg-golang: drop the fixed <pkg>_BINDIR variable
Now that <pkg>_BINDIR is always "bin", having it as a package variable
doesn't make much sense, so get rid of this variable completely, and
use "bin".

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>
2018-04-01 16:39:28 +02:00
Thomas Petazzoni c4c85c12eb 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>
2018-04-01 16:36:28 +02:00
Angelo Compagnucci 048b06ed3e package/pkg-golang: new package infrastructure
This patch adds a new infrastructure for golang based packages.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
[Arnout:
 - Rewrap comments to 80 columns.
 - Create a global definition of GO_TARGET_ENV.
 - <PKG>_GO_ENV is appended to the default env instead of replacing it.
 - Add a note to inner-golang-package that only target is supported.
]
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2018-03-31 19:57:31 +02:00