diff mbox series

[10/17] utils: Add bb.utils.have_layer() to simplify metadata layer checks

Message ID 20261130152847.3472849-10-richard.purdie@linuxfoundation.org
State New
Headers show
Series [01/17] uihelper: Fix exception when TaskStarted event handler breaks | expand

Commit Message

Richard Purdie Nov. 30, 2026, 3:28 p.m. UTC
Rather than repeat this pattern in many layers, have a simple helper
function in case we ever need to change internals and to make the
code clearer/simpler.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/utils.py | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 94e27dcaa52..e4e50072135 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1913,6 +1913,10 @@  def get_file_layer(filename, d):
     """
     return get_file_layer_from_layerdata(filename, d.getVar('layerdata', False) or {})
 
+def have_layer(layer, d, trueval=True, falseval=False):
+   if layer in d.getVar('layerdata', False):
+       return trueval
+   return falseval
 
 # Constant taken from http://linux.die.net/include/linux/prctl.h
 PR_SET_PDEATHSIG = 1