3 from clang_helpers
import PrepareClangFlags
5 compilation_database_folder
= ''
11 '/usr/include/dbus-1.0',
20 '-Wno-variadic-macros',
23 '-DUSE_CLANG_COMPLETER',
28 if compilation_database_folder
:
29 database
= ycm_core
.CompilationDatabase(compilation_database_folder
)
34 def DirectoryOfThisScript():
35 return os
.path
.dirname(os
.path
.abspath(__file__
))
38 def MakeRelativePathsInFlagsAbsolute(flags
, working_directory
):
39 if not working_directory
:
42 make_next_absolute
= False
43 path_flags
= [ '-isystem', '-I', '-iquote', '--sysroot=' ]
47 if make_next_absolute
:
48 make_next_absolute
= False
49 if not flag
.startswith('/'):
50 new_flag
= os
.path
.join(working_directory
, flag
)
52 for path_flag
in path_flags
:
54 make_next_absolute
= True
57 if flag
.startswith(path_flag
):
58 path
= flag
[ len(path_flag
): ]
59 new_flag
= path_flag
+ os
.path
.join(working_directory
, path
)
63 new_flags
.append(new_flag
)
67 def FlagsForFile(filename
):
69 compilation_info
= database
.GetCompilationInfoForFile(filename
)
70 final_flags
= PrepareClangFlags(
71 MakeRelativePathsInFlagsAbsolute(
72 compilation_info
.compiler_flags_
,
73 compilation_info
.compiler_working_dir_
),
77 relative_to
= DirectoryOfThisScript()
78 final_flags
= MakeRelativePathsInFlagsAbsolute(flags
, relative_to
)