diff options
author | Ahmed Hossam <Ahmed.Hossam@opensynergy.com> | 2021-10-26 20:56:42 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-28 14:16:26 +0100 |
commit | eaa7a61dab9a1d7bb039f16abdd9aacb44faa595 (patch) | |
tree | eff37a831ddaa418e0aa0af1d704a1a15206f139 | |
parent | 877b27b0cbf4f4544f75e0f0a78a82baeb46b159 (diff) | |
download | openembedded-core-contrib-eaa7a61dab9a1d7bb039f16abdd9aacb44faa595.tar.gz |
go.bbclass: Allow adding parameters to go ldflags
Currently, there is no clean way to pass extra parameters to the go tool link,
which is passed by the go build ldflags flag, the append needs to happen inside
the quotes of the ldflags parameter
See [YOCTO #14554].
Add a variable to allow adding extra parameters to -ldflags in the GO_LDFLAGS
variable, one of the main usecases is setting the application version.
For example, adding to the recipe something like
GO_EXTRA_LDFLAGS="-X main.Version=v1.0.0"
or
GO_EXTRA_LDFLAGS="-X main.Version=${PV}"
Signed-off-by: Ahmed Hossam <Ahmed.Hossam@opensynergy.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r-- | meta/classes/go.bbclass | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass index 0dd0c5f1d2..aa54b4a08c 100644 --- a/meta/classes/go.bbclass +++ b/meta/classes/go.bbclass @@ -41,7 +41,8 @@ GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS GO_LINKMODE ?= "" GO_LINKMODE:class-nativesdk = "--linkmode=external" GO_LINKMODE:class-native = "--linkmode=external" -GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} -extldflags '${GO_EXTLDFLAGS}'"' +GO_EXTRA_LDFLAGS ?= "" +GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} ${GO_EXTRA_LDFLAGS} -extldflags '${GO_EXTLDFLAGS}'"' export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath" export GOPATH_OMIT_IN_ACTIONID ?= "1" export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c" |