Skip to contentSkip to conversation

build: remove duplicate checks for cflags

PATCH Applied Bruce Richardson 2 participants 2 messages Jul 19, 2018 – Jul 26, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: remove duplicate checks for cflags

There is no need to check for each library, driver and example whether certain cflags are supported. Instead of checking inside the loop, do so outside and reuse the value.

---
 drivers/meson.build  |  9 +++++----
 examples/meson.build |  9 +++++----
 lib/meson.build      | 10 +++++-----
 3 files changed, 15 insertions(+), 13 deletions(-)
drivers/meson.build +5 -4
index 1737d86b8..82cc8ed49 100644
@@ -11,6 +11,10 @@ driver_classes = ['common',
 	       'event',   # depends on common, bus, mempool and net.
 	       'raw']     # depends on common, bus, mempool, net and event.
 
+default_cflags = machine_args
+if cc.has_argument('-Wno-format-truncation')
+	default_cflags += '-Wno-format-truncation'
+endif
 foreach class:driver_classes
 	drivers = []
 	std_deps = []
@@ -31,10 +35,7 @@ foreach class:driver_classes
 		allow_experimental_apis = false
 		sources = []
 		objs = []
-		cflags = machine_args
-		if cc.has_argument('-Wno-format-truncation')
-			cflags += '-Wno-format-truncation'
-		endif
+		cflags = default_cflags
 		includes = [include_directories(drv_path)]
 		# set up internal deps. Drivers can append/override as necessary
 		deps = std_deps
examples/meson.build +5 -4
index e6558875a..4ee7a1114 100644
@@ -18,15 +18,16 @@ else
 	examples = get_option('examples').split(',')
 	allow_skips = false # error out if we can't build a requested app
 endif
+default_cflags = machine_args
+if cc.has_argument('-Wno-format-truncation')
+	default_cflags += '-Wno-format-truncation'
+endif
 foreach example: examples
 	name = example
 	build = true
 	sources = []
 	allow_experimental_apis = false
-	cflags = machine_args
-	if cc.has_argument('-Wno-format-truncation')
-		cflags += '-Wno-format-truncation'
-	endif
+	cflags = default_cflags
 
 	ext_deps = [execinfo]
 	includes = [include_directories(example)]
lib/meson.build +5 -5
index d88b0211e..1cc7e111f 100644
@@ -26,6 +26,10 @@ libraries = [ 'compat', # just a header, used for versioning
 	# flow_classify lib depends on pkt framework table lib
 	'flow_classify', 'bpf']
 
+default_cflags = machine_args
+if cc.has_argument('-Wno-format-truncation')
+	default_cflags += '-Wno-format-truncation'
+endif
 foreach l:libraries
 	build = true
 	name = l
@@ -34,11 +38,7 @@ foreach l:libraries
 	sources = []
 	headers = []
 	includes = []
-	cflags = machine_args
-	if cc.has_argument('-Wno-format-truncation')
-	    cflags += '-Wno-format-truncation'
-	endif
-
+	cflags = default_cflags
 	objs = [] # other object files to link against, used e.g. for
 	          # instruction-set optimized versions of code
 
Signature · 1 line
2.17.1
#1 lore raw

19/07/2018 16:22, Bruce Richardson:

Quoted 5 lines

There is no need to check for each library, driver and example whether certain cflags are supported. Instead of checking inside the loop, do so outside and reuse the value.

The build log looks cleaner.

Applied, thanks