bitbake: cache: Split Cache() into a NoCache() parent object
There are some cases we want to parse recipes without any cache setup or involvement. Split out the standalone functions into a NoCache variant which the Cache is based upon, setting the scene for further cleanup and restructuring. (Bitbake rev: 120b64ea6a0c0ecae7af0fd15d989934fa4f1c36) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
e79550ea87
commit
b176189df1
|
@ -265,12 +265,68 @@ def realfn2virtual(realfn, cls):
|
||||||
return realfn
|
return realfn
|
||||||
return "virtual:" + cls + ":" + realfn
|
return "virtual:" + cls + ":" + realfn
|
||||||
|
|
||||||
class Cache(object):
|
class NoCache(object):
|
||||||
|
|
||||||
|
def __init__(self, databuilder):
|
||||||
|
self.databuilder = databuilder
|
||||||
|
self.data = databuilder.data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def loadDataFull(cls, virtualfn, appends, cfgData):
|
||||||
|
"""
|
||||||
|
Return a complete set of data for fn.
|
||||||
|
To do this, we need to parse the file.
|
||||||
|
"""
|
||||||
|
|
||||||
|
(fn, virtual) = virtualfn2realfn(virtualfn)
|
||||||
|
|
||||||
|
logger.debug(1, "Parsing %s (full)", fn)
|
||||||
|
|
||||||
|
cfgData.setVar("__ONLYFINALISE", virtual or "default")
|
||||||
|
bb_data = cls.load_bbfile(fn, appends, cfgData)
|
||||||
|
return bb_data[virtual]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def load_bbfile(bbfile, appends, config):
|
||||||
|
"""
|
||||||
|
Load and parse one .bb build file
|
||||||
|
Return the data and whether parsing resulted in the file being skipped
|
||||||
|
"""
|
||||||
|
chdir_back = False
|
||||||
|
|
||||||
|
# expand tmpdir to include this topdir
|
||||||
|
config.setVar('TMPDIR', config.getVar('TMPDIR', True) or "")
|
||||||
|
bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
|
||||||
|
oldpath = os.path.abspath(os.getcwd())
|
||||||
|
bb.parse.cached_mtime_noerror(bbfile_loc)
|
||||||
|
bb_data = config.createCopy()
|
||||||
|
# The ConfHandler first looks if there is a TOPDIR and if not
|
||||||
|
# then it would call getcwd().
|
||||||
|
# Previously, we chdir()ed to bbfile_loc, called the handler
|
||||||
|
# and finally chdir()ed back, a couple of thousand times. We now
|
||||||
|
# just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
|
||||||
|
if not bb_data.getVar('TOPDIR', False):
|
||||||
|
chdir_back = True
|
||||||
|
bb_data.setVar('TOPDIR', bbfile_loc)
|
||||||
|
try:
|
||||||
|
if appends:
|
||||||
|
bb_data.setVar('__BBAPPEND', " ".join(appends))
|
||||||
|
bb_data = bb.parse.handle(bbfile, bb_data)
|
||||||
|
if chdir_back:
|
||||||
|
os.chdir(oldpath)
|
||||||
|
return bb_data
|
||||||
|
except:
|
||||||
|
if chdir_back:
|
||||||
|
os.chdir(oldpath)
|
||||||
|
raise
|
||||||
|
|
||||||
|
class Cache(NoCache):
|
||||||
"""
|
"""
|
||||||
BitBake Cache implementation
|
BitBake Cache implementation
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, databuilder, data_hash, caches_array):
|
def __init__(self, databuilder, data_hash, caches_array):
|
||||||
|
super().__init__(databuilder)
|
||||||
data = databuilder.data
|
data = databuilder.data
|
||||||
|
|
||||||
# Pass caches_array information into Cache Constructor
|
# Pass caches_array information into Cache Constructor
|
||||||
|
@ -375,21 +431,6 @@ class Cache(object):
|
||||||
len(self.depends_cache)),
|
len(self.depends_cache)),
|
||||||
self.data)
|
self.data)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def loadDataFull(cls, virtualfn, appends, cfgData):
|
|
||||||
"""
|
|
||||||
Return a complete set of data for fn.
|
|
||||||
To do this, we need to parse the file.
|
|
||||||
"""
|
|
||||||
|
|
||||||
(fn, virtual) = virtualfn2realfn(virtualfn)
|
|
||||||
|
|
||||||
logger.debug(1, "Parsing %s (full)", fn)
|
|
||||||
|
|
||||||
cfgData.setVar("__ONLYFINALISE", virtual or "default")
|
|
||||||
bb_data = cls.load_bbfile(fn, appends, cfgData)
|
|
||||||
return bb_data[virtual]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, filename, appends, configdata, caches_array):
|
def parse(cls, filename, appends, configdata, caches_array):
|
||||||
"""Parse the specified filename, returning the recipe information"""
|
"""Parse the specified filename, returning the recipe information"""
|
||||||
|
@ -648,42 +689,6 @@ class Cache(object):
|
||||||
info_array.append(cache_class(realfn, data))
|
info_array.append(cache_class(realfn, data))
|
||||||
self.add_info(file_name, info_array, cacheData, parsed)
|
self.add_info(file_name, info_array, cacheData, parsed)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def load_bbfile(bbfile, appends, config):
|
|
||||||
"""
|
|
||||||
Load and parse one .bb build file
|
|
||||||
Return the data and whether parsing resulted in the file being skipped
|
|
||||||
"""
|
|
||||||
chdir_back = False
|
|
||||||
|
|
||||||
from bb import parse
|
|
||||||
|
|
||||||
# expand tmpdir to include this topdir
|
|
||||||
config.setVar('TMPDIR', config.getVar('TMPDIR', True) or "")
|
|
||||||
bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
|
|
||||||
oldpath = os.path.abspath(os.getcwd())
|
|
||||||
parse.cached_mtime_noerror(bbfile_loc)
|
|
||||||
bb_data = config.createCopy()
|
|
||||||
# The ConfHandler first looks if there is a TOPDIR and if not
|
|
||||||
# then it would call getcwd().
|
|
||||||
# Previously, we chdir()ed to bbfile_loc, called the handler
|
|
||||||
# and finally chdir()ed back, a couple of thousand times. We now
|
|
||||||
# just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
|
|
||||||
if not bb_data.getVar('TOPDIR', False):
|
|
||||||
chdir_back = True
|
|
||||||
bb_data.setVar('TOPDIR', bbfile_loc)
|
|
||||||
try:
|
|
||||||
if appends:
|
|
||||||
bb_data.setVar('__BBAPPEND', " ".join(appends))
|
|
||||||
bb_data = parse.handle(bbfile, bb_data)
|
|
||||||
if chdir_back:
|
|
||||||
os.chdir(oldpath)
|
|
||||||
return bb_data
|
|
||||||
except:
|
|
||||||
if chdir_back:
|
|
||||||
os.chdir(oldpath)
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def init(cooker):
|
def init(cooker):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue