All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] go.bbclass: Allow adding parameters to go ldflags
@ 2021-10-26 18:56 Ahmed Hossam
  2021-10-27  3:02 ` [OE-core] " Khem Raj
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmed Hossam @ 2021-10-26 18:56 UTC (permalink / raw)
  To: openembedded-core; +Cc: Ahmed Hossam

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>
---
 meta/classes/go.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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"
--
2.33.1


Please mind our privacy notice<https://www.opensynergy.com/datenschutzerklaerung/privacy-notice-for-business-partners-pursuant-to-article-13-of-the-general-data-protection-regulation-gdpr/> pursuant to Art. 13 GDPR. // Unsere Hinweise zum Datenschutz gem. Art. 13 DSGVO finden Sie hier.<https://www.opensynergy.com/de/datenschutzerklaerung/datenschutzhinweise-fuer-geschaeftspartner-gem-art-13-dsgvo/>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [OE-core] [PATCH] go.bbclass: Allow adding parameters to go ldflags
  2021-10-26 18:56 [PATCH] go.bbclass: Allow adding parameters to go ldflags Ahmed Hossam
@ 2021-10-27  3:02 ` Khem Raj
  0 siblings, 0 replies; 2+ messages in thread
From: Khem Raj @ 2021-10-27  3:02 UTC (permalink / raw)
  To: Ahmed Hossam, openembedded-core

looks fine

On 10/26/21 11:56, Ahmed Hossam wrote:
> 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>
> ---
>   meta/classes/go.bbclass | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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"
> --
> 2.33.1
> 
> 
> Please mind our privacy notice<https://www.opensynergy.com/datenschutzerklaerung/privacy-notice-for-business-partners-pursuant-to-article-13-of-the-general-data-protection-regulation-gdpr/> pursuant to Art. 13 GDPR. // Unsere Hinweise zum Datenschutz gem. Art. 13 DSGVO finden Sie hier.<https://www.opensynergy.com/de/datenschutzerklaerung/datenschutzhinweise-fuer-geschaeftspartner-gem-art-13-dsgvo/>
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#157449): https://lists.openembedded.org/g/openembedded-core/message/157449
> Mute This Topic: https://lists.openembedded.org/mt/86610860/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-27  3:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 18:56 [PATCH] go.bbclass: Allow adding parameters to go ldflags Ahmed Hossam
2021-10-27  3:02 ` [OE-core] " Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.