All of lore.kernel.org
 help / color / mirror / Atom feed
* Yocto on AMD Zen target ?
@ 2025-04-04  8:15 Joel GUITTET
  2025-04-04  9:17 ` [yocto] " Khem Raj
       [not found] ` <E63C2FBD-D303-4686-B29D-D8306CB27A80.1@smtp-inbound1.duck.com>
  0 siblings, 2 replies; 14+ messages in thread
From: Joel GUITTET @ 2025-04-04  8:15 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

Hello,

A customer ask us if it is possible to build a Yocto distro for an AMD EPYC 7502P CPU.
Seems to be a Ryzen Zen architecture according to Wikipedia.

Has Yocto any support for this kind of targets ? I don't find any relevant information.
Is it just supposed to work with the "genericx86-64.conf" machine provided in poky ?

Thanks
Joel

[-- Attachment #2: Type: text/html, Size: 481 bytes --]

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

* Re: [yocto] Yocto on AMD Zen target ?
  2025-04-04  8:15 Yocto on AMD Zen target ? Joel GUITTET
@ 2025-04-04  9:17 ` Khem Raj
  2025-04-04  9:34   ` Alexander Kanavin
       [not found] ` <E63C2FBD-D303-4686-B29D-D8306CB27A80.1@smtp-inbound1.duck.com>
  1 sibling, 1 reply; 14+ messages in thread
From: Khem Raj @ 2025-04-04  9:17 UTC (permalink / raw)
  To: yocto, jguittet.opensource

On Fri, Apr 4, 2025 at 1:15 AM Joel GUITTET via lists.yoctoproject.org
<jguittet.opensource=witekio.com@lists.yoctoproject.org> wrote:
>
> Hello,
>
> A customer ask us if it is possible to build a Yocto distro for an AMD EPYC 7502P CPU.
> Seems to be a Ryzen Zen architecture according to Wikipedia.
>
> Has Yocto any support for this kind of targets ? I don't find any relevant information.
> Is it just supposed to work with the "genericx86-64.conf" machine provided in poky ?

Generally yes, if you want specific machine maybe use meta-amd see
https://web.git.yoctoproject.org/meta-amd/tree/meta-amd-bsp/conf/machine
I think milan is the one that you will use for this machine.

>
> Thanks
> Joel
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> You automatically follow any topics you start or reply to.
> View/Reply Online (#65097): https://lists.yoctoproject.org/g/yocto/message/65097
> Mute This Topic: https://lists.yoctoproject.org/mt/112080706/1997914
> Group Owner: yocto+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


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

* Re: [yocto] Yocto on AMD Zen target ?
  2025-04-04  9:17 ` [yocto] " Khem Raj
@ 2025-04-04  9:34   ` Alexander Kanavin
  2025-04-04  9:36     ` Joel GUITTET
  0 siblings, 1 reply; 14+ messages in thread
From: Alexander Kanavin @ 2025-04-04  9:34 UTC (permalink / raw)
  To: yocto, raj.khem; +Cc: jguittet.opensource

On Fri, 4 Apr 2025 at 11:17, Khem Raj via lists.yoctoproject.org
<raj.khem=gmail.com@lists.yoctoproject.org> wrote:
> > A customer ask us if it is possible to build a Yocto distro for an AMD EPYC 7502P CPU.
> > Seems to be a Ryzen Zen architecture according to Wikipedia.
> >
> > Has Yocto any support for this kind of targets ? I don't find any relevant information.
> > Is it just supposed to work with the "genericx86-64.conf" machine provided in poky ?
>
> Generally yes, if you want specific machine maybe use meta-amd see
> https://web.git.yoctoproject.org/meta-amd/tree/meta-amd-bsp/conf/machine
> I think milan is the one that you will use for this machine.

Also, generix86-64 isn't tested on any actual x86 hardware, and lacks
many important tweaks that make a useful image. If meta-amd doesn't
work, there's also meta-intel. X86 builds are broadly compatible
between them.

Alex


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

* Re: [yocto] Yocto on AMD Zen target ?
  2025-04-04  9:34   ` Alexander Kanavin
@ 2025-04-04  9:36     ` Joel GUITTET
  0 siblings, 0 replies; 14+ messages in thread
From: Joel GUITTET @ 2025-04-04  9:36 UTC (permalink / raw)
  To: Alexander Kanavin, yocto

[-- Attachment #1: Type: text/plain, Size: 138 bytes --]

Hello Khem and Alex,

Thanks for these answers and pointing the meta-amd, I have found the tune-zen include files, seems fine.

Joel

[-- Attachment #2: Type: text/html, Size: 205 bytes --]

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

* warn if a variable is not used
       [not found] ` <E63C2FBD-D303-4686-B29D-D8306CB27A80.1@smtp-inbound1.duck.com>
@ 2025-04-08  8:23   ` proffesionaladdress2
  2025-04-08  8:58   ` proffesionaladdress2
  2025-04-08  8:59   ` proffesionaladdress2
  2 siblings, 0 replies; 14+ messages in thread
From: proffesionaladdress2 @ 2025-04-08  8:23 UTC (permalink / raw)
  To: yocto at lists yoctoproject org proffesionaladdress2

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

Hello, 

In a .bbappend file, I want to send a warning if a variable is not set/exist and set it to a default value. 
I use BitBake Build Tool Core version 2.0.0. 

If I try to test it like: 

if [[ -z "${MY_VARIABLE}" ]] 

I get an error like: 

Log data follows: 
| DEBUG: Executing shell function do_compile 
| /<path>/run.do_compile.352486: 153: MY_VARIABLE: not found 
| WARNING: exit code 127 from a shell command. 
ERROR: Task (/<path>/rpi-u-boot-scr.bb:do_compile) failed with exit code '1' 

When I use: 
isempty="${@bb.utils.contains('MY_VARIABLE', '', 'false', 'true', d)}" 
bbwarn "isempty=$isempty" 
if [[ $isempty == true ]]; then 
MY_VARIABLE = "value" 
bbwarn "MY_VARIABLE is not defined, used default: ${MY_VARIABLE}" 
else 
bbwarn "?????" 
fi 

it print: 
WARNING: rpi-u-boot-scr-1.0-r0 do_compile: isempty=true 
WARNING: rpi-u-boot-scr-1.0-r0 do_compile: ????? 

I already try with quote or not, but when I test it in a shell by setting the isempty variable it work properly. 

Best regards. 

[-- Attachment #2: Type: text/html, Size: 1793 bytes --]

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

* warn if a variable is not used
       [not found] ` <E63C2FBD-D303-4686-B29D-D8306CB27A80.1@smtp-inbound1.duck.com>
  2025-04-08  8:23   ` warn if a variable is not used proffesionaladdress2
@ 2025-04-08  8:58   ` proffesionaladdress2
  2025-04-08  8:59   ` proffesionaladdress2
  2 siblings, 0 replies; 14+ messages in thread
From: proffesionaladdress2 @ 2025-04-08  8:58 UTC (permalink / raw)
  To: yocto at lists yoctoproject org proffesionaladdress2

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

Hello, 

In a .bbappend file, I want to send a warning if a variable is not set/exist and set it to a default value. 
I use BitBake Build Tool Core version 2.0.0. 

If I try to test it like: 

if [[ -z "${MY_VARIABLE}" ]] 

I get an error like: 

Log data follows: 
| DEBUG: Executing shell function do_compile 
| /<path>/run.do_compile.352486: 153: MY_VARIABLE: not found 
| WARNING: exit code 127 from a shell command. 
ERROR: Task (/<path>/rpi-u-boot-scr.bb:do_compile) failed with exit code '1' 

When I use: 
isempty="${@bb.utils.contains('MY_VARIABLE', '', 'false', 'true', d)}" 
bbwarn "isempty=$isempty" 
if [[ $isempty == true ]]; then 
MY_VARIABLE = "value" 
bbwarn "MY_VARIABLE is not defined, used default: ${MY_VARIABLE}" 
else 
bbwarn "?????" 
fi 

it print: 
WARNING: rpi-u-boot-scr-1.0-r0 do_compile: isempty=true 
WARNING: rpi-u-boot-scr-1.0-r0 do_compile: ????? 

I already try with quote or not, but when I test it in a shell by setting the isempty variable it work properly. 

Best regards. 

[-- Attachment #2: Type: text/html, Size: 1793 bytes --]

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

* warn if a variable is not used
       [not found] ` <E63C2FBD-D303-4686-B29D-D8306CB27A80.1@smtp-inbound1.duck.com>
  2025-04-08  8:23   ` warn if a variable is not used proffesionaladdress2
  2025-04-08  8:58   ` proffesionaladdress2
@ 2025-04-08  8:59   ` proffesionaladdress2
  2025-04-08 12:56     ` [yocto] " Gyorgy Sarvari
  2025-04-08 13:18     ` Clayton Casciato
  2 siblings, 2 replies; 14+ messages in thread
From: proffesionaladdress2 @ 2025-04-08  8:59 UTC (permalink / raw)
  To: yocto at lists yoctoproject org proffesionaladdress2

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

Hello, 

In a .bbappend file, I want to send a warning if a variable is not set/exist and set it to a default value. 
I use BitBake Build Tool Core version 2.0.0. 

If I try to test it like: 

if [[ -z "${MY_VARIABLE}" ]] 

I get an error like: 

Log data follows: 
| DEBUG: Executing shell function do_compile 
| /<path>/run.do_compile.352486: 153: MY_VARIABLE: not found 
| WARNING: exit code 127 from a shell command. 
ERROR: Task (/<path>/rpi-u-boot-scr.bb:do_compile) failed with exit code '1' 

When I use: 
isempty="${@bb.utils.contains('MY_VARIABLE', '', 'false', 'true', d)}" 
bbwarn "isempty=$isempty" 
if [[ $isempty == true ]]; then 
MY_VARIABLE = "value" 
bbwarn "MY_VARIABLE is not defined, used default: ${MY_VARIABLE}" 
else 
bbwarn "?????" 
fi 

it print: 
WARNING: rpi-u-boot-scr-1.0-r0 do_compile: isempty=true 
WARNING: rpi-u-boot-scr-1.0-r0 do_compile: ????? 

I already try with quote or not, but when I test it in a shell by setting the isempty variable it work properly. 

Best regards. 

[-- Attachment #2: Type: text/html, Size: 1793 bytes --]

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

* Re: [yocto] warn if a variable is not used
  2025-04-08  8:59   ` proffesionaladdress2
@ 2025-04-08 12:56     ` Gyorgy Sarvari
       [not found]       ` <7A2D6367-3CD1-460F-9655-69A8B0D980A7.1@smtp-inbound1.duck.com>
  2025-04-08 13:18     ` Clayton Casciato
  1 sibling, 1 reply; 14+ messages in thread
From: Gyorgy Sarvari @ 2025-04-08 12:56 UTC (permalink / raw)
  To: yocto, proffesionaladdress2

>
> | /<path>/run.do_compile.352486: 153: MY_VARIABLE: not found
<snip>
>            MY_VARIABLE = "value"
Note that when you are in do_compile, that's a shell script. You
shouldn't put space around the equal sign here, because that's not a
valid syntax to assign a value to a variable in shell.


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

* Re: [yocto] warn if a variable is not used
       [not found]         ` <05B9C867-74DD-4A91-9A1B-1BD33302248A.1@smtp-inbound1.duck.com>
@ 2025-04-08 13:09           ` Gyorgy Sarvari
  0 siblings, 0 replies; 14+ messages in thread
From: Gyorgy Sarvari @ 2025-04-08 13:09 UTC (permalink / raw)
  To: proffesionaladdress2; +Cc: yocto at lists yoctoproject org proffesionaladdress2

You can check what is actually executed by bitbake. Open the
run.do_compile file to see the actual script after a failure, and see
how it is parsed and where it goes astray.

On 4/8/25 15:06, proffesionaladdress2@duck.com wrote:
> Thank you, but branch is never reached because the previous condition is never true in this code (and I don't know why).
> Even if bbwarn print 'WARNING: rpi-u-boot-scr-1.0-r0 do_compile: isempty=true'.
>
> isempty="${@bb.utils.contains('MY_VARIABLE', '', 'false', 'true', d)}"
> bbwarn "isempty=$isempty"
> if [[ $isempty == true ]]; then
>            MY_VARIABLE = "value"
>             bbwarn "MY_VARIABLE is not defined, used default: ${MY_VARIABLE}"
> else
>             bbwarn "?????"
> fi
>
> But maybe bitbake provide some syntax to print a warning when a variable is not set outside bash code.
> Or it is easier to use some python code.
>
> ----- Mail original -----
> De: "Gyorgy Sarvari" <skandigraun_at_gmail.com_proffesionaladdress2@duck.com>
> À: "yocto at lists yoctoproject org proffesionaladdress2" <yocto_at_lists.yoctoproject.org_proffesionaladdress2@duck.com>, proffesionaladdress2@duck.com
> Envoyé: Mardi 8 Avril 2025 14:56:24
> Objet: Re: [yocto] warn if a variable is not used
>
>> | /<path>/run.do_compile.352486: 153: MY_VARIABLE: not found
> <snip>
>>            MY_VARIABLE = "value"
> Note that when you are in do_compile, that's a shell script. You
> shouldn't put space around the equal sign here, because that's not a
> valid syntax to assign a value to a variable in shell.
>


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

* Re: [yocto] warn if a variable is not used
       [not found]       ` <7A2D6367-3CD1-460F-9655-69A8B0D980A7.1@smtp-inbound1.duck.com>
       [not found]         ` <05B9C867-74DD-4A91-9A1B-1BD33302248A.1@smtp-inbound1.duck.com>
@ 2025-04-08 13:12         ` proffesionaladdress2
  2025-04-14 10:58           ` Quentin Schulz
  1 sibling, 1 reply; 14+ messages in thread
From: proffesionaladdress2 @ 2025-04-08 13:12 UTC (permalink / raw)
  To: Gyorgy Sarvari
  Cc: yocto at lists yoctoproject org proffesionaladdress2,
	proffesionaladdress2

Thank you, but branch is never reached because the previous condition is never true in this code (and I don't know why).
Even if bbwarn print 'WARNING: rpi-u-boot-scr-1.0-r0 do_compile: isempty=true'.

isempty="${@bb.utils.contains('MY_VARIABLE', '', 'false', 'true', d)}"
bbwarn "isempty=$isempty"
if [[ $isempty == true ]]; then
           MY_VARIABLE = "value"
            bbwarn "MY_VARIABLE is not defined, used default: ${MY_VARIABLE}"
else
            bbwarn "?????"
fi

But maybe bitbake provide some syntax to print a warning when a variable is not set outside bash code.
Or it is easier to use some python code.

----- Mail original -----
De: "Gyorgy Sarvari" <skandigraun_at_gmail.com_proffesionaladdress2@duck.com>
À: "yocto at lists yoctoproject org proffesionaladdress2" <yocto_at_lists.yoctoproject.org_proffesionaladdress2@duck.com>, proffesionaladdress2@duck.com
Envoyé: Mardi 8 Avril 2025 14:56:24
Objet: Re: [yocto] warn if a variable is not used

>
> | /<path>/run.do_compile.352486: 153: MY_VARIABLE: not found
<snip>
>            MY_VARIABLE = "value"
Note that when you are in do_compile, that's a shell script. You
shouldn't put space around the equal sign here, because that's not a
valid syntax to assign a value to a variable in shell.



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

* Re: [yocto] warn if a variable is not used
  2025-04-08  8:59   ` proffesionaladdress2
  2025-04-08 12:56     ` [yocto] " Gyorgy Sarvari
@ 2025-04-08 13:18     ` Clayton Casciato
       [not found]       ` <4C0F3047-0C25-4038-BA0C-FE81491D89E5.1@smtp-inbound1.duck.com>
  1 sibling, 1 reply; 14+ messages in thread
From: Clayton Casciato @ 2025-04-08 13:18 UTC (permalink / raw)
  To: proffesionaladdress2, yocto

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

In case you weren't aware, you can explicitly set default values:
W ??= "x"
A ?= "aval"

https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-metadata.html#setting-a-default-value

--

Variables can be queried as to how they are set:
$ bitbake-getvar --recipe rpi-u-boot-scr MY_VARIABLE

--

Also note:

> 
> The scripts are executed by /bin/sh , which may not be a bash shell but
> might be something such as dash.
> 

https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-metadata.html#shell-functions

[-- Attachment #2: Type: text/html, Size: 5086 bytes --]

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

* Re: [yocto] warn if a variable is not used
       [not found]       ` <4C0F3047-0C25-4038-BA0C-FE81491D89E5.1@smtp-inbound1.duck.com>
@ 2025-04-09 15:32         ` proffesionaladdress2
  0 siblings, 0 replies; 14+ messages in thread
From: proffesionaladdress2 @ 2025-04-09 15:32 UTC (permalink / raw)
  To: Clayton Casciato
  Cc: proffesionaladdress2,
	yocto at lists yoctoproject org proffesionaladdress2

[-- Attachment #1: Type: text/plain, Size: 5145 bytes --]

Thank you, I wasn't aware about the --recipe option of bitbake-getvar. 

The goal here is not to silently set to a value but to also send a warning. 

I made it like but it print a lot of warning with BitBake Build Tool Core version 2.0.0 (the ":=" doesn't expand once in .bb file?), in a check_variable.bbclass: 

# warn_and_set_variable_default function take as parameters, the BitBake datastore "d", the variable to check "var" and the value to set if the variable "var" is empty. 
# It shall be set to a variable like: MY_VAR := "${@warn_and_set_variable_default(d, 'MY_VAR', "default")}" 
# to avoid multiple variable expansion according to bitbake documentation: 
# https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-metadata.html#inline-python-variable-expansion 
def warn_and_set_variable_default(d, var, defaultvalue): 
variable_value = d.getVar(var) 
if not variable_value: 
bb.warn('The variable %s is empty or not defined, it will be set to "%s"' % (var, defaultvalue)) 
return defaultvalue 
else: 
return variable_value 

# fail_if_variable_empty function take as parameters, the BitBake datastore "d", the variable to check "var". 
# It shall be set to a variable like warn_and_set_variable_default function. 
def fail_if_variable_empty(d, var): 
variable_value = d.getVar(var) 
if not variable_value: 
bb.fatal('The variable %s is empty and shall be set' %var) 
return None 
else: 
return variable_value 




Then in recipe: 

include classes/check_variable.bbclass 

# Parse mandatory variables 
MY_VAR_MANDATORY_PARSED := "${@fail_if_variable_empty(d, 'MY_VAR_MANDATORY')}" 

# Parse optional variables 
MY_VAR_OPTIONAL_PARSED := "${@warn_and_set_variable_default(d, 'MY_VAR_OPTIONAL', 'default')}" 


#usage 
do_install:append() { 
sed -i "s#@MY_VAR_MANDATORY@#\"${MY_VAR_MANDATORY_PARSED}\"#g" ${D}${bindir}/myfile.file 
sed -i "s#@MY_VAR_OPTIONAL@#\"${MY_VAR_OPTIONAL_PARSED}\"#g" ${D}${bindir}/myfile.file 
} 

And in local.conf (to avoid error from bbfatal): 

MY_VAR_MANDATORY="deadbeef" 


it will print 14 times for my recipe, like: 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default" 



De: "Clayton Casciato" <ccasciato_at_21sw.us_proffesionaladdress2@duck.com> 
À: "proffesionaladdress2" <proffesionaladdress2@duck.com>, "yocto at lists yoctoproject org proffesionaladdress2" <yocto_at_lists.yoctoproject.org_proffesionaladdress2@duck.com> 
Envoyé: Mardi 8 Avril 2025 15:18:54 
Objet: Re: [yocto] warn if a variable is not used 

In case you weren't aware, you can explicitly set default values: W ??= "x" A ?= "aval" https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-metadata.html#setting-a-defaul 

	

	

	

	
DuckDuckGo did not detect any trackers. [ https://duckduckgo.com/-IAIIzTFfMjhHUPJJpT-egROjaq5duXecWi8_QYYw2KgrYCq8CyKIfbd8C7jYEzviBm9jtTq-ynKiLi1BI6Tf447Ot-09ZA70WKKvc8VYd55iREHlhxCWcbhJWnqmrOf8TAqLpw0gSCM-b1qX2Qi9wurrhws1ngng9H9-BcqIg3svdO4t7VgT-SadQMtGCo6ptJNRY_imO7Pw | More ] 

	
	[ https://duckduckgo.com/-IAIIzTFfMjhHUPJJpT-egROjaq5duXecWi8_QYYw2KgrYCq8CyKIfbd8C7jYEzviBm9jtTq-ynKiLi1BI6Tf447Ot-09ZA70WKKvc8VYd55iREHlhxCWcbhJWnqmrOf8TAqLpw0gSCM-b1qX2Qi9wurrhws1ngng9H9-BcqIg3svdO4t7VgT-SadQMtGCo6ptJNRY_imO7Pw |  Report Spam  ] 
In case you weren't aware, you can explicitly set default values: 
W ??= "x" 
A ?= "aval" 
https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-metadata.html#setting-a-default-value 
-- 
Variables can be queried as to how they are set: 
$ bitbake-getvar --recipe rpi-u-boot-scr MY_VARIABLE 
-- 
Also note: 



The scripts are executed by /bin/sh , which may not be a bash shell but might be something such as dash . 



https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-metadata.html#shell-functions 



[-- Attachment #2: Type: text/html, Size: 11492 bytes --]

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

* Re: [yocto] warn if a variable is not used
  2025-04-08 13:12         ` proffesionaladdress2
@ 2025-04-14 10:58           ` Quentin Schulz
       [not found]             ` <8417B008-2B4E-42D4-B5A6-E7D31B7D6D3D.1@smtp-inbound1.duck.com>
  0 siblings, 1 reply; 14+ messages in thread
From: Quentin Schulz @ 2025-04-14 10:58 UTC (permalink / raw)
  To: yocto, proffesionaladdress2, Gyorgy Sarvari

Hi,

On 4/8/25 3:12 PM, proffesionaladdress2 via lists.yoctoproject.org wrote:
> Thank you, but branch is never reached because the previous condition is never true in this code (and I don't know why).
> Even if bbwarn print 'WARNING: rpi-u-boot-scr-1.0-r0 do_compile: isempty=true'.
> 
> isempty="${@bb.utils.contains('MY_VARIABLE', '', 'false', 'true', d)}"
> bbwarn "isempty=$isempty"
> if [[ $isempty == true ]]; then

This syntax is not supported by BitBake, please use POSIX condition here 
instead. (i.e. not the [[ ]], but [ ]).

Cheers,
Quentin


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

* Re: [yocto] warn if a variable is not used
       [not found]             ` <8417B008-2B4E-42D4-B5A6-E7D31B7D6D3D.1@smtp-inbound1.duck.com>
@ 2025-04-14 13:57               ` proffesionaladdress2
  0 siblings, 0 replies; 14+ messages in thread
From: proffesionaladdress2 @ 2025-04-14 13:57 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: yocto at lists yoctoproject org proffesionaladdress2,
	proffesionaladdress2, Gyorgy Sarvari

Thank you for reply, I also tried the [ ] syntax without success.

I made it like following, but it print a lot of warning with BitBake Build Tool Core version 2.0.0 (the ":=" doesn't expand once in .bb file?).
In a check_variable.bbclass:

# warn_and_set_variable_default function take as parameters, the BitBake datastore "d", the variable to check "var" and the value to set if the variable "var" is empty.
# It shall be set to a variable like: MY_VAR := "${@warn_and_set_variable_default(d, 'MY_VAR', "default")}"
# to avoid multiple variable expansion according to bitbake documentation:
# https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-metadata.html#inline-python-variable-expansion
def warn_and_set_variable_default(d, var, defaultvalue):
    variable_value = d.getVar(var)
    if not variable_value:
        bb.warn('The variable %s is empty or not defined, it will be set to "%s"' % (var, defaultvalue))
        return defaultvalue
    else:
        return variable_value

# fail_if_variable_empty function take as parameters, the BitBake datastore "d", the variable to check "var".
# It shall be set to a variable like warn_and_set_variable_default function.
def fail_if_variable_empty(d, var):
    variable_value = d.getVar(var)
    if not variable_value:
        bb.fatal('The variable %s is empty and shall be set' %var)
        return None
    else:
        return variable_value




Then in recipe:

include classes/check_variable.bbclass

# Parse mandatory variables
MY_VAR_MANDATORY_PARSED := "${@fail_if_variable_empty(d, 'MY_VAR_MANDATORY')}"

# Parse optional variables
MY_VAR_OPTIONAL_PARSED := "${@warn_and_set_variable_default(d, 'MY_VAR_OPTIONAL', 'default')}"


#usage
do_install:append() {
      sed -i "s#@MY_VAR_MANDATORY@#\"${MY_VAR_MANDATORY_PARSED}\"#g" ${D}${bindir}/myfile.file
      sed -i "s#@MY_VAR_OPTIONAL@#\"${MY_VAR_OPTIONAL_PARSED}\"#g" ${D}${bindir}/myfile.file
}

And in local.conf (to avoid error from bbfatal):

MY_VAR_MANDATORY="deadbeef"


it will print 14 times for my recipe, like:
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"
WARNING: The variable MY_VAR_OPTIONAL is empty or not defined, it will be set to "default"

----- Mail original -----
De: "Quentin Schulz" <quentin.schulz_at_cherry.de_proffesionaladdress2@duck.com>
À: "yocto at lists yoctoproject org proffesionaladdress2" <yocto_at_lists.yoctoproject.org_proffesionaladdress2@duck.com>, "proffesionaladdress2" <proffesionaladdress2@duck.com>, "Gyorgy Sarvari" <skandigraun_at_gmail.com_proffesionaladdress2@duck.com>
Envoyé: Lundi 14 Avril 2025 12:58:57
Objet: Re: [yocto] warn if a variable is not used

Hi,

On 4/8/25 3:12 PM, proffesionaladdress2 via lists.yoctoproject.org wrote:
> Thank you, but branch is never reached because the previous condition is never true in this code (and I don't know why).
> Even if bbwarn print 'WARNING: rpi-u-boot-scr-1.0-r0 do_compile: isempty=true'.
> 
> isempty="${@bb.utils.contains('MY_VARIABLE', '', 'false', 'true', d)}"
> bbwarn "isempty=$isempty"
> if [[ $isempty == true ]]; then

This syntax is not supported by BitBake, please use POSIX condition here 
instead. (i.e. not the [[ ]], but [ ]).

Cheers,
Quentin



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

end of thread, other threads:[~2025-04-14 14:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04  8:15 Yocto on AMD Zen target ? Joel GUITTET
2025-04-04  9:17 ` [yocto] " Khem Raj
2025-04-04  9:34   ` Alexander Kanavin
2025-04-04  9:36     ` Joel GUITTET
     [not found] ` <E63C2FBD-D303-4686-B29D-D8306CB27A80.1@smtp-inbound1.duck.com>
2025-04-08  8:23   ` warn if a variable is not used proffesionaladdress2
2025-04-08  8:58   ` proffesionaladdress2
2025-04-08  8:59   ` proffesionaladdress2
2025-04-08 12:56     ` [yocto] " Gyorgy Sarvari
     [not found]       ` <7A2D6367-3CD1-460F-9655-69A8B0D980A7.1@smtp-inbound1.duck.com>
     [not found]         ` <05B9C867-74DD-4A91-9A1B-1BD33302248A.1@smtp-inbound1.duck.com>
2025-04-08 13:09           ` Gyorgy Sarvari
2025-04-08 13:12         ` proffesionaladdress2
2025-04-14 10:58           ` Quentin Schulz
     [not found]             ` <8417B008-2B4E-42D4-B5A6-E7D31B7D6D3D.1@smtp-inbound1.duck.com>
2025-04-14 13:57               ` proffesionaladdress2
2025-04-08 13:18     ` Clayton Casciato
     [not found]       ` <4C0F3047-0C25-4038-BA0C-FE81491D89E5.1@smtp-inbound1.duck.com>
2025-04-09 15:32         ` proffesionaladdress2

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.