[bitbake-devel] [PATCH 1/1] cache|cooker|parse: switch __depends from a set to a dict
Joshua Lock
josh at linux.intel.com
Wed Sep 7 21:27:01 UTC 2011
The set container cannot be marshalled by Python's xmlrpclib meaning that
we cannot interact with the __depends variable via the [get|set]Variable
command API.
This patch changes the code to use a dict instead of a set to store the
__depends mapping of filename to mtime.
Signed-off-by: Joshua Lock <josh at linux.intel.com>
---
lib/bb/cache.py | 11 ++++++-----
lib/bb/cooker.py | 8 ++++----
lib/bb/parse/__init__.py | 4 ++--
lib/bb/ui/hob.py | 8 ++++----
4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/lib/bb/cache.py b/lib/bb/cache.py
index d495f9e..ba77f50 100644
--- a/lib/bb/cache.py
+++ b/lib/bb/cache.py
@@ -43,7 +43,7 @@ except ImportError:
logger.info("Importing cPickle failed. "
"Falling back to a very slow implementation.")
-__cache_version__ = "142"
+__cache_version__ = "143"
def getCacheFile(path, filename):
return os.path.join(path, filename)
@@ -282,7 +282,7 @@ class Cache(object):
newest_mtime = 0
deps = bb.data.getVar("__base_depends", data)
- old_mtimes = [old_mtime for _, old_mtime in deps]
+ old_mtimes = deps.values()
old_mtimes.append(newest_mtime)
newest_mtime = max(old_mtimes)
@@ -406,12 +406,12 @@ class Cache(object):
"""Parse the specified filename, returning the recipe information"""
infos = []
datastores = cls.load_bbfile(filename, appends, configdata)
- depends = set()
+ depends = {}
for variant, data in sorted(datastores.iteritems(),
key=lambda i: i[0],
reverse=True):
virtualfn = cls.realfn2virtual(filename, variant)
- depends |= (data.getVar("__depends", False) or set())
+ depends.update(data.getVar("__depends", False) or {})
if depends and not variant:
data.setVar("__depends", depends)
@@ -512,8 +512,9 @@ class Cache(object):
# Check dependencies are still valid
depends = info_array[0].file_depends
if depends:
- for f, old_mtime in depends:
+ for f in depends:
fmtime = bb.parse.cached_mtime_noerror(f)
+ old_mtime = depends[f]
# Check if file still exists
if old_mtime != 0 and fmtime == 0:
logger.debug(2, "Cache: %s's dependency %s was removed",
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index a0fcc15..e2bbb48 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -627,12 +627,12 @@ class BBCooker:
# Generate a list of parsed configuration files by searching the files
# listed in the __depends and __base_depends variables with a .conf suffix.
conffiles = []
- dep_files = bb.data.getVar('__depends', self.configuration.data) or set()
- dep_files.union(bb.data.getVar('__base_depends', self.configuration.data) or set())
+ dep_files = bb.data.getVar('__depends', self.configuration.data) or {}
+ dep_files.update(bb.data.getVar('__base_depends', self.configuration.data) or {})
for f in dep_files:
- if f[0].endswith(".conf"):
- conffiles.append(f[0])
+ if f.endswith(".conf"):
+ conffiles.append(f)
_, conf, conffile = path.rpartition("conf/")
match = os.path.join(conf, conffile)
diff --git a/lib/bb/parse/__init__.py b/lib/bb/parse/__init__.py
index eee8d9c..31a35f9 100644
--- a/lib/bb/parse/__init__.py
+++ b/lib/bb/parse/__init__.py
@@ -62,8 +62,8 @@ def update_mtime(f):
def mark_dependency(d, f):
if f.startswith('./'):
f = "%s/%s" % (os.getcwd(), f[2:])
- deps = bb.data.getVar('__depends', d) or set()
- deps.update([(f, cached_mtime(f))])
+ deps = bb.data.getVar('__depends', d) or {}
+ deps[f] = cached_mtime(f)
bb.data.setVar('__depends', deps, d)
def supports(fn, data):
diff --git a/lib/bb/ui/hob.py b/lib/bb/ui/hob.py
index 84df37d..39731fa 100644
--- a/lib/bb/ui/hob.py
+++ b/lib/bb/ui/hob.py
@@ -994,12 +994,12 @@ def main (server, eventHandler):
# We hope to adjust this long term as tracked in Yocto Bugzilla #1441
# http://bugzilla.pokylinux.org/show_bug.cgi?id=1441
reqfiles = 0
- dep_files = server.runCommand(["getVariable", "__depends"]) or set()
- dep_files.union(server.runCommand(["getVariable", "__base_depends"]) or set())
+ dep_files = server.runCommand(["getVariable", "__depends"]) or {}
+ dep_files.update(server.runCommand(["getVariable", "__base_depends"]) or {})
for f in dep_files:
- if f[0].endswith("hob-pre.conf"):
+ if f.endswith("hob-pre.conf"):
reqfiles = reqfiles + 1
- elif f[0].endswith("hob-post.conf"):
+ elif f.endswith("hob-post.conf"):
reqfiles = reqfiles + 1
if reqfiles == 2:
break
--
1.7.6
More information about the bitbake-devel
mailing list