当前位置: 首页>>代码示例>>Python>>正文


Python CompilationDatabase.fromDirectory方法代码示例

本文整理汇总了Python中clang.cindex.CompilationDatabase.fromDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python CompilationDatabase.fromDirectory方法的具体用法?Python CompilationDatabase.fromDirectory怎么用?Python CompilationDatabase.fromDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clang.cindex.CompilationDatabase的用法示例。


在下文中一共展示了CompilationDatabase.fromDirectory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_fail

# 需要导入模块: from clang.cindex import CompilationDatabase [as 别名]
# 或者: from clang.cindex.CompilationDatabase import fromDirectory [as 别名]
def test_create_fail():
    """Check we fail loading a database with an assertion"""
    path = os.path.dirname(__file__)
    try:
        CompilationDatabase.fromDirectory(path)
    except CompilationDatabaseError as e:
        assert e.cdb_error == CompilationDatabaseError.ERROR_CANNOTLOADDATABASE
    else:
        assert False
开发者ID:AndrewWalker,项目名称:sealang,代码行数:11,代码来源:test_cdb.py

示例2: test_all_compilecommand

# 需要导入模块: from clang.cindex import CompilationDatabase [as 别名]
# 或者: from clang.cindex.CompilationDatabase import fromDirectory [as 别名]
    def test_all_compilecommand(self):
        """Check we get all results from the db"""
        cdb = CompilationDatabase.fromDirectory(kInputsDir)
        cmds = cdb.getAllCompileCommands()
        self.assertEqual(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']},

            ]
        for i in range(len(cmds)):
            self.assertEqual(cmds[i].directory, expected[i]['wd'])
            self.assertEqual(cmds[i].filename, expected[i]['file'])
            for arg, exp in zip(cmds[i].arguments, expected[i]['line']):
                self.assertEqual(arg, exp)
开发者ID:jvesely,项目名称:clang,代码行数:27,代码来源:test_cdb.py

示例3: test_compilationDB_references

# 需要导入模块: from clang.cindex import CompilationDatabase [as 别名]
# 或者: from clang.cindex.CompilationDatabase import fromDirectory [as 别名]
 def test_compilationDB_references(self):
     """Ensure CompilationsCommands are independent of the database"""
     cdb = CompilationDatabase.fromDirectory(kInputsDir)
     cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
     del cdb
     gc.collect()
     workingdir = cmds[0].directory
开发者ID:jvesely,项目名称:clang,代码行数:9,代码来源:test_cdb.py

示例4: test_compilecommand_iterator_stops

# 需要导入模块: from clang.cindex import CompilationDatabase [as 别名]
# 或者: from clang.cindex.CompilationDatabase import fromDirectory [as 别名]
 def test_compilecommand_iterator_stops(self):
     """Check that iterator stops after the correct number of elements"""
     cdb = CompilationDatabase.fromDirectory(kInputsDir)
     count = 0
     for cmd in cdb.getCompileCommands('/home/john.doe/MyProject/project2.cpp'):
         count += 1
         self.assertLessEqual(count, 2)
开发者ID:jvesely,项目名称:clang,代码行数:9,代码来源:test_cdb.py

示例5: test_2_compilecommand

# 需要导入模块: from clang.cindex import CompilationDatabase [as 别名]
# 或者: from clang.cindex.CompilationDatabase import fromDirectory [as 别名]
def test_2_compilecommand():
    """Check file with 2 compile commands"""
    cdb = CompilationDatabase.fromDirectory(kInputsDir)
    cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project2.cpp")
    assert len(cmds) == 2
    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",
            ],
        },
    ]
    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
开发者ID:Le-voyeur,项目名称:root,代码行数:28,代码来源:test_cdb.py

示例6: test_compilecommand_iterator_stops

# 需要导入模块: from clang.cindex import CompilationDatabase [as 别名]
# 或者: from clang.cindex.CompilationDatabase import fromDirectory [as 别名]
def test_compilecommand_iterator_stops():
    """Check that iterator stops after the correct number of elements"""
    cdb = CompilationDatabase.fromDirectory(kInputsDir)
    count = 0
    for cmd in cdb.getCompileCommands("/home/john.doe/MyProject/project2.cpp"):
        count += 1
        assert count <= 2
开发者ID:Le-voyeur,项目名称:root,代码行数:9,代码来源:test_cdb.py

示例7: test_2_compilecommand

# 需要导入模块: from clang.cindex import CompilationDatabase [as 别名]
# 或者: from clang.cindex.CompilationDatabase import fromDirectory [as 别名]
def test_2_compilecommand():
    """Check file with 2 compile commands"""
    cdb = CompilationDatabase.fromDirectory(kInputsDir)
    cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project2.cpp')
    assert len(cmds) == 2
    expected = [
        {
            'wd': b'/home/john.doe/MyProjectA',
            'line': [
                b'clang++',
                b'-o', b'project2.o',
                b'-c', b'/home/john.doe/MyProject/project2.cpp'
            ]
        },
        {
            'wd': b'/home/john.doe/MyProjectB',
            'line': [
                b'clang++',
                b'-DFEATURE=1',
                b'-o', b'project2-feature.o',
                b'-c', b'/home/john.doe/MyProject/project2.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
开发者ID:AndrewWalker,项目名称:sealang,代码行数:30,代码来源:test_cdb.py


注:本文中的clang.cindex.CompilationDatabase.fromDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。