[v3,2/7] build: use meson warning levels
diff mbox series

Message ID 20191129210905.1865-3-kevin.laatz@intel.com
State Superseded, archived
Delegated to: David Marchand
Headers show
Series
  • Add ABI compatibility checks to the meson build
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Laatz, Kevin Nov. 29, 2019, 9:09 p.m. UTC
From: Bruce Richardson <bruce.richardson@intel.com>

Rather than trying to manage all the cflags ourselves, we can use meson
warning levels to give the user more control. We remove the Wextra flag and
rely on meson to add it, by bumping up our default warning level.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build | 40 +++++++++++++++++++++-------------------
 meson.build        |  3 ++-
 2 files changed, 23 insertions(+), 20 deletions(-)

Patch
diff mbox series

diff --git a/config/meson.build b/config/meson.build
index 364a8d739..36a594970 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -158,31 +158,33 @@  endif
 # add -include rte_config to cflags
 add_project_arguments('-include', 'rte_config.h', language: 'c')
 
-# enable extra warnings and disable any unwanted warnings
+# enable extra warnings and disable any unwanted warnings. "-Wall" is added
+# by meson at warning level 1, and "-Wextra" at level 2, so we can omit
+# those. Add extra warnings at level 2 or above. (2 is default level).
 warning_flags = [
-	# -Wall is added by meson by default, so add -Wextra only
-	'-Wextra',
-
-	# additional warnings in alphabetical order
-	'-Wcast-qual',
-	'-Wdeprecated',
-	'-Wformat-nonliteral',
-	'-Wformat-security',
-	'-Wmissing-declarations',
-	'-Wmissing-prototypes',
-	'-Wnested-externs',
-	'-Wold-style-definition',
-	'-Wpointer-arith',
-	'-Wsign-compare',
-	'-Wstrict-prototypes',
-	'-Wundef',
-	'-Wwrite-strings',
-
 	# globally disabled warnings
 	'-Wno-address-of-packed-member',
 	'-Wno-packed-not-aligned',
 	'-Wno-missing-field-initializers'
 ]
+if get_option('warning_level').to_int() >= 2
+	warning_flags += [
+		# additional warnings in alphabetical order
+		'-Wcast-qual',
+		'-Wdeprecated',
+		'-Wformat-nonliteral',
+		'-Wformat-security',
+		'-Wmissing-declarations',
+		'-Wmissing-prototypes',
+		'-Wnested-externs',
+		'-Wold-style-definition',
+		'-Wpointer-arith',
+		'-Wsign-compare',
+		'-Wstrict-prototypes',
+		'-Wundef',
+		'-Wwrite-strings',
+	]
+endif
 if not dpdk_conf.get('RTE_ARCH_64')
 # for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!!
 	warning_flags += '-Wno-pointer-to-int-cast'
diff --git a/meson.build b/meson.build
index 3b7a2e7de..7a8f97ad6 100644
--- a/meson.build
+++ b/meson.build
@@ -8,7 +8,8 @@  project('DPDK', 'C',
 		files('VERSION')).stdout().strip(),
 	license: 'BSD',
 	default_options: ['buildtype=debugoptimized',
-			'default_library=static'],
+			'default_library=static',
+			'warning_level=2'],
 	meson_version: '>= 0.47.1'
 )