[gobject-introspection] scanner: Allow CFLAGS to contain arbitrary preprocessor commands like -include
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Allow CFLAGS to contain arbitrary preprocessor commands like -include
- Date: Wed, 6 Mar 2013 22:47:20 +0000 (UTC)
commit 7639a440b43ea1197de96035304404b0c87db608
Author: Colin Walters <walters verbum org>
Date: Wed Mar 6 12:16:24 2013 -0500
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
Makefile.introspection | 2 ++
giscanner/scannermain.py | 18 +++++++++++++++++-
giscanner/sourcescanner.py | 3 ++-
3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.introspection b/Makefile.introspection
index 567d5e9..b347337 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 5fa370c..42867f0 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 9eb4ab4..de13776 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)]:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]