Skip to contentSkip to conversation

u-boot.inc: Refactor do_* steps into functions that can be overridden

PATCH New Ryan Eatmon 1 participant 1 message Aug 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 u-boot.inc: Refactor do_* steps into functions that can be overridden

The looping logic for handling (and not handling) UBOOT_CONFIG has led to the various do_* functions to be large and unwieldy. In order to modify one of the functional blocks inside of a loop (or in the else condition) means you either have to replace the function entirely, or append the function and undo something it did and then do what you need for your change.

This refactor breaks out all of the inner loops and else clauses into new functions that themselves can be overridden without needing to worry about the bulk of the looping logic.

It should not break any existing recipes doing prepends, appends, or overrides. None of the functional blocks were changed, just refactored out into new functions.

Backport from master: https://git.openembedded.org/openembedded-core/commit/?id=937bcc229502fcc154cc676b4fcc93c561873def

---
 meta/recipes-bsp/u-boot/u-boot-configure.inc |  36 ++-
 meta/recipes-bsp/u-boot/u-boot.inc           | 281 ++++++++++++-------
 2 files changed, 208 insertions(+), 109 deletions(-)
meta/recipes-bsp/u-boot/u-boot-configure.inc +24 -12
index 378d675364..a15511f8b2 100644
@@ -18,23 +18,35 @@ do_configure () {
             for type in ${UBOOT_CONFIG}; do
                 j=$(expr $j + 1);
                 if [ $j -eq $i ]; then
-                    oe_runmake -C ${S} O=${B}/${config} ${config}
-                    if [ -n "${@' '.join(find_cfgs(d))}" ]; then
-                        merge_config.sh -m -O ${B}/${config} ${B}/${config}/.config ${@" ".join(find_cfgs(d))}
-                        oe_runmake -C ${S} O=${B}/${config} oldconfig
-                    fi
+                    uboot_configure_config $config $type
                 fi
             done
             unset j
         done
         unset i
     else
-        if [ -n "${UBOOT_MACHINE}" ]; then
-            oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE}
-        else
-            oe_runmake -C ${S} O=${B} oldconfig
-        fi
-        merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
-        cml1_do_configure
+        uboot_configure
     fi
 }
+
+uboot_configure_config () {
+    config=$1
+    type=$2
+
+    oe_runmake -C ${S} O=${B}/${config} ${config}
+    if [ -n "${@' '.join(find_cfgs(d))}" ]; then
+        merge_config.sh -m -O ${B}/${config} ${B}/${config}/.config ${@" ".join(find_cfgs(d))}
+        oe_runmake -C ${S} O=${B}/${config} oldconfig
+    fi
+}
+
+uboot_configure () {
+    if [ -n "${UBOOT_MACHINE}" ]; then
+        oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE}
+    else
+        oe_runmake -C ${S} O=${B} oldconfig
+    fi
+    merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
+    cml1_do_configure
+}
+
meta/recipes-bsp/u-boot/u-boot.inc +184 -97

387 lines not on this page · raw message

Signature · 1 line
2.17.1