summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2013-11-13 12:31:19 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2013-11-15 17:36:37 +0100
commit95cbe0c58f729fbcd27e68a693a8bbcaaf117858 (patch)
treee413da849fb17e8ce45b0cb9b570603466923461
parent562258d22f983b135cfc5031cb023d6b07473150 (diff)
downloadgobject-introspection-95cbe0c58f729fbcd27e68a693a8bbcaaf117858.tar.gz
giscanner: Make sure we use real paths in more places
Ensure we are using the real path also for cflags comming from pkg_config files and command line options. This fixes the generation of the gir files when include paths contain symlinks. https://bugzilla.gnome.org/show_bug.cgi?id=712211
-rw-r--r--giscanner/dumper.py2
-rwxr-xr-xgiscanner/scannermain.py14
-rw-r--r--giscanner/sourcescanner.py4
-rw-r--r--giscanner/utils.py7
4 files changed, 20 insertions, 7 deletions
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 98920e36..93f27569 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -214,7 +214,7 @@ class DumpCompiler(object):
else:
args.append("-Wno-deprecated-declarations")
pkgconfig_flags = self._run_pkgconfig('--cflags')
- args.extend(pkgconfig_flags)
+ args.extend([utils.cflag_real_include_path(f) for f in pkgconfig_flags])
cflags = os.environ.get('CFLAGS', '')
for cflag in cflags.split():
args.append(cflag)
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 6ae2dede..bc7bc16f 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -46,13 +46,19 @@ 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))
+ arg = parser.rargs.pop(0)
+ cflags.append(utils.cflag_real_include_path(arg))
def process_cflags_end(option, opt, value, parser):
pass
+def process_cpp_includes(option, opt, value, parser):
+ cpp_includes = getattr(parser.values, option.dest)
+ cpp_includes.append(os.path.realpath(value))
+
+
def get_preprocessor_option_group(parser):
group = optparse.OptionGroup(parser, "Preprocessor options")
group.add_option("", "--cflags-begin",
@@ -63,8 +69,8 @@ def get_preprocessor_option_group(parser):
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=[])
+ dest="cpp_includes", default=[], type="string",
+ action="callback", callback=process_cpp_includes)
group.add_option("-D", help="Pre-processor define",
action="append", dest="cpp_defines",
default=[])
@@ -252,7 +258,7 @@ def process_packages(options, packages):
filtered_output = list(process_options(output, options_whitelist))
parser = _get_option_parser()
pkg_options, unused = parser.parse_args(filtered_output)
- options.cpp_includes.extend(pkg_options.cpp_includes)
+ options.cpp_includes.extend([os.path.realpath(f) for f in pkg_options.cpp_includes])
options.cpp_defines.extend(pkg_options.cpp_defines)
options.cpp_undefines.extend(pkg_options.cpp_undefines)
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index 3444445e..42af96ff 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -227,7 +227,7 @@ class SourceScanner(object):
def set_cpp_options(self, includes, defines, undefines, cflags=[]):
self._cpp_options.extend(cflags)
- for prefix, args in [('-I', includes),
+ for prefix, args in [('-I', [os.path.realpath(f) for f in includes]),
('-D', defines),
('-U', undefines)]:
for arg in (args or []):
@@ -243,7 +243,7 @@ class SourceScanner(object):
self._filenames.append(filename)
headers = []
- for filename in filenames:
+ for filename in self._filenames:
if os.path.splitext(filename)[1] in SOURCE_EXTS:
self._scanner.lex_filename(filename)
else:
diff --git a/giscanner/utils.py b/giscanner/utils.py
index 77d05b9e..def53fe4 100644
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -148,3 +148,10 @@ def files_are_identical(path1, path2):
f1.close()
f2.close()
return buf1 == buf2
+
+
+def cflag_real_include_path(cflag):
+ if not cflag.startswith("-I"):
+ return cflag
+
+ return "-I" + os.path.realpath(cflag[2:])