VARIABLE[flag] ??= "value" behaves as VARIABLE[flag] = "value" while the docs say that "All the standard syntax operations previously mentioned work for variable flags except for override style syntax". I _think_ it's because in DataNode::eval flag = None if 'flag' in groupd and groupd['flag'] is not None: flag = groupd['flag'] elif groupd["lazyques"]: flag = "_defaultval" will leave op = "set" even if groupd['op'] == 'lazyques'. But I can't find the code that cares about op, so I could be wrong. If ??= is not supported for flag assignments, we should at least get an error.
I think this is a bug and ??= should work for flags as expected. We should probably add a test case to lib/bb/tests/ and then fix the code, you're probably on the right track with the code fix but I need to look in more detail. The test case will help test before/after the fix.
Should fix but not urgent. Yoann will work on this next year!
Reproducer: #local.conf: TEST = "good value" TEST ??= "bad value" TEST[flag] = "good flag" TEST[flag] ??= "bad flag" Then: $ bitbake-getvar TEST ; echo -n "TEST[flag] = " ; bitbake-getvar TEST -f flag --value # # $TEST [4 operations] # set /home/yocon/Documents/projets/yocto/poky_bb_intero_flag/build/conf/local.conf:291 # "good value" # set /home/yocon/Documents/projets/yocto/poky_bb_intero_flag/build/conf/local.conf:292 # [_defaultval] "bad value" # set /home/yocon/Documents/projets/yocto/poky_bb_intero_flag/build/conf/local.conf:293 # [flag] "good flag" # set /home/yocon/Documents/projets/yocto/poky_bb_intero_flag/build/conf/local.conf:294 # [flag] "bad flag" # pre-expansion value: # "good value" TEST="good value" TEST[flag] =bad flag ^ this should display "good flag" (like it does for "good value")
Patch v1 sent: bitbake-devel@lists.openembedded.org | [PATCH 1/2] tests/parse: add test for ?= and ??= operators for variable flags https://lists.openembedded.org/g/bitbake-devel/topic/patch_1_2_tests_parse_add/110541105 bitbake-devel@lists.openembedded.org | [PATCH 2/2] data_smart: fix ??= operator for variable flags https://lists.openembedded.org/g/bitbake-devel/topic/patch_2_2_data_smart_fix/110541106
Patch v2: bitbake-devel@lists.openembedded.org | [PATCH v2 1/2] tests/parse: add test for ?= and ??= operators for variable flags https://lists.openembedded.org/g/bitbake-devel/topic/patch_v2_1_2_tests_parse/110545216 bitbake-devel@lists.openembedded.org | [PATCH v2 2/2] data_smart: fix ??= operator for variable flags https://lists.openembedded.org/g/bitbake-devel/topic/patch_v2_2_2_data_smart/110545217
Merged: tests/parse: add test for ?= and ??= operators for variable flags - bitbake - Bitbake Development tree https://git.openembedded.org/bitbake/commit/?id=d12c80125d810df54379cc4f019a95ab9064ad2c data_smart: fix ??= operator for variable flags - bitbake - Bitbake Development tree https://git.openembedded.org/bitbake/commit/?id=0329a7e3ac694737f2d2c1861f65492551360663
Created attachment 5096 [details] Failing test case for getVarFlags()
Louis Rannou found a bug with the current fix: * default varflags are excluded from d.getVarFlags() dict but should be (at least I would expect it) * https://bugzilla.yoctoproject.org/attachment.cgi?id=5096 attached patch to trigger the bug * Simpler version: In the current testcase: self.assertTrue("flag_default" in d.getVarFlags("A"))
I guess we need to act on "_defaultval_flag_*" variables in getVarFlags() instead of skipping them currently: https://git.openembedded.org/bitbake/tree/lib/bb/data_smart.py?id=93059aad13a12cd69d86368795c88e5349197d5d#n952
you may need to pass internalflags=True to getVarFlags()?
Hello, I'm quite ready for a v2 patch but I'm having some incoherences. First of all, I found that calling delVar("A") will blow out all flags. Is that expected ? Perhaps we can have an extra argument to say if we want flags to be deleted or not. Second, delVarFlag("A", "flag1") will erase the flag1 but not its weak default. I suppose the default must be removed too ?
Louis sent a v2: [PATCH v2 0/2] bitbake: fix ??= operator for variable flags and test https://lists.openembedded.org/g/bitbake-devel/topic/patch_v2_0_2_bitbake_fix/111163809 [PATCH v2 1/2] bitbake: data_smart: fix ??= operator for variable flags https://lists.openembedded.org/g/bitbake-devel/topic/patch_v2_1_2_bitbake/111163810 [PATCH v2 2/2] bitbake: tests/data: add tests for variable flags https://lists.openembedded.org/g/bitbake-devel/topic/patch_v2_2_2_bitbake/111163811
Merged: bitbake: data_smart: fix ??= operator for variable flags https://git.openembedded.org/bitbake/commit?id=2ee079fc1b7cf6d384ca17bd034b0a40461d9d18 bitbake: tests/data: add tests for variable flags https://git.openembedded.org/bitbake/commit?id=ff8cae735cf489373af1aac7ee233d7b82d483d3
Closing, but reoppen if delVar is not supposed to erase all variable flags
I did mean to comment, delVar is supposed to remove all varflags so that behaviour is correct, thanks!