Skip to contentSkip to conversation

cleanup kernel meson.build file for linux

PATCH Superseded Bruce Richardson 4 participants 12 messages Apr 30, 2019 – May 29, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover cleanup kernel meson.build file for linux

Small cleanups to shorten the meson.build file in the kernel/linux directory, removing the unneeded version check and taking advantage of the subdir_done() function introduced in meson 0.46.

These should be fairly harmless, but given the stage of development we are at for 19.05, targetting them to 19.08 instead. [They can be pulled in to 19.05 if so desired, though. :-)]

Bruce Richardson (3):
kernel/linux: remove unnecessary meson version check kernel/linux: reduce unneeded indents in meson build file kernel/linux: remove unneeded local variables

 kernel/linux/meson.build | 46 +++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 27 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 kernel/linux: remove unnecessary meson version check

The check for meson version 0.44 is not redundant since the minimum supported version for the project as a whole is 0.47.

---
 kernel/linux/meson.build | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/linux/meson.build +1 -6
index d751d939f..bf8f085b0 100644
@@ -7,13 +7,8 @@ WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-com
 WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
 
 # if we are cross-compiling we need kernel_dir specified
-# NOTE: warning() function only available from version 0.44 onwards
 if get_option('kernel_dir') == '' and meson.is_cross_build()
-	if meson.version().version_compare('>=0.44')
-		warning(WARN_CROSS_COMPILE)
-	else
-		message('WARNING: ' + WARN_CROSS_COMPILE)
-	endif
+	warning(WARN_CROSS_COMPILE)
 else
 
 	kernel_dir = get_option('kernel_dir')
Signature · 1 line
2.20.1
#2 lore raw

Re: [dpdk-dev] [PATCH 19.08 1/3] kernel/linux: remove unnecessary meson version check

Quoted 1 line · Bruce Richardson

The check for meson version 0.44 is not redundant since the minimum

"not", in this case, being used as a synonym for "now" :-)

Quoted 29 lines

supported version for the project as a whole is 0.47.

---
 kernel/linux/meson.build | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/linux/meson.build +1 -6
index d751d939f..bf8f085b0 100644
@@ -7,13 +7,8 @@ WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-com
 WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
 
 # if we are cross-compiling we need kernel_dir specified
-# NOTE: warning() function only available from version 0.44 onwards
 if get_option('kernel_dir') == '' and meson.is_cross_build()
-	if meson.version().version_compare('>=0.44')
-		warning(WARN_CROSS_COMPILE)
-	else
-		message('WARNING: ' + WARN_CROSS_COMPILE)
-	endif
+	warning(WARN_CROSS_COMPILE)
 else
 
 	kernel_dir = get_option('kernel_dir')
Signature · 1 line
2.20.1
#3 lore raw

PATCH 2/3 kernel/linux: reduce unneeded indents in meson build file

In reply to Bruce Richardson

Since meson 0.46, meson has supported the subdir_done() function, which allows us to abort processing of a file early. Using this we can reduce the indentation in our files by eliminating unnecessary else blocks.

---
Note: though the diff here seems fairly big, a lot of it is whitespace change due to reduced indentation. Using "git diff -w" is recommended for easier review.

---
 kernel/linux/meson.build | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
kernel/linux/meson.build +18 -18
index bf8f085b0..d31fc8f80 100644
@@ -9,25 +9,25 @@ WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers
 # if we are cross-compiling we need kernel_dir specified
 if get_option('kernel_dir') == '' and meson.is_cross_build()
 	warning(WARN_CROSS_COMPILE)
-else
+	subdir_done()
+endif
 
-	kernel_dir = get_option('kernel_dir')
-	if kernel_dir == ''
-		# use default path for native builds
-		kernel_version = run_command('uname', '-r').stdout().strip()
-		kernel_dir = '/lib/modules/' + kernel_version + '/build'
-	endif
+kernel_dir = get_option('kernel_dir')
+if kernel_dir == ''
+	# use default path for native builds
+	kernel_version = run_command('uname', '-r').stdout().strip()
+	kernel_dir = '/lib/modules/' + kernel_version + '/build'
+endif
 
-	# test running make in kernel directory, using "make kernelversion"
-	make_returncode = run_command('make', '-sC', kernel_dir,
-			'kernelversion').returncode()
-	if make_returncode != 0
-		warning(WARN_NO_HEADERS)
-	else # returncode == 0
+# test running make in kernel directory, using "make kernelversion"
+make_returncode = run_command('make', '-sC', kernel_dir,
+		'kernelversion').returncode()
+if make_returncode != 0
+	warning(WARN_NO_HEADERS)
+	subdir_done()
+endif
 
 # DO ACTUAL MODULE BUILDING
