[poky] About the operator "??="

Xu, Dongxiao dongxiao.xu at intel.com
Fri Dec 10 18:48:06 PST 2010


Richard Purdie wrote:
> On Thu, 2010-12-09 at 22:44 +0800, Xu, Dongxiao wrote:
>> I made the following patch (setVarFlag.patch) to move everything in
>> setVar to setVarFlag, please help to review it.
>> 
>> Please note one place that I modified, see the indent of
>> "self._seen_overrides[override].add( var )", I thought it was a bug
>> in original code.
> 
> No, its not. Its making sure [override] exists before trying to add
> var to it. It could also be: 
> 
> if override not in self._seen_overrides:
>     self._seen_overrides[override] = set(var)
> else:
>     self._seen_overrides[override].add( var )

Thanks, I understand now.

For overrides, we only override the variable flag "content", and there is no concept for overriding the other variable flags. Does my understanding correct?
If this is the case, we should add the following constraint.

+            if override not in self._seen_overrides:
+                self._seen_overrides[override] = set()
+            if flag == "content":
+                self._seen_overrides[override].add( var )

Otherwise, each time when setVarFlag() for a certain key, all flag values will will be added to self._seen_overrides[override], and for different flags, the value may be different types, and there will be errors like:

NOTE: Handling BitBake files: | (0116/0765) [15 %]ERROR: cannot concatenate 'str' and 'NoneType' objects while parsing /home/dongxiao/poky/meta/recipes-devtools/dpkg/dpkg_1.15.8.5.bb. 

> 
>> After adding this, the "two lines" in original "??=" optimization
>> patch are no longer needed. 
>> 
>> +            if bb.data.getVarFlag(key, "content", data) is None:
>> +                bb.data.setVar(key, None, data)
>> 
>> I rerun "time bitbake -p" with the two patches (see below, one is
>> setVarFlag.patch, another is the "??=" optimization patch) The
>> result is: 
>> 
>> real    0m27.049s
>> user    0m26.340s
>> sys     0m0.440s
>> 
>> The parsing time is a bit longer ( < 1 sec) than without the
>> following "setVarFlag.patch".
> 
> Patches look good to me other than the above. I also talked to Chris
> on irc on #oe earlier today and we agreed this is a good move for
> setVar bringing both into line although the whole way the datastore
> works could still be better.   
> 
> Could you send these patches through a pull request please and lets
> get them merged. 

OK, I will make a pull request after the above question got clear.

Thanks,
Dongxiao

> 
> Cheers,
> 
> Richard




More information about the poky mailing list