]>
git.rmz.io Git - dotfiles.git/blob - vim/ycm_extra_conf.py
6 def FlagsForFile( filename
, **kwargs
):
7 client_data
= kwargs
['client_data']
8 cwd
= client_data
['getcwd()']
9 # These are the compilation flags that will be used in case there's no
10 # compilation database set (by default, one is not set).
18 # '-Wno-variadic-macros',
29 final_flags
= MakeRelativePathsInFlagsAbsolute( flags
, relative_to
)
36 # This function makes it easy to pull in additional flags from rospack
38 cmd
= ['rospack', 'cflags-only-I']
40 out
= subprocess
.Popen(cmd
, shell
=False, stdout
=subprocess
.PIPE
).stdout
43 line
= out
.readline()[:-1].split(" ")
46 if include
.startswith(os
.path
.expanduser('~')):
47 includes
+= ['-I', include
]
49 includes
+= ['-isystem', include
]
50 return filter(lambda a
: a
!= ' ', includes
)
53 def DirectoryOfThisScript():
54 return os
.path
.dirname( os
.path
.abspath( __file__
) )
56 def MakeRelativePathsInFlagsAbsolute( flags
, working_directory
):
57 if not working_directory
:
60 make_next_absolute
= False
61 path_flags
= [ '-isystem', '-I', '-iquote', '--sysroot=' ]
65 if make_next_absolute
:
66 make_next_absolute
= False
67 if not flag
.startswith( '/' ):
68 new_flag
= os
.path
.join( working_directory
, flag
)
70 for path_flag
in path_flags
:
72 make_next_absolute
= True
75 if flag
.startswith( path_flag
):
76 path
= flag
[ len( path_flag
): ]
77 new_flag
= path_flag
+ os
.path
.join( working_directory
, path
)
81 new_flags
.append( new_flag
)