[bitbake-devel] [PATCH 3/3] tinfoil: add a parse_recipe_file function

Paul Eggleton paul.eggleton at linux.intel.com
Tue Aug 30 04:36:38 UTC 2016


Parsing a recipe is such a common task for tinfoil-using scripts, and is
a little awkward to do properly, so we should add an API function to do
it. This should also isolate scripts a little from future changes to the
internal code.

Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
 lib/bb/tinfoil.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 441be2c..793565f 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -90,6 +90,27 @@ class Tinfoil:
             else:
                 self.parseRecipes()
 
+    def parse_recipe_file(self, fn, appends=True, appendlist=None):
+        """
+        Parse the specified recipe file (with or without bbappends)
+        and return a datastore object representing the environment
+        for the recipe.
+        """
+        if appends and appendlist == []:
+            appends = False
+        parser = bb.cache.NoCache(self.cooker.databuilder)
+        if appends:
+            if appendlist:
+                appendfiles = appendlist
+            else:
+                if not hasattr(self.cooker, 'collection'):
+                    raise Exception('You must call tinfoil.prepare() with config_only=False in order to get bbappends')
+                appendfiles = self.cooker.collection.get_file_appends(fn)
+        else:
+            appendfiles = None
+        envdata = parser.loadDataFull(fn, appendfiles)
+        return envdata
+
     def shutdown(self):
         self.cooker.shutdown(force=True)
         self.cooker.post_serve()
-- 
2.5.5




More information about the bitbake-devel mailing list