From 7ce5d16b5cf1fb96c85f08edd2c577557a8affa9 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 1 Mar 2018 19:07:42 +0100 Subject: [PATCH] meson: enable more warnings --- meson.build | 44 +++++++++++++++++++++++++++++++++++++++++ tests/check/meson.build | 12 ++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index f2b2afa757..d97b0d995a 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,8 @@ else gst_version_nano = 0 endif +have_cxx = add_languages('cpp', required : false) + glib_req = '>= 2.40.0' gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor) @@ -186,6 +188,48 @@ if gst_debug_disabled and cc.has_argument('-Wno-unused') add_project_arguments('-Wno-unused', language: 'c') endif +warning_flags = [ + '-Wmissing-declarations', + '-Wredundant-decls', + '-Wwrite-strings', + '-Wformat', + '-Wformat-nonliteral', + '-Wformat-security', + '-Winit-self', + '-Wmissing-include-dirs', + '-Waddress', + '-Wno-multichar', + '-Wvla', + '-Wpointer-arith', + '-Waggregate-return', +] + +warning_c_flags = [ + '-Wmissing-prototypes', + '-Wold-style-definition', + '-Wdeclaration-after-statement', + '-Wnested-externs' +] + +if have_cxx + cxx = meson.get_compiler('cpp') +endif + +foreach extra_arg : warning_flags + if cc.has_argument (extra_arg) + add_project_arguments([extra_arg], language: 'c') + endif + if have_cxx and cxx.has_argument (extra_arg) + add_project_arguments([extra_arg], language: 'cpp') + endif +endforeach + +foreach extra_arg : warning_c_flags + if cc.has_argument (extra_arg) + add_project_arguments([extra_arg], language: 'c') + endif +endforeach + presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets') subdir('gst') subdir('ext') diff --git a/tests/check/meson.build b/tests/check/meson.build index 6fdb490af9..8887f62b72 100644 --- a/tests/check/meson.build +++ b/tests/check/meson.build @@ -28,6 +28,16 @@ libm = cc.find_library('m', required : false) # FIXME: valgrind_args: add suppressions $(top_srcdir)/common/gst.supp $(srcdir)/gst-plugins-ugly.supp +no_warn_args = [] +foreach arg : [ + '-Wno-missing-prototypes', + '-Wno-missing-declarations', + '-Wno-old-style-definition'] + if cc.has_argument(arg) + no_warn_args += [arg] + endif +endforeach + foreach t : ugly_tests fname = '@0@.c'.format(t.get(0)) test_name = t.get(0).underscorify() @@ -43,7 +53,7 @@ foreach t : ugly_tests if not skip_test exe = executable(test_name, fname, include_directories : [configinc], - c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines, + c_args : ['-DHAVE_CONFIG_H=1' ] + test_defines + no_warn_args, dependencies : [libm] + test_deps + extra_deps, )