[gobject-introspection/ignore-py-compiler-flags] ccompiler: include a version of customize_compiler() from CPython



commit 508ec4aadbee562eee69bd8d6db24d35f05352ea
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Dec 29 13:40:17 2018 +0100

    ccompiler: include a version of customize_compiler() from CPython
    
    So we have more control over it.
    
    This also removes all macOS specific bits from it because I'm not sure if they are
    needed and they depend in internal API. This means this change can cause functional
    changes. Please report if you hit any!

 giscanner/ccompiler.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 24dcbcbf..d8b15bce 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -29,11 +29,60 @@ import distutils
 from distutils.msvccompiler import MSVCCompiler
 from distutils.unixccompiler import UnixCCompiler
 from distutils.cygwinccompiler import Mingw32CCompiler
-from distutils.sysconfig import customize_compiler
+from distutils.sysconfig import get_config_vars
 
 from . import utils
 
 
+def customize_compiler(compiler):
+    """This is a version of distutils.sysconfig.customize_compiler, without
+    any macOS specific bits.
+    """
+
+    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')
+
+        if 'CC' in os.environ:
+            cc = os.environ['CC']
+        if 'CXX' in os.environ:
+            cxx = os.environ['CXX']
+        if 'LDSHARED' in os.environ:
+            ldshared = os.environ['LDSHARED']
+        if 'CPP' in os.environ:
+            cpp = os.environ['CPP']
+        else:
+            cpp = cc + " -E"
+        if 'LDFLAGS' in os.environ:
+            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
+        if 'CFLAGS' in os.environ:
+            cflags = opt + ' ' + os.environ['CFLAGS']
+            ldshared = ldshared + ' ' + os.environ['CFLAGS']
+        if 'CPPFLAGS' in os.environ:
+            cpp = cpp + ' ' + os.environ['CPPFLAGS']
+            cflags = cflags + ' ' + os.environ['CPPFLAGS']
+            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
+        if 'AR' in os.environ:
+            ar = os.environ['AR']
+        if 'ARFLAGS' in os.environ:
+            archiver = ar + ' ' + os.environ['ARFLAGS']
+        else:
+            archiver = ar + ' ' + ar_flags
+
+        cc_cmd = cc + ' ' + cflags
+        compiler.set_executables(
+            preprocessor=cpp,
+            compiler=cc_cmd,
+            compiler_so=cc_cmd + ' ' + ccshared,
+            compiler_cxx=cxx,
+            linker_so=ldshared,
+            linker_exe=cc,
+            archiver=archiver)
+
+        compiler.shared_lib_extension = shlib_suffix
+
+
 # Flags that retain macros in preprocessed output.
 FLAGS_RETAINING_MACROS = ['-g3', '-ggdb3', '-gstabs3', '-gcoff3', '-gxcoff3', '-gvms3']
 


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