summaryrefslogtreecommitdiffstats
path: root/bindings/python
diff options
context:
space:
mode:
authorGuillaume Papin <guillaume.papin@epitech.eu>2016-03-07 18:44:42 +0000
committerGuillaume Papin <guillaume.papin@epitech.eu>2016-03-07 18:44:42 +0000
commit8baa4118b70036859b2e145467c732f26b0b2c72 (patch)
tree86b2ac6624334fa73a5127f45892924453616859 /bindings/python
parent770fdd38e937ce167626f902fc9d72c2b551b05d (diff)
python binding: expose compile command filename
Reviewers: compnerd, skalinichev Differential Revision: http://reviews.llvm.org/D17278 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python')
-rw-r--r--bindings/python/clang/cindex.py10
-rw-r--r--bindings/python/tests/cindex/test_cdb.py17
2 files changed, 22 insertions, 5 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index e4b38769b7..f4c7ca4986 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -2703,6 +2703,11 @@ class CompileCommand(object):
return conf.lib.clang_CompileCommand_getDirectory(self.cmd)
@property
+ def filename(self):
+ """Get the working filename for this CompileCommand"""
+ return conf.lib.clang_CompileCommand_getFilename(self.cmd)
+
+ @property
def arguments(self):
"""
Get an iterable object providing each argument in the
@@ -2884,6 +2889,11 @@ functionList = [
_CXString,
_CXString.from_result),
+ ("clang_CompileCommand_getFilename",
+ [c_object_p],
+ _CXString,
+ _CXString.from_result),
+
("clang_CompileCommand_getNumArgs",
[c_object_p],
c_uint),
diff --git a/bindings/python/tests/cindex/test_cdb.py b/bindings/python/tests/cindex/test_cdb.py
index e1f824f797..35fe3e108a 100644
--- a/bindings/python/tests/cindex/test_cdb.py
+++ b/bindings/python/tests/cindex/test_cdb.py
@@ -38,27 +38,34 @@ def test_all_compilecommand():
cmds = cdb.getAllCompileCommands()
assert len(cmds) == 3
expected = [
+ { 'wd': '/home/john.doe/MyProject',
+ 'file': '/home/john.doe/MyProject/project.cpp',
+ 'line': ['clang++', '-o', 'project.o', '-c',
+ '/home/john.doe/MyProject/project.cpp']},
{ 'wd': '/home/john.doe/MyProjectA',
+ 'file': '/home/john.doe/MyProject/project2.cpp',
'line': ['clang++', '-o', 'project2.o', '-c',
'/home/john.doe/MyProject/project2.cpp']},
{ 'wd': '/home/john.doe/MyProjectB',
+ 'file': '/home/john.doe/MyProject/project2.cpp',
'line': ['clang++', '-DFEATURE=1', '-o', 'project2-feature.o', '-c',
'/home/john.doe/MyProject/project2.cpp']},
- { 'wd': '/home/john.doe/MyProject',
- 'line': ['clang++', '-o', 'project.o', '-c',
- '/home/john.doe/MyProject/project.cpp']}
+
]
for i in range(len(cmds)):
assert cmds[i].directory == expected[i]['wd']
+ assert cmds[i].filename == expected[i]['file']
for arg, exp in zip(cmds[i].arguments, expected[i]['line']):
assert arg == exp
def test_1_compilecommand():
"""Check file with single compile command"""
cdb = CompilationDatabase.fromDirectory(kInputsDir)
- cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+ file = '/home/john.doe/MyProject/project.cpp'
+ cmds = cdb.getCompileCommands(file)
assert len(cmds) == 1
- assert cmds[0].directory == '/home/john.doe/MyProject'
+ assert cmds[0].directory == os.path.dirname(file)
+ assert cmds[0].filename == file
expected = [ 'clang++', '-o', 'project.o', '-c',
'/home/john.doe/MyProject/project.cpp']
for arg, exp in zip(cmds[0].arguments, expected):