[gobject-introspection] giscanner/ccompiler.py: Improve CFLAGS handling



commit 3c42163880bf74d318453b47e6ac56bf3b89a86f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Sep 8 13:11:19 2015 +0800

    giscanner/ccompiler.py: Improve CFLAGS handling
    
    Some packages such as GEGL set macro defines directly into CFLAGS,
    and distutils don't handle those with quotes well, so we need to deal
    with them seperately.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753428

 giscanner/ccompiler.py |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 85ff026..a401cfd 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -25,6 +25,7 @@ import sys
 import distutils
 
 from distutils.msvccompiler import MSVCCompiler
+from distutils.unixccompiler import UnixCCompiler
 from distutils.cygwinccompiler import Mingw32CCompiler
 from distutils.sysconfig import customize_compiler
 
@@ -206,6 +207,21 @@ class CCompiler(object):
         for include in cpp_includes:
             includes.append(include)
 
+        if isinstance(self.compiler, UnixCCompiler):
+            # This is to handle the case where macros are defined in CFLAGS
+            cflags = os.environ.get('CFLAGS')
+            if cflags:
+                for i, cflag in enumerate(cflags.split()):
+                    if cflag.startswith('-D'):
+                        stridx = cflag.find('=')
+                        if stridx > -1:
+                            macroset = (cflag[2:stridx],
+                                        cflag[stridx + 1:])
+                        else:
+                            macroset = (cflag[2:], None)
+                        if macroset not in macros:
+                            macros.append(macroset)
+
         # Do not add -Wall when using init code as we do not include any
         # header of the library being introspected
         if self.compiler_cmd == 'gcc' and not init_sections:


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