Skip to contentSkip to conversation

classes/machine-overrides-extended.bbclass: add

PATCH In review Trevor Woerner 2 participants 3 messages Jul 21, 2017 – Jul 28, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes/machine-overrides-extended.bbclass: add

Copy this class from meta-freescale so all BSPs can use it.

This class makes it easy for a BSP to specify multiple sets of configurations for a given MACHINE. In some cases there are multiple choices for the user. For example: for the kernel, the user could choose either the vendor kernel or the upstream kernel. However, sometimes these decisions are "locked" together:
i.e. if you want to use the vendor's binary blob for (say) graphics, then you have to use their vendor kernel as well. It's not possible for a user to choose, say, the graphics binary blob but want to use the upstream kernel too. Therefore the BSP ends up with "sets" of configurations which need to be taken collectively instead of piecemeal.

In the example of meta-freescale, if the user does nothing special, they get the vendor options. If they add the following line to their configuration, they get the upstream pieces:

MACHINEOVERRIDES .= ":use-mainline-bsp"

---
 meta/classes/machine-overrides-extender.bbclass | 48 +++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 meta/classes/machine-overrides-extender.bbclass
meta/classes/machine-overrides-extender.bbclass new file +48 -0
new file mode 100644
index 0000000000..f333a0fcb7
@@ -0,0 +1,48 @@
+# -*- python -*-
+# Automatically set extend the MACHINEOVERRIDES
+#
+# This allow to grouping of different settings for similar platforms.
+#
+# To indicate that a SoC contains following set of overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_soc = "group1:group2"
+#
+# However to indicate that an override replaces a set of other
+# overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_FILTER_OUT_override = "group1 group2"
+#
+# Copyright 2016-2017 (C) O.S. Systems Software LTDA.
+
+def machine_overrides_extender(d):
+    machine_overrides = (d.getVar('MACHINEOVERRIDES', True) or '').split(':')
+
+    # Gather the list of overrides to filter out
+    machine_overrides_filter_out = []
+    for override in machine_overrides:
+        machine_overrides_filter_out += (d.getVar('MACHINEOVERRIDES_EXTENDER_FILTER_OUT_%s' % override, True) or '').split()
+
+    # Drop any overrides of filter_out prior extending
+    machine_overrides = [o for o in machine_overrides if o not in machine_overrides_filter_out]
+
+    for override in machine_overrides:
+        extender = d.getVar('MACHINEOVERRIDES_EXTENDER_%s' % override, True)
+
+        if extender:
+            extender = extender.split(':')
+
+            # Drop any extension if in filter_out
+            extender = [e for e in extender if e not in machine_overrides_filter_out]
+
+            extender.reverse()
+            if not set(extender).issubset(set(machine_overrides)):
+                index = machine_overrides.index(override)
+                for e in extender:
+                    machine_overrides.insert(index, e)
+    d.setVar('MACHINEOVERRIDES', ':'.join(machine_overrides))
+
+python machine_overrides_extender_handler() {
+    machine_overrides_extender(e.data)
+}
+machine_overrides_extender_handler[eventmask] = "bb.event.ConfigParsed"
+addhandler machine_overrides_extender_handler
Signature · 1 line
2.13.0
#1 lore raw

I haven't seen any conclusions on the Architecture list here:

http://lists.openembedded.org/pipermail/openembedded-architecture/2017-July/000662.html

Quoted 86 lines · Trevor Woerner

Copy this class from meta-freescale so all BSPs can use it.

This class makes it easy for a BSP to specify multiple sets of configurations for a given MACHINE. In some cases there are multiple choices for the user. For example: for the kernel, the user could choose either the vendor kernel or the upstream kernel. However, sometimes these decisions are "locked" together:
i.e. if you want to use the vendor's binary blob for (say) graphics, then you have to use their vendor kernel as well. It's not possible for a user to choose, say, the graphics binary blob but want to use the upstream kernel too. Therefore the BSP ends up with "sets" of configurations which need to be taken collectively instead of piecemeal.

In the example of meta-freescale, if the user does nothing special, they get the vendor options. If they add the following line to their configuration, they get the upstream pieces:

MACHINEOVERRIDES .= ":use-mainline-bsp"

---
 meta/classes/machine-overrides-extender.bbclass | 48 +++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 meta/classes/machine-overrides-extender.bbclass
