diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-12-29 13:40:17 +0100 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-12-29 14:06:33 +0100 |
commit | 508ec4aadbee562eee69bd8d6db24d35f05352ea (patch) | |
tree | ea2a0f96e51e8ae4d00cb7d620707824fad3918a /giscanner | |
parent | 3126ad5bc833f9404eab339a86be216f223ac687 (diff) | |
download | gobject-introspection-508ec4aadbee562eee69bd8d6db24d35f05352ea.tar.gz |
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!
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/ccompiler.py | 51 |
1 files changed, 50 insertions, 1 deletions
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'] |