summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-03-06 12:16:24 -0500
committerColin Walters <walters@verbum.org>2013-03-06 17:15:45 -0500
commit7639a440b43ea1197de96035304404b0c87db608 (patch)
treeb0d54d2ba3302a43b5424ad6a2bde4a85dd4046e
parent3b6de4492d03e69bb29b09b4b1db9960cee9c7d0 (diff)
downloadgobject-introspection-7639a440b43ea1197de96035304404b0c87db608.tar.gz
scanner: Allow CFLAGS to contain arbitrary preprocessor commands like -include
Newer spidermonkey .pc file contains a -include argument, which g-ir-scanner doesn't understand. Rather than us attempting to replicate all of cpp's options, use wrapper arguments in Makefile.introspection to pass them through. https://bugzilla.gnome.org/show_bug.cgi?id=695182
-rw-r--r--Makefile.introspection2
-rwxr-xr-xgiscanner/scannermain.py18
-rw-r--r--giscanner/sourcescanner.py3
3 files changed, 21 insertions, 2 deletions
diff --git a/Makefile.introspection b/Makefile.introspection
index 567d5e96..b3473377 100644
--- a/Makefile.introspection
+++ b/Makefile.introspection
@@ -142,7 +142,9 @@ $(1): $$($(_gir_name)_FILES)
$(_gir_program) \
$(_gir_libraries) \
$($(_gir_name)_SCANNERFLAGS) \
+ --cflags-begin \
$($(_gir_name)_CFLAGS) \
+ --cflags-end \
$($(_gir_name)_LDFLAGS) \
$$^ \
--output $(1)
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 5fa370ce..42867f08 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -42,8 +42,23 @@ from giscanner.sourcescanner import SourceScanner
from giscanner.transformer import Transformer
from . import utils
+def process_cflags_begin(option, opt, value, parser):
+ cflags = getattr(parser.values, option.dest)
+ while len(parser.rargs) > 0 and parser.rargs[0] != '--cflags-end':
+ cflags.append(parser.rargs.pop(0))
+
+def process_cflags_end(option, opt, value, parser):
+ pass
+
def get_preprocessor_option_group(parser):
group = optparse.OptionGroup(parser, "Preprocessor options")
+ group.add_option("", "--cflags-begin",
+ help="Start preprocessor/compiler flags",
+ dest="cflags", default=[],
+ action="callback", callback=process_cflags_begin)
+ group.add_option("", "--cflags-end",
+ help="End preprocessor/compiler flags",
+ action="callback", callback=process_cflags_end)
group.add_option("-I", help="Pre-processor include file",
action="append", dest="cpp_includes",
default=[])
@@ -353,7 +368,8 @@ def create_source_scanner(options, args):
ss = SourceScanner()
ss.set_cpp_options(options.cpp_includes,
options.cpp_defines,
- options.cpp_undefines)
+ options.cpp_undefines,
+ cflags=options.cflags)
ss.parse_files(filenames)
ss.parse_macros(filenames)
return ss
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index 9eb4ab4f..de137767 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -223,7 +223,8 @@ class SourceScanner(object):
# Public API
- def set_cpp_options(self, includes, defines, undefines):
+ def set_cpp_options(self, includes, defines, undefines, cflags=[]):
+ self._cpp_options.extend(cflags)
for prefix, args in [('-I', includes),
('-D', defines),
('-U', undefines)]: