summaryrefslogtreecommitdiff
path: root/giscanner/message.py
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2018-11-08 18:26:29 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2018-11-08 18:06:22 +0000
commit886d36d65f3bcd30ddc23005e378c0fb4d295e21 (patch)
tree55c51f1163a5b3ef8af3e943811ca737724a9816 /giscanner/message.py
parentb5b25328b75ad97836f585f708b60d8fc6bca902 (diff)
downloadgobject-introspection-886d36d65f3bcd30ddc23005e378c0fb4d295e21.tar.gz
giscanner: Print relative filename paths when warning
g-ir-scanner would cut away the 'common prefix' between the current working directory and the file about be warned about. This is problematic when using automatic jumping to warnings and errors, as it'd mean the editor can't find the relevant file. For example, if g-ir-scanner is run from 'build/', and a warning occurs on a file in 'src/file.c', the scanner would print the warning 'src/file.c:123: Warning: This and that'. Running this from e.g. meson would mean e.g. VIM would not find the correct file to jump to. Meanwhile, GCC, in the same setup, would print '../src/file.c:123: Warning: ...', as that is the relative path from where the scanner is ran, and e.g. VIM would behave in a correct way.
Diffstat (limited to 'giscanner/message.py')
-rw-r--r--giscanner/message.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/giscanner/message.py b/giscanner/message.py
index 02377896..f20578f3 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -80,11 +80,8 @@ class Position(object):
self.column or -1)
def format(self, cwd):
- filename = os.path.realpath(self.filename)
- cwd = os.path.realpath(cwd)
- common_prefix = os.path.commonprefix((filename, cwd))
- if common_prefix:
- filename = os.path.relpath(filename, common_prefix)
+ filename = os.path.relpath(os.path.realpath(self.filename),
+ os.path.realpath(cwd))
if self.column is not None:
return '%s:%d:%d' % (filename, self.line, self.column)