diff mbox series

[v2,1/2] tinfoil: add new "finalizeData" API

Message ID 20241114221725.3826753-1-yoann.congal@smile.fr
State Accepted, archived
Commit 63db64ca98564420a378f14c337074ae06da8c63
Headers show
Series [v2,1/2] tinfoil: add new "finalizeData" API | expand

Commit Message

Yoann Congal Nov. 14, 2024, 10:17 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

Create a new tinfoil API "finalizeData" which does key expantion and
runs the anonymous functions to allow bitbake-getvar to have the same
output as "bitbake -e".

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
v1->v2: No change
---
 lib/bb/command.py | 8 ++++++++
 lib/bb/tinfoil.py | 6 ++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/command.py b/lib/bb/command.py
index 695277f1e..a63427660 100644
--- a/lib/bb/command.py
+++ b/lib/bb/command.py
@@ -24,6 +24,7 @@  import io
 import bb.event
 import bb.cooker
 import bb.remotedata
+import bb.parse
 
 class DataStoreConnectionHandle(object):
     def __init__(self, dsindex=0):
@@ -582,6 +583,13 @@  class CommandsSync:
         return DataStoreConnectionHandle(idx)
     parseRecipeFile.readonly = True
 
+    def finalizeData(self, command, params):
+        newdata = command.cooker.data.createCopy()
+        bb.data.expandKeys(newdata)
+        bb.parse.ast.runAnonFuncs(newdata)
+        idx = command.remotedatastores.store(newdata)
+        return DataStoreConnectionHandle(idx)
+
 class CommandsAsync:
     """
     A class of asynchronous commands
diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index dcd3910cc..0e937fba3 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -633,6 +633,12 @@  class Tinfoil:
         fn = self.get_recipe_file(pn)
         return self.parse_recipe_file(fn)
 
+    def finalizeData(self):
+        """
+        Run anonymous functions and expand keys
+        """
+        return self._reconvert_type(self.run_command('finalizeData'), 'DataStoreConnectionHandle')
+
     def parse_recipe_file(self, fn, appends=True, appendlist=None, config_data=None):
         """
         Parse the specified recipe file (with or without bbappends)