1 # This file is NOT licensed under the GPLv3, which is the license for the rest
4 # Here's the license text for this file:
6 # This is free and unencumbered software released into the public domain.
8 # Anyone is free to copy, modify, publish, use, compile, sell, or
9 # distribute this software, either in source code form or as a compiled
10 # binary, for any purpose, commercial or non-commercial, and by any
13 # In jurisdictions that recognize copyright laws, the author or authors
14 # of this software dedicate any and all copyright interest in the
15 # software to the public domain. We make this dedication for the benefit
16 # of the public at large and to the detriment of our heirs and
17 # successors. We intend this dedication to be an overt act of
18 # relinquishment in perpetuity of all present and future rights to this
19 # software under copyright law.
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 # OTHER DEALINGS IN THE SOFTWARE.
29 # For more information, please refer to <http://unlicense.org/>
40 '-DCONFIG_H_IS_FROM_SAMBA=1',
41 '-DSTATIC_replace_MODULES=NULL',
42 '-DSTATIC_replace_MODULES_PROTO=extern',
44 '-D_POSIX_PTHREAD_SEMANTICS',
47 '-D_XOPEN_SOURCE_EXTENDED=1',
48 '-DAD_DC_BUILD_IS_ENABLED=1',
50 '-I/usr/local/include',
89 '-Ilibcli/named_pipe_auth',
99 '-Insswitch/libwbclient',
107 '-Isource3/rpc_server',
108 '-Isource3/smbd/notifyd',
111 '-Isource4/auth/gensec',
112 '-Isource4/auth/kerberos',
117 '-Isource4/lib/events',
118 '-Isource4/lib/http',
119 '-Isource4/lib/messaging',
120 '-Isource4/lib/socket',
121 '-Isource4/lib/stream',
124 '-Isource4/libcli/ldap',
127 '-Ithird_party/zlib',
129 '-Ibin/default/auth',
130 '-Ibin/default/auth/credentials',
131 '-Ibin/default/auth/gensec',
132 '-Ibin/default/auth/kerberos',
133 '-Ibin/default/auth/ntlmssp',
134 '-Ibin/default/ctdb',
135 '-Ibin/default/ctdb/include',
136 '-Ibin/default/dynconfig',
137 '-Ibin/default/include',
138 '-Ibin/default/include/public',
140 '-Ibin/default/lib/addns',
141 '-Ibin/default/lib/afs',
142 '-Ibin/default/lib/async_req',
143 '-Ibin/default/lib/compression',
144 '-Ibin/default/lib/crypto',
145 '-Ibin/default/lib/dbwrap',
146 '-Ibin/default/lib/krb5_wrap',
147 '-Ibin/default/lib/ldb',
148 '-Ibin/default/lib/ldb-samba',
149 '-Ibin/default/lib/ldb/include',
150 '-Ibin/default/lib/param',
151 '-Ibin/default/lib/pthreadpool',
152 '-Ibin/default/lib/replace',
153 '-Ibin/default/lib/smbconf',
154 '-Ibin/default/lib/socket',
155 '-Ibin/default/lib/talloc',
156 '-Ibin/default/lib/tdb',
157 '-Ibin/default/lib/tdb/include',
158 '-Ibin/default/lib/tevent',
159 '-Ibin/default/lib/tsocket',
160 '-Ibin/default/lib/util/charset',
161 '-Ibin/default/libcli/auth',
162 '-Ibin/default/libcli/cldap',
163 '-Ibin/default/libcli/drsuapi',
164 '-Ibin/default/libcli/ldap',
165 '-Ibin/default/libcli/lsarpc',
166 '-Ibin/default/libcli/named_pipe_auth',
167 '-Ibin/default/libcli/nbt',
168 '-Ibin/default/libcli/netlogon',
169 '-Ibin/default/libcli/registry',
170 '-Ibin/default/libcli/security',
171 '-Ibin/default/libcli/smb',
172 '-Ibin/default/libcli/util',
173 '-Ibin/default/libds/common',
174 '-Ibin/default/librpc',
175 '-Ibin/default/nsswitch',
176 '-Ibin/default/nsswitch/libwbclient',
177 '-Ibin/default/source3',
178 '-Ibin/default/source3/auth',
179 '-Ibin/default/source3/include',
180 '-Ibin/default/source3/lib',
181 '-Ibin/default/source3/librpc',
182 '-Ibin/default/source3/modules',
183 '-Ibin/default/source3/param',
184 '-Ibin/default/source3/rpc_server',
185 '-Ibin/default/source3/smbd/notifyd',
186 '-Ibin/default/source4',
187 '-Ibin/default/source4/auth',
188 '-Ibin/default/source4/auth/gensec',
189 '-Ibin/default/source4/auth/kerberos',
190 '-Ibin/default/source4/cluster',
191 '-Ibin/default/source4/dsdb',
192 '-Ibin/default/source4/include',
193 '-Ibin/default/source4/lib',
194 '-Ibin/default/source4/lib/events',
195 '-Ibin/default/source4/lib/http',
196 '-Ibin/default/source4/lib/messaging',
197 '-Ibin/default/source4/lib/socket',
198 '-Ibin/default/source4/lib/stream',
199 '-Ibin/default/source4/lib/tls',
200 '-Ibin/default/source4/libcli',
201 '-Ibin/default/source4/libcli/ldap',
202 '-Ibin/default/source4/librpc',
203 '-Ibin/default/source4/param',
204 '-Ibin/default/third_party/zlib',
208 '-Wdeclaration-after-statement',
210 '-Werror-implicit-function-declaration',
212 '-Werror=declaration-after-statement',
214 '-Werror=format-security',
215 '-Werror=pointer-arith',
216 '-Werror=return-type',
217 '-Werror=strict-prototypes',
218 '-Werror=uninitialized',
219 '-Werror=write-strings',
222 '-Wmissing-prototypes',
223 '-Wno-error=deprecated-declarations',
224 '-Wno-error=tautological-compare',
229 '-Wstrict-prototypes',
235 # Set this to the absolute path to the folder (NOT the file!) containing the
236 # compile_commands.json file to use that instead of 'flags'. See here for
237 # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
239 # You can get CMake to generate this file for you by adding:
240 # set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
241 # to your CMakeLists.txt file.
243 # Most projects will NOT need to set this to anything; you can just change the
244 # 'flags' list of compilation flags. Notice that YCM itself uses that approach.
245 compilation_database_folder
= ''
247 if os
.path
.exists( compilation_database_folder
):
248 database
= ycm_core
.CompilationDatabase( compilation_database_folder
)
252 SOURCE_EXTENSIONS
= [ '.C', '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
254 def DirectoryOfThisScript():
255 return os
.path
.dirname( os
.path
.abspath( __file__
) )
258 def MakeRelativePathsInFlagsAbsolute( flags
, working_directory
):
259 if not working_directory
:
262 make_next_absolute
= False
263 path_flags
= [ '-isystem', '-I', '-iquote', '--sysroot=' ]
267 if make_next_absolute
:
268 make_next_absolute
= False
269 if not flag
.startswith( '/' ):
270 new_flag
= os
.path
.join( working_directory
, flag
)
272 for path_flag
in path_flags
:
273 if flag
== path_flag
:
274 make_next_absolute
= True
277 if flag
.startswith( path_flag
):
278 path
= flag
[ len( path_flag
): ]
279 new_flag
= path_flag
+ os
.path
.join( working_directory
, path
)
283 new_flags
.append( new_flag
)
287 def IsHeaderFile( filename
):
288 extension
= os
.path
.splitext( filename
)[ 1 ]
289 return extension
in [ '.H', '.h', '.hxx', '.hpp', '.hh' ]
292 def GetCompilationInfoForFile( filename
):
293 # The compilation_commands.json file generated by CMake does not have entries
294 # for header files. So we do our best by asking the db for flags for a
295 # corresponding source file, if any. If one exists, the flags for that file
296 # should be good enough.
297 if IsHeaderFile( filename
):
298 basename
= os
.path
.splitext( filename
)[ 0 ]
299 for extension
in SOURCE_EXTENSIONS
:
300 replacement_file
= basename
+ extension
301 if os
.path
.exists( replacement_file
):
302 compilation_info
= database
.GetCompilationInfoForFile(
304 if compilation_info
.compiler_flags_
:
305 return compilation_info
307 return database
.GetCompilationInfoForFile( filename
)
310 def FlagsForFile( filename
, **kwargs
):
312 # Bear in mind that compilation_info.compiler_flags_ does NOT return a
313 # python list, but a "list-like" StringVec object
314 compilation_info
= GetCompilationInfoForFile( filename
)
315 if not compilation_info
:
318 final_flags
= MakeRelativePathsInFlagsAbsolute(
319 compilation_info
.compiler_flags_
,
320 compilation_info
.compiler_working_dir_
)
322 relative_to
= DirectoryOfThisScript()
323 final_flags
= MakeRelativePathsInFlagsAbsolute( flags
, relative_to
)
326 'flags': final_flags
,