-		foreach d:subdirs
-			subdir(d)
-		endforeach
-	endif
-endif
+foreach d:subdirs
+	subdir(d)
+endforeach
Signature · 1 line
2.20.1
#4 lore raw

PATCH 3/3 kernel/linux: remove unneeded local variables

In reply to Bruce Richardson

The local variables for the error message aren't needed, since the messages aren't used more than once, and the indent levels are now such that the lines printing the message are not much longer than the lines defining the variables to hold the messages themselves. Therefore the use of the variables is pointless.

---
 kernel/linux/meson.build | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/linux/meson.build +2 -5
index d31fc8f80..a37c95752 100644
@@ -3,12 +3,9 @@
 
 subdirs = ['igb_uio', 'kni']
 
-WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-compiling'
-WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
-
 # if we are cross-compiling we need kernel_dir specified
 if get_option('kernel_dir') == '' and meson.is_cross_build()
-	warning(WARN_CROSS_COMPILE)
+	warning('Need "kernel_dir" option for kmod compilation when cross-compiling')
 	subdir_done()
 endif
 
@@ -23,7 +20,7 @@ endif
 make_returncode = run_command('make', '-sC', kernel_dir,
 		'kernelversion').returncode()
 if make_returncode != 0
-	warning(WARN_NO_HEADERS)
+	warning('Cannot compile kernel modules as requested - are kernel headers installed?')
 	subdir_done()
 endif
 
Signature · 1 line
2.20.1
Reviewed-by on the v1 series
#5 lore raw
In reply to Bruce Richardson
Quoted 13 lines · Bruce Richardson

Small cleanups to shorten the meson.build file in the kernel/linux directory, removing the unneeded version check and taking advantage of the subdir_done() function introduced in meson 0.46.

These should be fairly harmless, but given the stage of development we are at for 19.05, targetting them to 19.08 instead. [They can be pulled in to 19.05 if so desired, though. :-)]

Bruce Richardson (3):
kernel/linux: remove unnecessary meson version check kernel/linux: reduce unneeded indents in meson build file kernel/linux: remove unneeded local variables

Quoted 6 lines
 kernel/linux/meson.build | 46 +++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

--
2.20.1

For the series,

Signature · 1 line
David Marchand
#6 lore raw

v2 cover cleanup kernel meson.build file for linux

In reply to Bruce Richardson

Small cleanups to shorten the meson.build file in the kernel/linux directory, removing the unneeded version check and taking advantage of the subdir_done() function introduced in meson 0.46.

V2:
resubmit without the 19.08 patch prefix and with the typo removed in patch 1.

Bruce Richardson (3):
kernel/linux: remove unnecessary meson version check kernel/linux: reduce unneeded indents in meson build file kernel/linux: remove unneeded local variables

 kernel/linux/meson.build | 46 +++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 27 deletions(-)
Signature · 1 line
2.21.0
#7 lore raw

PATCH v2 1/3 kernel/linux: remove unnecessary meson version check

The check for meson version 0.44 is redundant since the minimum supported version for the project as a whole is 0.47.

---
 kernel/linux/meson.build | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/linux/meson.build +1 -6
index d751d939f..bf8f085b0 100644
@@ -7,13 +7,8 @@ WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-com
 WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
 
 # if we are cross-compiling we need kernel_dir specified
-# NOTE: warning() function only available from version 0.44 onwards
 if get_option('kernel_dir') == '' and meson.is_cross_build()
-	if meson.version().version_compare('>=0.44')
-		warning(WARN_CROSS_COMPILE)
-	else
-		message('WARNING: ' + WARN_CROSS_COMPILE)
-	endif
+	warning(WARN_CROSS_COMPILE)
 else
 
 	kernel_dir = get_option('kernel_dir')
Signature · 1 line
2.21.0
#8 lore raw

PATCH v2 2/3 kernel/linux: reduce unneeded indents in meson build file

In reply to Bruce Richardson

Since meson 0.46, meson has supported the subdir_done() function, which allows us to abort processing of a file early. Using this we can reduce the indentation in our files by eliminating unnecessary else blocks.

---
 kernel/linux/meson.build | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
