[v3,1/7] u-boot: make KCFLAGS and HOSTCFLAGS configurable

Message ID 20230317132106.1111258-2-felix.moessbauer@siemens.com
State Superseded, archived
Headers show
Series Add BSP for StarFiveTech VisionFive2 Risc-V board | expand

Commit Message

MOESSBAUER, Felix March 17, 2023, 1:21 p.m. UTC
For more complex u-boot configurations, custom compiler flags are
required to e.g. inject more include paths or set the bits per long.
This patch adds the bitbake variables KCFLAGS and HOSTCFLAGS which are
forwarded and exported in the rules file.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/recipes-bsp/u-boot/files/debian/rules.tmpl | 5 ++++-
 meta/recipes-bsp/u-boot/u-boot-custom.inc       | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Jan Kiszka March 17, 2023, 2:42 p.m. UTC | #1
On 17.03.23 14:21, Felix Moessbauer wrote:
> For more complex u-boot configurations, custom compiler flags are
> required to e.g. inject more include paths or set the bits per long.
> This patch adds the bitbake variables KCFLAGS and HOSTCFLAGS which are
> forwarded and exported in the rules file.
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  meta/recipes-bsp/u-boot/files/debian/rules.tmpl | 5 ++++-
>  meta/recipes-bsp/u-boot/u-boot-custom.inc       | 5 ++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-bsp/u-boot/files/debian/rules.tmpl b/meta/recipes-bsp/u-boot/files/debian/rules.tmpl
> index 806b01fe..a29ec9b1 100755
> --- a/meta/recipes-bsp/u-boot/files/debian/rules.tmpl
> +++ b/meta/recipes-bsp/u-boot/files/debian/rules.tmpl
> @@ -3,7 +3,7 @@
>  # Debian rules for custom U-Boot build
>  #
>  # This software is a part of ISAR.
> -# Copyright (c) Siemens AG, 2018-2021
> +# Copyright (c) Siemens AG, 2018-2023
>  #
>  # SPDX-License-Identifier: MIT
>  
> @@ -12,6 +12,9 @@ export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
>  SET_CROSS_BUILD_TOOLS=CROSS_BUILD_TOOLS=y
>  endif
>  
> +export KCFLAGS=${KCFLAGS}
> +export HOSTCFLAGS=${HOSTCFLAGS}
> +
>  override_dh_auto_build:
>  	$(MAKE) $(PARALLEL_MAKE) ${U_BOOT_CONFIG}
>  	$(MAKE) $(PARALLEL_MAKE) ${U_BOOT_BIN}
> diff --git a/meta/recipes-bsp/u-boot/u-boot-custom.inc b/meta/recipes-bsp/u-boot/u-boot-custom.inc
> index 876eb361..1e9744b1 100644
> --- a/meta/recipes-bsp/u-boot/u-boot-custom.inc
> +++ b/meta/recipes-bsp/u-boot/u-boot-custom.inc
> @@ -26,8 +26,11 @@ python() {
>  
>  DEBIAN_BUILD_DEPENDS ?= "bc, bison, flex, device-tree-compiler, git"
>  
> +KCFLAGS ?= ""
> +HOSTCFLAGS ?= ""

I buy that we may lack some settings to transfer debian vars for
building u-boot host tools. But KCFLAGS, specficially to set
BITS_PER_LONG which is already set by
u-boot/arch/riscv/include/asm/types.h, that looks like a vendor u-boot
tree bug.

Jan

> +
>  TEMPLATE_FILES = "debian/control.tmpl debian/rules.tmpl"
> -TEMPLATE_VARS += "MACHINE DEBIAN_BUILD_DEPENDS U_BOOT_CONFIG U_BOOT_BIN"
> +TEMPLATE_VARS += "MACHINE DEBIAN_BUILD_DEPENDS U_BOOT_CONFIG U_BOOT_BIN KCFLAGS HOSTCFLAGS"
>  
>  U_BOOT_TOOLS_PACKAGE ?= "0"
>  U_BOOT_CONFIG_PACKAGE ?= "0"

Patch

diff --git a/meta/recipes-bsp/u-boot/files/debian/rules.tmpl b/meta/recipes-bsp/u-boot/files/debian/rules.tmpl
index 806b01fe..a29ec9b1 100755
--- a/meta/recipes-bsp/u-boot/files/debian/rules.tmpl
+++ b/meta/recipes-bsp/u-boot/files/debian/rules.tmpl
@@ -3,7 +3,7 @@ 
 # Debian rules for custom U-Boot build
 #
 # This software is a part of ISAR.
-# Copyright (c) Siemens AG, 2018-2021
+# Copyright (c) Siemens AG, 2018-2023
 #
 # SPDX-License-Identifier: MIT
 
@@ -12,6 +12,9 @@  export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
 SET_CROSS_BUILD_TOOLS=CROSS_BUILD_TOOLS=y
 endif
 
+export KCFLAGS=${KCFLAGS}
+export HOSTCFLAGS=${HOSTCFLAGS}
+
 override_dh_auto_build:
 	$(MAKE) $(PARALLEL_MAKE) ${U_BOOT_CONFIG}
 	$(MAKE) $(PARALLEL_MAKE) ${U_BOOT_BIN}
diff --git a/meta/recipes-bsp/u-boot/u-boot-custom.inc b/meta/recipes-bsp/u-boot/u-boot-custom.inc
index 876eb361..1e9744b1 100644
--- a/meta/recipes-bsp/u-boot/u-boot-custom.inc
+++ b/meta/recipes-bsp/u-boot/u-boot-custom.inc
@@ -26,8 +26,11 @@  python() {
 
 DEBIAN_BUILD_DEPENDS ?= "bc, bison, flex, device-tree-compiler, git"
 
+KCFLAGS ?= ""
+HOSTCFLAGS ?= ""
+
 TEMPLATE_FILES = "debian/control.tmpl debian/rules.tmpl"
-TEMPLATE_VARS += "MACHINE DEBIAN_BUILD_DEPENDS U_BOOT_CONFIG U_BOOT_BIN"
+TEMPLATE_VARS += "MACHINE DEBIAN_BUILD_DEPENDS U_BOOT_CONFIG U_BOOT_BIN KCFLAGS HOSTCFLAGS"
 
 U_BOOT_TOOLS_PACKAGE ?= "0"
 U_BOOT_CONFIG_PACKAGE ?= "0"