All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Lock <josh@linux.intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH 1/1] cache|cooker|parse: switch __depends from a set to a dict
Date: Wed,  7 Sep 2011 14:27:01 -0700	[thread overview]
Message-ID: <0238d6b802f0620dcda8c8997a1b2988b71408dc.1315406971.git.josh@linux.intel.com> (raw)
In-Reply-To: <cover.1315406971.git.josh@linux.intel.com>
In-Reply-To: <cover.1315406971.git.josh@linux.intel.com>

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@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




  reply	other threads:[~2011-09-07 21:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-07 21:27 [RFC PATCH 0/1] Don't use set() for datastore variables Joshua Lock
2011-09-07 21:27 ` Joshua Lock [this message]
2011-09-12 20:42 ` Joshua Lock
2011-09-13 12:55   ` Bernhard Reutner-Fischer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0238d6b802f0620dcda8c8997a1b2988b71408dc.1315406971.git.josh@linux.intel.com \
    --to=josh@linux.intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.