kernel/linux/meson.build +18 -18
index bf8f085b0..d31fc8f80 100644
@@ -9,25 +9,25 @@ WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers
 # if we are cross-compiling we need kernel_dir specified
 if get_option('kernel_dir') == '' and meson.is_cross_build()
 	warning(WARN_CROSS_COMPILE)
-else
+	subdir_done()
+endif
 
-	kernel_dir = get_option('kernel_dir')
-	if kernel_dir == ''
-		# use default path for native builds
-		kernel_version = run_command('uname', '-r').stdout().strip()
-		kernel_dir = '/lib/modules/' + kernel_version + '/build'
-	endif
+kernel_dir = get_option('kernel_dir')
+if kernel_dir == ''
+	# use default path for native builds
+	kernel_version = run_command('uname', '-r').stdout().strip()
+	kernel_dir = '/lib/modules/' + kernel_version + '/build'
+endif
 
-	# test running make in kernel directory, using "make kernelversion"
-	make_returncode = run_command('make', '-sC', kernel_dir,
-			'kernelversion').returncode()
-	if make_returncode != 0
-		warning(WARN_NO_HEADERS)
-	else # returncode == 0
+# test running make in kernel directory, using "make kernelversion"
+make_returncode = run_command('make', '-sC', kernel_dir,
+		'kernelversion').returncode()
+if make_returncode != 0
+	warning(WARN_NO_HEADERS)
+	subdir_done()
+endif
 
 # DO ACTUAL MODULE BUILDING
-		foreach d:subdirs
-			subdir(d)
-		endforeach
-	endif
-endif
+foreach d:subdirs
+	subdir(d)
+endforeach
Signature · 1 line
2.21.0
#9 lore raw

PATCH v2 3/3 kernel/linux: remove unneeded local variables

In reply to Bruce Richardson

The local variables for the error message aren't needed, since the messages aren't used more than once, and the indent levels are now such that the lines printing the message are not much longer than the lines defining the variables to hold the messages themselves. Therefore the use of the variables is pointless.

---
 kernel/linux/meson.build | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/linux/meson.build +2 -5
index d31fc8f80..a37c95752 100644
@@ -3,12 +3,9 @@
 
 subdirs = ['igb_uio', 'kni']
 
-WARN_CROSS_COMPILE='Need "kernel_dir" option for kmod compilation when cross-compiling'
-WARN_NO_HEADERS='Cannot compile kernel modules as requested - are kernel headers installed?'
-
 # if we are cross-compiling we need kernel_dir specified
 if get_option('kernel_dir') == '' and meson.is_cross_build()
-	warning(WARN_CROSS_COMPILE)
+	warning('Need "kernel_dir" option for kmod compilation when cross-compiling')
 	subdir_done()
 endif
 
@@ -23,7 +20,7 @@ endif
 make_returncode = run_command('make', '-sC', kernel_dir,
 		'kernelversion').returncode()
 if make_returncode != 0
-	warning(WARN_NO_HEADERS)
+	warning('Cannot compile kernel modules as requested - are kernel headers installed?')
 	subdir_done()
 endif
 
Signature · 1 line
2.21.0
#10 lore raw
In reply to Bruce Richardson
Quoted 9 lines · Bruce Richardson

Small cleanups to shorten the meson.build file in the kernel/linux directory, removing the unneeded version check and taking advantage of the
subdir_done() function introduced in meson 0.46.

V2:
resubmit without the 19.08 patch prefix and with the typo removed in patch 1.

Quoted 8 lines

Bruce Richardson (3):
kernel/linux: remove unnecessary meson version check kernel/linux: reduce unneeded indents in meson build file kernel/linux: remove unneeded local variables

 kernel/linux/meson.build | 46 +++++++++++++++++---------------------
--
 1 file changed, 19 insertions(+), 27 deletions(-)
Signature · 2 lines
Kind regards,
Luca Boccassi
#11 lore raw

17/05/2019 15:53, Luca Boccassi:

Quoted 10 lines · Bruce Richardson
Quoted 9 lines

Small cleanups to shorten the meson.build file in the kernel/linux directory, removing the unneeded version check and taking advantage of the
subdir_done() function introduced in meson 0.46.

V2:
resubmit without the 19.08 patch prefix and with the typo removed in patch 1.

Quoted 6 lines
Quoted 4 lines

Bruce Richardson (3):
kernel/linux: remove unnecessary meson version check kernel/linux: reduce unneeded indents in meson build file kernel/linux: remove unneeded local variables

Applied, thanks