[gobject-introspection] giscanner: Make sure we use real paths in more places
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: Make sure we use real paths in more places
- Date: Fri, 15 Nov 2013 16:36:46 +0000 (UTC)
commit 95cbe0c58f729fbcd27e68a693a8bbcaaf117858
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Wed Nov 13 12:31:19 2013 +0100
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
giscanner/dumper.py | 2 +-
giscanner/scannermain.py | 14 ++++++++++----
giscanner/sourcescanner.py | 4 ++--
giscanner/utils.py | 7 +++++++
4 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 98920e3..93f2756 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 6ae2ded..bc7bc16 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 3444445..42af96f 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 77d05b9..def53fe 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:])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]