summaryrefslogtreecommitdiffstats
path: root/meta/classes/go.bbclass
diff options
context:
space:
mode:
authorAhmed Hossam <Ahmed.Hossam@opensynergy.com>2021-10-26 20:56:42 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-28 14:16:30 +0100
commit82070da31d86c5fd87818bea80ad1038ea74a94e (patch)
tree459a1723314c47f103690354396392c2c9dca811 /meta/classes/go.bbclass
parent52e97dc769858ce2d2e735a832f67972927dba8c (diff)
downloadpoky-82070da31d86c5fd87818bea80ad1038ea74a94e.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}" (From OE-Core rev: eaa7a61dab9a1d7bb039f16abdd9aacb44faa595) Signed-off-by: Ahmed Hossam <Ahmed.Hossam@opensynergy.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/go.bbclass')
-rw-r--r--meta/classes/go.bbclass3
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
41GO_LINKMODE ?= "" 41GO_LINKMODE ?= ""
42GO_LINKMODE:class-nativesdk = "--linkmode=external" 42GO_LINKMODE:class-nativesdk = "--linkmode=external"
43GO_LINKMODE:class-native = "--linkmode=external" 43GO_LINKMODE:class-native = "--linkmode=external"
44GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} -extldflags '${GO_EXTLDFLAGS}'"' 44GO_EXTRA_LDFLAGS ?= ""
45GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} ${GO_EXTRA_LDFLAGS} -extldflags '${GO_EXTLDFLAGS}'"'
45export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath" 46export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath"
46export GOPATH_OMIT_IN_ACTIONID ?= "1" 47export GOPATH_OMIT_IN_ACTIONID ?= "1"
47export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c" 48export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c"