18 compilation_database_folder =
'obj' 20 if os.path.exists( compilation_database_folder ):
21 database = ycm_core.CompilationDatabase( compilation_database_folder )
25 SOURCE_EXTENSIONS = [
'.cpp',
'.cxx',
'.cc',
'.c',
'.m',
'.mm' ]
28 return os.path.dirname( os.path.abspath( __file__ ) )
32 if not working_directory:
35 make_next_absolute =
False 36 path_flags = [
'-isystem',
'-I',
'-iquote',
'--sysroot=' ]
40 if make_next_absolute:
41 make_next_absolute =
False 42 if not flag.startswith(
'/' ):
43 new_flag = os.path.join( working_directory, flag )
45 for path_flag
in path_flags:
47 make_next_absolute =
True 50 if flag.startswith( path_flag ):
51 path = flag[ len( path_flag ): ]
52 new_flag = path_flag + os.path.join( working_directory, path )
56 new_flags.append( new_flag )
61 extension = os.path.splitext( filename )[ 1 ]
62 return extension
in [
'.h',
'.hxx',
'.hpp',
'.hh' ]
71 basename = os.path.splitext( filename )[ 0 ]
72 for extension
in SOURCE_EXTENSIONS:
73 replacement_file = basename + extension
74 if os.path.exists( replacement_file ):
75 compilation_info = database.GetCompilationInfoForFile(
77 if compilation_info.compiler_flags_:
78 return compilation_info
80 return database.GetCompilationInfoForFile( filename )
88 if not compilation_info:
92 compilation_info.compiler_flags_,
93 compilation_info.compiler_working_dir_ )
99 final_flags.remove(
'-stdlib=libc++' )
107 'flags': final_flags,