summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)]: