[yocto] [PATCH 3/4][Image Creator]Put extra requested fields into different cache files

Liping Ke liping.ke at intel.com
Thu May 12 18:50:30 PDT 2011


From: Liping Ke <liping.ke at intel.com>

We introduce extra required fields as well as namedtuple recipeinfo
class here. We also define the data retrieving methods for this
extra recipeinfo class. This factory methods can be easily extended
for furthing expanding. The extended Hob(Image Creator) class will
be used in the following patches.

Signed-off-by: Liping Ke <Liping.ke at intel.com>
---
 bitbake/lib/bb/cache.py       |    2 ++
 bitbake/lib/bb/extra_cache.py |   29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 bitbake/lib/bb/extra_cache.py

diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 82712ec..7dc518f 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -118,6 +118,8 @@ class RecipeRetrieve():
         return metadata.getVar(var, True) or ''
 
 class RecipeInfo(namedtuple('RecipeInfo', recipe_fields), RecipeRetrieve):
+    # Please note: fields are the static class member
+    # in namedtuple class RecipeInfo
     @classmethod
     def make_optional(cls, default=None, **kwargs):
         """Construct the namedtuple from the specified keyword arguments,
diff --git a/bitbake/lib/bb/extra_cache.py b/bitbake/lib/bb/extra_cache.py
new file mode 100644
index 0000000..11bb493
--- /dev/null
+++ b/bitbake/lib/bb/extra_cache.py
@@ -0,0 +1,29 @@
+from collections import namedtuple
+from bb.cache import RecipeRetrieve
+
+# This three fields are only requested by Image Creator
+# hob_recipe_fields, HobRecipeInfo Definition are both
+# introduced by Image Creator. If a user want to introduce
+# more fields, we need to to the same thing as below:
+# 1. introduce extra recipe fields
+# 2. Define your extra named tuple class
+# 3. Add extra data loading methods in the else part of
+#    the Factory Class.
+hob_extra_recipe_fields = (
+    'summary',
+    'license',
+    'section'
+)
+
+HobExtraRecipeInfo = namedtuple('HobExtraRecipeInfo', hob_extra_recipe_fields)
+    
+class ExtraRecipeInfoFactory(RecipeRetrieve):
+    @classmethod
+    def from_metadata(cls, extracaches, metadata):
+        if extracaches == "hob":
+            return HobExtraRecipeInfo(
+                summary          = cls.getvar('SUMMARY', metadata),
+                license          = cls.getvar('LICENSE', metadata),
+                section          = cls.getvar('SECTION', metadata),
+            )
+
-- 
1.7.0.4




More information about the yocto mailing list