summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2015-09-08 13:11:19 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2015-09-08 15:45:36 +0800
commit3c42163880bf74d318453b47e6ac56bf3b89a86f (patch)
treefb0b46ac17844dc672edf8a867a358ae5c21f8b2
parent175942eb307e552e17d3f55174fb508ff42f880d (diff)
downloadgobject-introspection-3c42163880bf74d318453b47e6ac56bf3b89a86f.tar.gz
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
-rw-r--r--giscanner/ccompiler.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 85ff0268..a401cfd7 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: