Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] u-boot: Add UBOOT_LOCALVERSION_AUTO support
@ 2020-03-31 17:46 Otavio Salvador
  2020-03-31 18:07 ` [OE-core] " Denys Dmytriyenko
  0 siblings, 1 reply; 5+ messages in thread
From: Otavio Salvador @ 2020-03-31 17:46 UTC (permalink / raw)
  To: OpenEmbedded Core Mailing List; +Cc: Tom Rini, Stefano Babic, Otavio Salvador

Add the Git revision used for the build. It is very useful especially when
using custom or vendor U-Boot forks so we can map a binary to a specific
source revision. Valid values are "0" or "1".

This is based on a class which has been in use in `meta-freescale` BSP
for years and has been very useful especially for custom U-Boot releases
as it allow we to know the exact Git revision used for the binary.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

 meta/recipes-bsp/u-boot/u-boot.inc | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/meta/recipes-bsp/u-boot/u-boot.inc b/meta/recipes-bsp/u-boot/u-boot.inc
index b13db224732..39d35500e11 100644
--- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc
@@ -24,6 +24,11 @@ PACKAGECONFIG[openssl] = ",,openssl-native"
 # file already exists it will not be overwritten.
 UBOOT_LOCALVERSION ?= ""
 
+# Add the Git revision used for the build. It is very useful especially when
+# using custom or vendor U-Boot forks so we can map a binary to a specific
+# source revision. Valid values are "0" or "1".
+UBOOT_LOCALVERSION_AUTO ?= "0"
+
 # Some versions of u-boot use .bin and others use .img.  By default use .bin
 # but enable individual recipes to change this value.
 UBOOT_SUFFIX ??= "bin"
@@ -84,6 +89,19 @@ do_configure () {
             oe_runmake -C ${S} O=${B} oldconfig
         fi
         merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
+
+        if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]; then
+            if [ "${UBOOT_LOCALVERSION_AUTO}" = "1" ]; then
+                # Add GIT revision to the local version
+                head=`cd ${S} ; git rev-parse --verify --short HEAD 2> /dev/null`
+                printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${S}/.scmversion
+                printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${B}/.scmversion
+            else
+                printf "%s" "${UBOOT_LOCALVERSION}" > ${S}/.scmversion
+                printf "%s" "${UBOOT_LOCALVERSION}" > ${B}/.scmversion
+            fi
+        fi
+
         cml1_do_configure
     else
         DEVTOOL_DISABLE_MENUCONFIG=true
@@ -99,12 +117,6 @@ do_compile () {
 	unset CFLAGS
 	unset CPPFLAGS
 
-	if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]
-	then
-		echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion
-		echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion
-	fi
-
     if [ -n "${UBOOT_CONFIG}" ]
     then
         unset i j k
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-31 19:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-31 17:46 [PATCH] u-boot: Add UBOOT_LOCALVERSION_AUTO support Otavio Salvador
2020-03-31 18:07 ` [OE-core] " Denys Dmytriyenko
2020-03-31 18:18   ` Otavio Salvador
2020-03-31 18:47     ` Denys Dmytriyenko
2020-03-31 19:20       ` Otavio Salvador

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox