mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
bitbake: data_smart: Add setVarFilter function to implement variabl filtering
Adds a new setVarFilter() API to the data store allowing filters to be
applied to variables.
Note that filters are applied to the non-override part of the variable name
so a filter set against RDEPENDS would apply against RDEPENDS:${PN} and
friends.
The filter function is applied before returning the final variable value.
(Bitbake rev: a9471c10d1de039474ddb4738abd286b928d82f4)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -24,6 +24,7 @@ from collections.abc import MutableMapping
|
||||
import logging
|
||||
import hashlib
|
||||
import bb, bb.codeparser
|
||||
import bb.filter
|
||||
from bb import utils
|
||||
from bb.COW import COWDictBase
|
||||
|
||||
@@ -427,6 +428,7 @@ class DataSmart(MutableMapping):
|
||||
|
||||
self.inchistory = IncludeHistory()
|
||||
self.varhistory = VariableHistory(self)
|
||||
self.filters = {}
|
||||
self._tracking = False
|
||||
self._var_renames = {}
|
||||
self._var_renames.update(bitbake_renamed_vars)
|
||||
@@ -678,6 +680,7 @@ class DataSmart(MutableMapping):
|
||||
|
||||
srcflags = self.getVarFlags(key, False, True) or {}
|
||||
for i in srcflags:
|
||||
|
||||
if i not in (__setvar_keyword__):
|
||||
continue
|
||||
src = srcflags[i]
|
||||
@@ -895,6 +898,12 @@ class DataSmart(MutableMapping):
|
||||
if expand:
|
||||
value = parser.value
|
||||
|
||||
if value and expand and flag == "_content":
|
||||
basevar = var.split(":")[0]
|
||||
if basevar in self.filters:
|
||||
value = bb.filter.apply_filters(value, [self.filters[basevar],])
|
||||
parser.value = value
|
||||
|
||||
if parser:
|
||||
self.expand_cache[cachename] = parser
|
||||
|
||||
@@ -1000,6 +1009,7 @@ class DataSmart(MutableMapping):
|
||||
data.varhistory = self.varhistory.copy()
|
||||
data.varhistory.dataroot = data
|
||||
data.inchistory = self.inchistory.copy()
|
||||
data.filters = self.filters.copy()
|
||||
|
||||
data._tracking = self._tracking
|
||||
data._var_renames = self._var_renames
|
||||
@@ -1028,6 +1038,15 @@ class DataSmart(MutableMapping):
|
||||
if referrervalue and isinstance(referrervalue, str) and ref in referrervalue:
|
||||
self.setVar(key, referrervalue.replace(ref, value))
|
||||
|
||||
def setVarFilter(self, var, filter):
|
||||
if filter:
|
||||
self.filters[var] = filter
|
||||
else:
|
||||
try:
|
||||
del self.filters[var]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def localkeys(self):
|
||||
for key in self.dict:
|
||||
if key not in ['_data']:
|
||||
|
||||
Reference in New Issue
Block a user