[gnome-continuous-yocto/gnomeostree-3.28-rocko: 4190/8267] wic: misc.py: add parameter 'cache' to get_bitbake_vars



commit 7d5f44b455ec7f6d697454ab4bf64f367463bf0e
Author: Ed Bartosh <ed bartosh linux intel com>
Date:   Thu Jan 19 16:18:28 2017 +0200

    wic: misc.py: add parameter 'cache' to get_bitbake_vars
    
    This parameter will be used to allow or prevent variable caching.
    
    For example, we don't want to cache value of RECIPE_SYSROOT_NATIVE
    wic-tools variable as we may decide to rebuild wic-tools.
    
    (From OE-Core rev: e4269fdb4c3ef06b97df063f8586f74986215c83)
    
    Signed-off-by: Ed Bartosh <ed bartosh linux intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 scripts/lib/wic/utils/oe/misc.py |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py
index 445109a..3737c4b 100644
--- a/scripts/lib/wic/utils/oe/misc.py
+++ b/scripts/lib/wic/utils/oe/misc.py
@@ -160,7 +160,7 @@ class BitbakeVars(defaultdict):
         key, val = match.groups()
         self[image][key] = val.strip('"')
 
-    def get_var(self, var, image=None):
+    def get_var(self, var, image=None, cache=True):
         """
         Get bitbake variable from 'bitbake -e' output or from .env file.
         This is a lazy method, i.e. it runs bitbake or parses file only when
@@ -202,21 +202,26 @@ class BitbakeVars(defaultdict):
                     self._parse_line(line, image)
 
             # Make first image a default set of variables
-            images = [key for key in self if key]
-            if len(images) == 1:
-                self[None] = self[image]
+            if cache:
+                images = [key for key in self if key]
+                if len(images) == 1:
+                    self[None] = self[image]
 
-        return self[image].get(var)
+        result = self[image].get(var)
+        if not cache:
+            self.pop(image, None)
+
+        return result
 
 # Create BB_VARS singleton
 BB_VARS = BitbakeVars()
 
-def get_bitbake_var(var, image=None):
+def get_bitbake_var(var, image=None, cache=True):
     """
     Provide old get_bitbake_var API by wrapping
     get_var method of BB_VARS singleton.
     """
-    return BB_VARS.get_var(var, image)
+    return BB_VARS.get_var(var, image, cache)
 
 def parse_sourceparams(sourceparams):
     """


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]