[gobject-introspection/ignore-py-compiler-flags] ccompiler: don't use Python compiler flags. Fixes #150



commit c14d0372283abc1b857e38517e791447233e4d62
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Dec 29 14:28:26 2018 +0100

    ccompiler: don't use Python compiler flags. Fixes #150
    
    Only use flags provided by env vars from the user and never from the
    Python sysconfig. The sysconfig values depend on the way Python was built,
    might conflict when using g-i with a different compiler and can't be controlled
    by the g-i user.

 giscanner/ccompiler.py          | 14 ++++++++------
 tests/scanner/test_ccompiler.py |  2 --
 2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index d8b15bce..8ea99445 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -36,13 +36,13 @@ from . import utils
 
 def customize_compiler(compiler):
     """This is a version of distutils.sysconfig.customize_compiler, without
-    any macOS specific bits.
+    any macOS specific bits and which tries to avoid using any Python specific
+    defaults if alternatives through env vars are given.
     """
 
     if compiler.compiler_type == "unix":
-        (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
-            get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
-                            'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
+        (cc, cxx, ldshared, shlib_suffix, ar, ar_flags) = \
+            get_config_vars('CC', 'CXX', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
 
         if 'CC' in os.environ:
             cc = os.environ['CC']
@@ -57,8 +57,10 @@ def customize_compiler(compiler):
         if 'LDFLAGS' in os.environ:
             ldshared = ldshared + ' ' + os.environ['LDFLAGS']
         if 'CFLAGS' in os.environ:
-            cflags = opt + ' ' + os.environ['CFLAGS']
+            cflags = os.environ['CFLAGS']
             ldshared = ldshared + ' ' + os.environ['CFLAGS']
+        else:
+            cflags = ''
         if 'CPPFLAGS' in os.environ:
             cpp = cpp + ' ' + os.environ['CPPFLAGS']
             cflags = cflags + ' ' + os.environ['CPPFLAGS']
@@ -74,7 +76,7 @@ def customize_compiler(compiler):
         compiler.set_executables(
             preprocessor=cpp,
             compiler=cc_cmd,
-            compiler_so=cc_cmd + ' ' + ccshared,
+            compiler_so=cc_cmd,
             compiler_cxx=cxx,
             linker_so=ldshared,
             linker_exe=cc,
diff --git a/tests/scanner/test_ccompiler.py b/tests/scanner/test_ccompiler.py
index 4a136d6a..ac50e245 100644
--- a/tests/scanner/test_ccompiler.py
+++ b/tests/scanner/test_ccompiler.py
@@ -191,7 +191,6 @@ class UnixCCompilerTest(unittest.TestCase):
         args = self.preprocess_args()
         self.assertIn('-I.', args)
 
-    @unittest.skip("Currently Python build time CPPFLAGS are included as well")
     def test_preprocess_command(self):
         """"Checks complete preprocessing command."""
         args = self.preprocess_args(environ=dict(CPP='gcc -E'),
@@ -199,7 +198,6 @@ class UnixCCompilerTest(unittest.TestCase):
         self.assertEqual(['gcc', '-E', '-I.', '-C', '/tmp/file.c'],
                          args)
 
-    @unittest.skip("Currently Python build time CFLAGS and CPPFLAGS are included as well")
     def test_compile_command(self):
         """Checks complete compilation command."""
         args = self.compile_args(environ=dict(CC='clang'),


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