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

Submitted by Paul Eggleton on Aug. 30, 2016, 4:36 a.m. | Patch ID: 130545

Details

Message ID 84157c8e45d40788c11c3ef5955825e3b5b20112.1472531645.git.paul.eggleton@linux.intel.com
State New
Headers show

Commit Message

Paul Eggleton Aug. 30, 2016, 4:36 a.m.
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@linux.intel.com>
---
 lib/bb/tinfoil.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Patch hide | download patch | download mbox

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()