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



commit ab596da7991dc5b91b047fc741c9da23ae051e1a
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 1beda259..2064d254 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 47cc1050..b9172131 100755
--- a/setup.py
+++ b/setup.py
@@ -975,7 +975,6 @@ def add_ext_compiler_flags(ext, compiler, _cache={}):
                 "-Wall",
                 "-Warray-bounds",
                 "-Wcast-align",
-                "-Wdeclaration-after-statement",
                 "-Wduplicated-branches",
                 "-Wextra",
                 "-Wformat=2",
@@ -1007,6 +1006,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]