[pygobject/pygobject-3-30] build: don't use -Wdeclaration-after-statement with Python 3



commit ae6fb42fd541dbb6445e3a2c48a0306901a7cdeb
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Fri Jun 7 16:50:53 2019 +0200

    build: don't use -Wdeclaration-after-statement with Python 3
    
    The headers of Python 3.8 trigger the warning and PEP7 states that
    Python is depending on this now.
    
    As far as I remember this was mostly added to keep the code compatible
    with ancient py2 MSVC, so only use it with Python 2.

 meson.build | 7 ++++++-
 setup.py    | 6 +++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1d331f69..1b30bc15 100644
--- a/meson.build
+++ b/meson.build
@@ -72,7 +72,6 @@ else
     '-Wall',
     '-Warray-bounds',
     '-Wcast-align',
-    '-Wdeclaration-after-statement',
     '-Wduplicated-branches',
     '-Wextra',
     '-Wformat=2',
@@ -104,6 +103,12 @@ else
     '-Wwrite-strings',
   ]
 
+  if python.language_version().split('.')[0] == '2'
+    main_c_args += [
+        '-Wdeclaration-after-statement',
+    ]
+  endif
+
   main_c_args += [
     '-Wno-incompatible-pointer-types-discards-qualifiers',
     '-Wno-missing-field-initializers',
diff --git a/setup.py b/setup.py
index d8893e7e..fc46a4cd 100755
--- a/setup.py
+++ b/setup.py
@@ -937,7 +937,6 @@ def add_ext_compiler_flags(ext, compiler, _cache={}):
                 "-Wall",
                 "-Warray-bounds",
                 "-Wcast-align",
-                "-Wdeclaration-after-statement",
                 "-Wduplicated-branches",
                 "-Wextra",
                 "-Wformat=2",
@@ -969,6 +968,11 @@ def add_ext_compiler_flags(ext, compiler, _cache={}):
                 "-Wwrite-strings",
             ]
 
+            if sys.version_info[0] == 2:
+                args += [
+                    "-Wdeclaration-after-statement",
+                ]
+
             args += [
                 "-Wno-incompatible-pointer-types-discards-qualifiers",
                 "-Wno-missing-field-initializers",


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