meta/classes/machine-overrides-extender.bbclass new file +48 -0
new file mode 100644
index 0000000000..f333a0fcb7
@@ -0,0 +1,48 @@
+# -*- python -*-
+# Automatically set extend the MACHINEOVERRIDES
+#
+# This allow to grouping of different settings for similar platforms.
+#
+# To indicate that a SoC contains following set of overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_soc = "group1:group2"
+#
+# However to indicate that an override replaces a set of other
+# overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_FILTER_OUT_override = "group1 group2"
+#
+# Copyright 2016-2017 (C) O.S. Systems Software LTDA.
+
+def machine_overrides_extender(d):
+    machine_overrides = (d.getVar('MACHINEOVERRIDES', True) or '').split(':')
+
+    # Gather the list of overrides to filter out
+    machine_overrides_filter_out = []
+    for override in machine_overrides:
+        machine_overrides_filter_out += (d.getVar('MACHINEOVERRIDES_EXTENDER_FILTER_OUT_%s' % override, True) or '').split()
+
+    # Drop any overrides of filter_out prior extending
+    machine_overrides = [o for o in machine_overrides if o not in machine_overrides_filter_out]
+
+    for override in machine_overrides:
+        extender = d.getVar('MACHINEOVERRIDES_EXTENDER_%s' % override, True)
+
+        if extender:
+            extender = extender.split(':')
+
+            # Drop any extension if in filter_out
+            extender = [e for e in extender if e not in machine_overrides_filter_out]
+
+            extender.reverse()
+            if not set(extender).issubset(set(machine_overrides)):
+                index = machine_overrides.index(override)
+                for e in extender:
+                    machine_overrides.insert(index, e)
+    d.setVar('MACHINEOVERRIDES', ':'.join(machine_overrides))
+
+python machine_overrides_extender_handler() {
+    machine_overrides_extender(e.data)
+}
+machine_overrides_extender_handler[eventmask] = "bb.event.ConfigParsed"
+addhandler machine_overrides_extender_handler
Signature · 7 lines
2.13.0

-- 
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
#2 lore raw
In reply to Trevor Woerner

ping? comments?

Quoted 81 lines · Trevor Woerner

Copy this class from meta-freescale so all BSPs can use it.

This class makes it easy for a BSP to specify multiple sets of configurations for a given MACHINE. In some cases there are multiple choices for the user. For example: for the kernel, the user could choose either the vendor kernel or the upstream kernel. However, sometimes these decisions are "locked" together:
i.e. if you want to use the vendor's binary blob for (say) graphics, then you have to use their vendor kernel as well. It's not possible for a user to choose, say, the graphics binary blob but want to use the upstream kernel too. Therefore the BSP ends up with "sets" of configurations which need to be taken collectively instead of piecemeal.

In the example of meta-freescale, if the user does nothing special, they get the vendor options. If they add the following line to their configuration, they get the upstream pieces:

MACHINEOVERRIDES .= ":use-mainline-bsp"

---
 meta/classes/machine-overrides-extender.bbclass | 48 +++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 meta/classes/machine-overrides-extender.bbclass
meta/classes/machine-overrides-extender.bbclass new file +48 -1
new file mode 100644
index 0000000000..f333a0fcb7
@@ -0,0 +1,48 @@
+# -*- python -*-
+# Automatically set extend the MACHINEOVERRIDES
+#
+# This allow to grouping of different settings for similar platforms.
+#
+# To indicate that a SoC contains following set of overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_soc = "group1:group2"
+#
+# However to indicate that an override replaces a set of other
+# overrides, you can use:
+#
+# MACHINEOVERRIDES_EXTENDER_FILTER_OUT_override = "group1 group2"
+#
+# Copyright 2016-2017 (C) O.S. Systems Software LTDA.
+
+def machine_overrides_extender(d):
+    machine_overrides = (d.getVar('MACHINEOVERRIDES', True) or '').split(':')
+
+    # Gather the list of overrides to filter out
+    machine_overrides_filter_out = []
+    for override in machine_overrides:
+        machine_overrides_filter_out += (d.getVar('MACHINEOVERRIDES_EXTENDER_FILTER_OUT_%s' % override, True) or '').split()
+
+    # Drop any overrides of filter_out prior extending
+    machine_overrides = [o for o in machine_overrides if o not in machine_overrides_filter_out]
+
+    for override in machine_overrides:
+        extender = d.getVar('MACHINEOVERRIDES_EXTENDER_%s' % override, True)
+
+        if extender:
+            extender = extender.split(':')
+
+            # Drop any extension if in filter_out
+            extender = [e for e in extender if e not in machine_overrides_filter_out]
+
+            extender.reverse()
+            if not set(extender).issubset(set(machine_overrides)):
+                index = machine_overrides.index(override)
+                for e in extender:
+                    machine_overrides.insert(index, e)
+    d.setVar('MACHINEOVERRIDES', ':'.join(machine_overrides))
+
+python machine_overrides_extender_handler() {
+    machine_overrides_extender(e.data)
+}
+machine_overrides_extender_handler[eventmask] = "bb.event.ConfigParsed"
+addhandler machine_overrides_extender_handler
--

2.13.0