diff mbox series

kernel.bbclass: make pkg-config variables globally exported in the class

Message ID 20240226234417.270628-1-kamatam@amazon.com
State New
Headers show
Series kernel.bbclass: make pkg-config variables globally exported in the class | expand

Commit Message

Munehisa Kamata Feb. 26, 2024, 11:44 p.m. UTC
Rather than repeatedly exporting the variables in the different functions,
make them globally exported in the class for better maintainability.

This is essentially "v3" discussed in [1].

[1] https://lore.kernel.org/openembedded-core/20240222202827.3675576-1-kamatam@amazon.com/T/#t

Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
---
 meta/classes-recipe/kernel.bbclass | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

Comments

Richard Purdie Feb. 27, 2024, 10:38 a.m. UTC | #1
On Mon, 2024-02-26 at 15:44 -0800, Munehisa Kamata via lists.openembedded.org wrote:
> Rather than repeatedly exporting the variables in the different functions,
> make them globally exported in the class for better maintainability.
> 
> This is essentially "v3" discussed in [1].
> 
> [1] https://lore.kernel.org/openembedded-core/20240222202827.3675576-1-kamatam@amazon.com/T/#t
> 
> Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
> ---
>  meta/classes-recipe/kernel.bbclass | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
> index db4461e551..fce810a9e4 100644
> --- a/meta/classes-recipe/kernel.bbclass
> +++ b/meta/classes-recipe/kernel.bbclass
> @@ -239,9 +239,15 @@ KERNEL_EXTRA_ARGS ?= ""
>  EXTRA_OEMAKE += ' CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" STRIP="${KERNEL_STRIP}"'
>  EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"'
>  EXTRA_OEMAKE += ' HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}"'
> -# Only for newer kernels (5.19+), native pkg-config variables are set for older kernels when building kernel and modules
> +# Only for newer kernels (5.19+), native pkg-config variables are set below for older kernels
>  EXTRA_OEMAKE += ' HOSTPKG_CONFIG="pkg-config-native"'
>  
> +# setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
> +export PKG_CONFIG_DIR = "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
> +export PKG_CONFIG_PATH = "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig"
> +export PKG_CONFIG_LIBDIR = "${PKG_CONFIG_DIR}"
> +export PKG_CONFIG_SYSROOT_DIR = ""
> +
>  KERNEL_ALT_IMAGETYPE ??= ""
>  
>  copy_initramfs() {
> @@ -352,12 +358,6 @@ KERNEL_DEBUG_TIMESTAMPS ??= "0"
>  kernel_do_compile() {
>  	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
>  
> -	# setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
> -	export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
> -	export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig"
> -	export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR"
> -	export PKG_CONFIG_SYSROOT_DIR=""
> -
>  	if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
>  		# kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
>  		# be set....
> @@ -408,12 +408,6 @@ addtask transform_kernel after do_compile before do_install
>  do_compile_kernelmodules() {
>  	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
>  
> -	# setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
> -	export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
> -	export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig"
> -	export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR"
> -	export PKG_CONFIG_SYSROOT_DIR=""
> -
>  	if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
>  		# kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
>  		# be set....
> 


I'm really not keen on this. global exports are painful to remove later
as you can't really tell when they need to be set (e.g during
do_configure). Given that these reverse our usual usage of pkg-config
too, I really don't want to be doing this at all.

Until we have a minimum kernel version which has saner pkg-config usage
I appreciate we have to retain this but I do want to make it easier to
remove later.

I'm therefore leaning against doing this.

Cheers,

Richard
Munehisa Kamata March 2, 2024, 11:39 p.m. UTC | #2
Hi Richard,

On Tue, 2024-02-27 02:38:39 -0800, Richard Purdie wrote:
> 
> I'm really not keen on this. global exports are painful to remove later
> as you can't really tell when they need to be set (e.g during
> do_configure). Given that these reverse our usual usage of pkg-config
> too, I really don't want to be doing this at all.
> 
> Until we have a minimum kernel version which has saner pkg-config usage
> I appreciate we have to retain this but I do want to make it easier to
> remove later.
> 
> I'm therefore leaning against doing this.

That's a fair point. As the original issue has already been solved and I
meant this was a minor improvement, I don't insist on it.


Thanks,
Munehisa
 
> Cheers,
> 
> Richard
> 
> 
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index db4461e551..fce810a9e4 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -239,9 +239,15 @@  KERNEL_EXTRA_ARGS ?= ""
 EXTRA_OEMAKE += ' CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" STRIP="${KERNEL_STRIP}"'
 EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"'
 EXTRA_OEMAKE += ' HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}"'
-# Only for newer kernels (5.19+), native pkg-config variables are set for older kernels when building kernel and modules
+# Only for newer kernels (5.19+), native pkg-config variables are set below for older kernels
 EXTRA_OEMAKE += ' HOSTPKG_CONFIG="pkg-config-native"'
 
+# setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
+export PKG_CONFIG_DIR = "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
+export PKG_CONFIG_PATH = "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig"
+export PKG_CONFIG_LIBDIR = "${PKG_CONFIG_DIR}"
+export PKG_CONFIG_SYSROOT_DIR = ""
+
 KERNEL_ALT_IMAGETYPE ??= ""
 
 copy_initramfs() {
@@ -352,12 +358,6 @@  KERNEL_DEBUG_TIMESTAMPS ??= "0"
 kernel_do_compile() {
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
 
-	# setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
-	export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
-	export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig"
-	export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR"
-	export PKG_CONFIG_SYSROOT_DIR=""
-
 	if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
 		# kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
 		# be set....
@@ -408,12 +408,6 @@  addtask transform_kernel after do_compile before do_install
 do_compile_kernelmodules() {
 	unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
 
-	# setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
-	export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
-	export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig"
-	export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR"
-	export PKG_CONFIG_SYSROOT_DIR=""
-
 	if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
 		# kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
 		# be set....