[gobject-introspection] gi-r-scanner: add support for raw CFLAGS flags option



commit 95b03cf87efbd4fea4b7d55601c9752cefd29bfc
Author: Tim Lunn <tim feathertop org>
Date:   Sun Feb 24 17:34:56 2013 +1100

    gi-r-scanner: add support for raw CFLAGS flags option
    
    gi-r-scanner chokes when gir_CFLAGS have an '-include <header>' since
    this is not a recognised option. This commit adds a new --cflags option
    that passes cflags directly to the spawned gcc.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695182

 Makefile.introspection      |    2 +-
 giscanner/scannermain.py    |    6 +++++-
 giscanner/sourcescanner.py  |    4 +++-
 tests/warn/warningtester.py |    3 ++-
 4 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/Makefile.introspection b/Makefile.introspection
index 567d5e9..8424c73 100644
--- a/Makefile.introspection
+++ b/Makefile.introspection
@@ -142,7 +142,7 @@ $(1): $$($(_gir_name)_FILES)
          $(_gir_program) \
          $(_gir_libraries) \
          $($(_gir_name)_SCANNERFLAGS) \
-         $($(_gir_name)_CFLAGS) \
+         --cflags="$($(_gir_name)_CFLAGS)" \
          $($(_gir_name)_LDFLAGS) \
          $$^ \
          --output $(1)
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 5fa370c..8b4363b 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -44,6 +44,9 @@ from . import utils
 
 def get_preprocessor_option_group(parser):
     group = optparse.OptionGroup(parser, "Preprocessor options")
+    group.add_option("--cflags", help="Pre-processor cflags",
+                     action="store", dest="cpp_cflags",
+                     default="")
     group.add_option("-I", help="Pre-processor include file",
                      action="append", dest="cpp_includes",
                      default=[])
@@ -351,7 +354,8 @@ def create_source_scanner(options, args):
     # Run the preprocessor, tokenize and construct simple
     # objects representing the raw C symbols
     ss = SourceScanner()
-    ss.set_cpp_options(options.cpp_includes,
+    ss.set_cpp_options(options.cpp_cflags,
+                       options.cpp_includes,
                        options.cpp_defines,
                        options.cpp_undefines)
     ss.parse_files(filenames)
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index 9eb4ab4..795c46a 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -223,7 +223,9 @@ class SourceScanner(object):
 
     # Public API
 
-    def set_cpp_options(self, includes, defines, undefines):
+    def set_cpp_options(self, cflags, includes, defines, undefines):
+        if cflags:
+            self._cpp_options = cflags.split()
         for prefix, args in [('-I', includes),
                              ('-D', defines),
                              ('-U', undefines)]:
diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py
index 27e0a5e..fba8f0c 100644
--- a/tests/warn/warningtester.py
+++ b/tests/warn/warningtester.py
@@ -40,6 +40,7 @@ class ChunkedIO(object):
 
 class Options:
     def __init__(self):
+        self.cpp_cflags = ""
         self.cpp_includes = []
         self.cpp_defines = []
         self.cpp_undefines = []
@@ -110,7 +111,7 @@ def check(args):
     exit_code = process_packages(options, ['gobject-2.0'])
     if exit_code:
         sys.exit(exit_code)
-    ss.set_cpp_options(options.cpp_includes, options.cpp_defines, options.cpp_undefines)
+    ss.set_cpp_options(options.cpp_cflags, options.cpp_includes, options.cpp_defines, options.cpp_undefines)
     ss.parse_files([filename])
     ss.parse_macros([filename])
     transformer.parse(ss.get_symbols())


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