[vala/wip/meson: 3/3] meson: Check suported cflags for tests



commit 841be4fc41a94f2270d4b7219d4d91036c9f19ee
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Feb 10 21:03:53 2019 +0100

    meson: Check suported cflags for tests

 tests/meson.build | 54 ++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 20 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index 63bc1b031..69a0ab3a8 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -699,28 +699,42 @@ vala_flags = [
        '-X', '-pipe',
        '-X', '-lm',
        '-X', '-DGETTEXT_PACKAGE="valac"',
-       '-X', '-Werror=init-self',
-       '-X', '-Werror=implicit',
-       '-X', '-Werror=pointer-arith',
-       '-X', '-Werror=redundant-decls',
-       '-X', '-Werror=return-type',
-       '-X', '-Werror=sequence-point',
-       '-X', '-Werror=uninitialized',
-       '-X', '-Werror=int-to-pointer-cast',
-       '-X', '-Werror=pointer-to-int-cast',
-       '-X', '-Wformat=2',
-       '-X', '-Werror=format-security',
-       '-X', '-Werror=format-nonliteral',
-       '-X', '-Werror=int-conversion',
-       '-X', '-Werror=duplicated-branches',
-       '-X', '-Werror=duplicated-cond',
-       '-X', '-Werror=declaration-after-statement',
-       '-X', '-Werror=maybe-uninitialized',
-#      '-X', '-Werror=missing-prototypes',
-#      '-X', '-Werror=strict-prototypes',
-#      '-X', '-Werror=enum-conversion',
 ]
 
+cc = meson.get_compiler('c')
+if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
+  test_cflags = [
+       '-Werror=init-self',
+       '-Werror=implicit',
+       '-Werror=pointer-arith',
+       '-Werror=redundant-decls',
+       '-Werror=return-type',
+       '-Werror=sequence-point',
+       '-Werror=uninitialized',
+       '-Werror=int-to-pointer-cast',
+       '-Werror=pointer-to-int-cast',
+       '-Wformat=2',
+       '-Werror=format-security',
+       '-Werror=format-nonliteral',
+       '-Werror=int-conversion',
+       '-Werror=duplicated-branches',
+       '-Werror=duplicated-cond',
+       '-Werror=declaration-after-statement',
+       '-Werror=maybe-uninitialized',
+       '-Werror=missing-prototypes',
+       '-Werror=strict-prototypes',
+       '-Werror=enum-conversion',
+  ]
+else
+  test_cflags = []
+endif
+
+supported_test_cflags = cc.get_supported_arguments(test_cflags)
+
+foreach flag : supported_test_cflags
+       vala_flags += ['-X', flag]
+endforeach
+
 add_test_setup('default', is_default: true, env: 'G_SLICE=debug-blocks G_DEBUG=fatal-warnings')
 
 vg = find_program('valgrind', required: false)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]