[bitbake-devel] enable override for suffix just include digit and dot

Submitted by 张忠山 on Aug. 26, 2016, 5:34 a.m. | Patch ID: 130201

Details

Message ID 1472189699-6646-1-git-send-email-zzs213@126.com
State New
Headers show

Commit Message

张忠山 Aug. 26, 2016, 5:34 a.m.
From: 张忠山 <zzs213@126.com>

Without this patch, if we write these in recipe test.bb:

	NAME_1.1.7   = 'version is 1.1.7'
	NAME_develop = 'version is develop'

Use 'bitbake test -e' to observe 'NAME':
	#
	# $NAME [2 operations]
	#   override[develop]:set .../test.bb:10
	#     "version is develop"
	# pre-expansion value:
	#   "version is develop"
	NAME="version is develop"

Obviously, override for '1.1.7' missing.

Signed-off-by: 张忠山 <zzs213@126.com>
---
 lib/bb/data_smart.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 59621b7..ea4ff80 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -559,7 +559,7 @@  class DataSmart(MutableMapping):
         # aka pay the cookie monster
         override = var[var.rfind('_')+1:]
         shortvar = var[:var.rfind('_')]
-        while override and override.islower():
+        while override and (override + 'a').islower():
             if shortvar not in self.overridedata:
                 self.overridedata[shortvar] = []
             if [var, override] not in self.overridedata[shortvar]:
@@ -637,7 +637,7 @@  class DataSmart(MutableMapping):
         if '_' in var:
             override = var[var.rfind('_')+1:]
             shortvar = var[:var.rfind('_')]
-            while override and override.islower():
+            while override and (override + 'a').islower():
                 try:
                     if shortvar in self.overridedata:
                         # Force CoW by recreating the list first

Comments

Khem Raj Aug. 26, 2016, 2:44 p.m.
On Aug 25, 2016 10:35 PM, <zzs213@126.com> wrote:
>
> From: 张忠山 <zzs213@126.com>
>
> Without this patch, if we write these in recipe test.bb:
>
>         NAME_1.1.7   = 'version is 1.1.7'
>         NAME_develop = 'version is develop'
>
> Use 'bitbake test -e' to observe 'NAME':
>         #
>         # $NAME [2 operations]
>         #   override[develop]:set .../test.bb:10
>         #     "version is develop"
>         # pre-expansion value:
>         #   "version is develop"
>         NAME="version is develop"
>
> Obviously, override for '1.1.7' missing.

Dot is not allowed in variable names intentionally since its file extension
separator. I am not sure if its a good idea to allow it in variable names
>
> Signed-off-by: 张忠山 <zzs213@126.com>
> ---
>  lib/bb/data_smart.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
> index 59621b7..ea4ff80 100644
> --- a/lib/bb/data_smart.py
> +++ b/lib/bb/data_smart.py
> @@ -559,7 +559,7 @@ class DataSmart(MutableMapping):
>          # aka pay the cookie monster
>          override = var[var.rfind('_')+1:]
>          shortvar = var[:var.rfind('_')]
> -        while override and override.islower():
> +        while override and (override + 'a').islower():
>              if shortvar not in self.overridedata:
>                  self.overridedata[shortvar] = []
>              if [var, override] not in self.overridedata[shortvar]:
> @@ -637,7 +637,7 @@ class DataSmart(MutableMapping):
>          if '_' in var:
>              override = var[var.rfind('_')+1:]
>              shortvar = var[:var.rfind('_')]
> -            while override and override.islower():
> +            while override and (override + 'a').islower():
>                  try:
>                      if shortvar in self.overridedata:
>                          # Force CoW by recreating the list first
> --
> 1.9.1
>
>
> --
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
张忠山 Aug. 27, 2016, 7:32 a.m.
>>
>> Without this patch, if we write these in recipe test.bb <http://test.bb>:
>>
>>         NAME_1.1.7   = 'version is 1.1.7'
>>         NAME_develop = 'version is develop'
>>
>> Use 'bitbake test -e' to observe 'NAME':
>>         #
>>         # $NAME [2 operations]
>>         #   override[develop]:set .../test.bb:10 <http://test.bb:10>
>>         #     "version is develop"
>>         # pre-expansion value:
>>         #   "version is develop"
>>         NAME="version is develop"
>>
>> Obviously, override for '1.1.7' missing.
>
> Dot is not allowed in variable names intentionally since its file
> extension separator. I am not sure if its a good idea to allow it in
> variable names

Since we can use the path delimeter '/' in override like 
'virtual/kernel'. Why we can't use dot in override.

And bitbkae would add 'PV'(which default to '1.0' in OE) to 'OVERRIDES'. 
So using dot in override may not be an issue.

In bitbake manual, It said we can use BBVERSIONS and override to let 
sigle recipe support multiple package version

