File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import os
22import json
3+ import clang .cindex as clang
4+
5+
6+ class CompilationDatabase :
7+ """
8+ Build a compilation database from a given directory
9+ """
10+
11+ def __init__ (self , build_dir ):
12+ self .compilation_database = clang .CompilationDatabase .fromDirectory (
13+ buildDir = build_dir
14+ )
15+
16+ def get_compilation_arguments (self , filename = None ):
17+ """
18+ Returns the compilation commands extracted from the compilation database
19+
20+ Parameters:
21+ - filename (optional): To get compilaton commands of a file
22+
23+ Returns:
24+ - compilation_arguments (dict): {filename: compiler arguments}
25+ """
26+
27+ if filename :
28+ # Get compilation commands from the compilation database for the given file
29+ compilation_commands = self .compilation_database .getCompileCommands (
30+ filename = filename
31+ )
32+ else :
33+ # Get all compilation commands from the compilation database
34+ compilation_commands = self .compilation_database .getAllCompileCommands ()
35+
36+ return {
37+ command .filename : list (command .arguments )[1 :- 1 ]
38+ for command in compilation_commands
39+ }
340
441
542class Codemodel :
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments