r197765 - [libclang/python] Add CompilationDatabase.getAllCompileCommands to the python bindings.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Dec 19 17:34:00 PST 2013
Author: akirtzidis
Date: Thu Dec 19 19:34:00 2013
New Revision: 197765
URL: http://llvm.org/viewvc/llvm-project?rev=197765&view=rev
Log:
[libclang/python] Add CompilationDatabase.getAllCompileCommands to the python bindings.
Patch by Laszlo Nagy!
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cdb.py
Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=197765&r1=197764&r2=197765&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Dec 19 19:34:00 2013
@@ -2607,6 +2607,14 @@ class CompilationDatabase(ClangObject):
return conf.lib.clang_CompilationDatabase_getCompileCommands(self,
filename)
+ def getAllCompileCommands(self):
+ """
+ Get an iterable object providing all the CompileCommands available from
+ the database.
+ """
+ return conf.lib.clang_CompilationDatabase_getAllCompileCommands(self)
+
+
class Token(Structure):
"""Represents a single token from the preprocessor.
@@ -2673,6 +2681,11 @@ functionList = [
c_object_p,
CompilationDatabase.from_result),
+ ("clang_CompilationDatabase_getAllCompileCommands",
+ [c_object_p],
+ c_object_p,
+ CompileCommands.from_result),
+
("clang_CompilationDatabase_getCompileCommands",
[c_object_p, c_char_p],
c_object_p,
Modified: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cdb.py?rev=197765&r1=197764&r2=197765&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py Thu Dec 19 19:34:00 2013
@@ -32,6 +32,27 @@ def test_lookup_succeed():
cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
assert len(cmds) != 0
+def test_all_compilecommand():
+ """Check we get all results from the db"""
+ cdb = CompilationDatabase.fromDirectory(kInputsDir)
+ cmds = cdb.getAllCompileCommands()
+ assert len(cmds) == 3
+ expected = [
+ { 'wd': '/home/john.doe/MyProjectA',
+ 'line': ['clang++', '-o', 'project2.o', '-c',
+ '/home/john.doe/MyProject/project2.cpp']},
+ { 'wd': '/home/john.doe/MyProjectB',
+ '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']
+ 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)
More information about the cfe-commits
mailing list