If we can't use dot in override, Howto use BBVERSIONS? Use embedded 
python code to set var according version? But it is ugly tahn using 
override!
Chris Larson Aug. 27, 2016, 7:55 p.m.
On Sat, Aug 27, 2016 at 12:32 AM, 张忠山 <zzs213@126.com> wrote:

> Without this patch, if we write these in recipe test.bb <http://test.bb>:
>>>
>>>         NAME_1.1.7   = 'version is 1.1.7'
>>>         NAME_develop = 'version is develop'
>>>
>>> Use 'bitbake test -e' to observe 'NAME':
>>>         #
>>>         # $NAME [2 operations]
>>>         #   override[develop]:set .../test.bb:10 <http://test.bb:10>
>>>         #     "version is develop"
>>>         # pre-expansion value:
>>>         #   "version is develop"
>>>         NAME="version is develop"
>>>
>>> Obviously, override for '1.1.7' missing.
>>>
>>
>> Dot is not allowed in variable names intentionally since its file
>> extension separator. I am not sure if its a good idea to allow it in
>> variable names
>>
>
> Since we can use the path delimeter '/' in override like 'virtual/kernel'.
> Why we can't use dot in override.
>
> And bitbkae would add 'PV'(which default to '1.0' in OE) to 'OVERRIDES'.
> So using dot in override may not be an issue.
>
> In bitbake manual, It said we can use BBVERSIONS and override to let sigle
> recipe support multiple package version
>
> If we can't use dot in override, Howto use BBVERSIONS? Use embedded python
> code to set var according version? But it is ugly tahn using override!


OVERRIDES .= ":pv-${@'${PV}'.replace('.', '_')}"
FOO_pv-1_1_7 = "bar"

It's worth noting that you're likely the first person to try using it since
I added the feature. oe-core moved to a policy where only one version of a
given recipe is kept in most cases, making it less useful.
张忠山 Aug. 29, 2016, 2:50 a.m.
在 2016年08月28日 03:55, Christopher Larson 写道:
>
> On Sat, Aug 27, 2016 at 12:32 AM, 张忠山 <zzs213@126.com
> <mailto:zzs213@126.com>> wrote:
>
>             Without this patch, if we write these in recipe test.bb
>             <http://test.bb> <http://test.bb>:
>
>                     NAME_1.1.7   = 'version is 1.1.7'
>                     NAME_develop = 'version is develop'
>
>             Use 'bitbake test -e' to observe 'NAME':
>                     #
>                     # $NAME [2 operations]
>                     #   override[develop]:set .../test.bb:10
>             <http://test.bb:10> <http://test.bb:10>
>                     #     "version is develop"
>                     # pre-expansion value:
>                     #   "version is develop"
>                     NAME="version is develop"
>
>             Obviously, override for '1.1.7' missing.
>
>
>         Dot is not allowed in variable names intentionally since its file
>         extension separator. I am not sure if its a good idea to allow it in
>         variable names
>
>
>     Since we can use the path delimeter '/' in override like
>     'virtual/kernel'. Why we can't use dot in override.
>
>     And bitbkae would add 'PV'(which default to '1.0' in OE) to
>     'OVERRIDES'. So using dot in override may not be an issue.
>
>     In bitbake manual, It said we can use BBVERSIONS and override to let
>     sigle recipe support multiple package version
>
>     If we can't use dot in override, Howto use BBVERSIONS? Use embedded
>     python code to set var according version? But it is ugly tahn using
>     override!
>
>
> OVERRIDES .= ":pv-${@'${PV}'.replace('.', '_')}"
> FOO_pv-1_1_7 = "bar"
>

Thanks for your suggestion.
But I found just the folowwing enough:

	OVERRIDES .= ":pv-${PV}"
	FOO_pv-1.1.7 = 'bar'

So I wonder why we must avoid dot in override. Is it mandatory or a 
convention.

And is there some taboos with 'override'. If any it should appear in 
manual I think.

> It's worth noting that you're likely the first person to try using it
> since I added the feature. oe-core moved to a policy where only one
> version of a given recipe is kept in most cases, making it less useful.

Does this means 'BBVERSIONS' would disappeared in th future?
张忠山 Aug. 29, 2016, 5:58 a.m.
>
> OVERRIDES .= ":pv-${@'${PV}'.replace('.', '_')}"
> FOO_pv-1_1_7 = "bar"
>

Now I test my project fully, Found can't use ${PV} to generate OVERRIDES.

Because of BBVERSIONS, When generage OVERRIDES, the PV not setted 
according PREFFERED_VERSION_xxx. It use the setting in bitbake.conf 
which default to `1.0`

So maybe this worked:

OVERRIDES .= ":pv-${PREFERRED_VERSION_${PN}}"
FOO_pv-1_1_7 = "bar"