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',
51 '-I/usr/local/include',
90 '-Ilibcli/named_pipe_auth',
100 '-Insswitch/libwbclient',
108 '-Isource3/rpc_server',
109 '-Isource3/smbd/notifyd',
112 '-Isource4/auth/gensec',
113 '-Isource4/auth/kerberos',
118 '-Isource4/lib/events',
119 '-Isource4/lib/http',
120 '-Isource4/lib/messaging',
121 '-Isource4/lib/socket',
122 '-Isource4/lib/stream',
125 '-Isource4/libcli/ldap',
128 '-Ithird_party/zlib',
130 '-Ibin/default/auth',
131 '-Ibin/default/auth/credentials',
132 '-Ibin/default/auth/gensec',
133 '-Ibin/default/auth/kerberos',
134 '-Ibin/default/auth/ntlmssp',
135 '-Ibin/default/ctdb',
136 '-Ibin/default/ctdb/include',
137 '-Ibin/default/dynconfig',
138 '-Ibin/default/include',
139 '-Ibin/default/include/public',
141 '-Ibin/default/lib/addns',
142 '-Ibin/default/lib/afs',
143 '-Ibin/default/lib/async_req',
144 '-Ibin/default/lib/compression',
145 '-Ibin/default/lib/crypto',
146 '-Ibin/default/lib/dbwrap',
147 '-Ibin/default/lib/krb5_wrap',
148 '-Ibin/default/lib/ldb',
149 '-Ibin/default/lib/ldb-samba',
150 '-Ibin/default/lib/ldb/include',
151 '-Ibin/default/lib/param',
152 '-Ibin/default/lib/pthreadpool',
153 '-Ibin/default/lib/replace',
154 '-Ibin/default/lib/smbconf',
155 '-Ibin/default/lib/socket',
156 '-Ibin/default/lib/talloc',
157 '-Ibin/default/lib/tdb',
158 '-Ibin/default/lib/tdb/include',
159 '-Ibin/default/lib/tevent',
160 '-Ibin/default/lib/tsocket',
161 '-Ibin/default/lib/util/charset',
162 '-Ibin/default/libcli/auth',
163 '-Ibin/default/libcli/cldap',
164 '-Ibin/default/libcli/drsuapi',
165 '-Ibin/default/libcli/ldap',
166 '-Ibin/default/libcli/lsarpc',
167 '-Ibin/default/libcli/named_pipe_auth',
168 '-Ibin/default/libcli/nbt',
169 '-Ibin/default/libcli/netlogon',
170 '-Ibin/default/libcli/registry',
171 '-Ibin/default/libcli/security',
172 '-Ibin/default/libcli/smb',
173 '-Ibin/default/libcli/util',
174 '-Ibin/default/libds/common',
175 '-Ibin/default/librpc',
176 '-Ibin/default/nsswitch',
177 '-Ibin/default/nsswitch/libwbclient',
178 '-Ibin/default/source3',
179 '-Ibin/default/source3/auth',
180 '-Ibin/default/source3/include',
181 '-Ibin/default/source3/lib',
182 '-Ibin/default/source3/librpc',
183 '-Ibin/default/source3/modules',
184 '-Ibin/default/source3/param',
185 '-Ibin/default/source3/rpc_server',
186 '-Ibin/default/source3/smbd/notifyd',
187 '-Ibin/default/source4',
188 '-Ibin/default/source4/auth',
189 '-Ibin/default/source4/auth/gensec',
190 '-Ibin/default/source4/auth/kerberos',
191 '-Ibin/default/source4/cluster',
192 '-Ibin/default/source4/dsdb',
193 '-Ibin/default/source4/include',
194 '-Ibin/default/source4/lib',
195 '-Ibin/default/source4/lib/events',
196 '-Ibin/default/source4/lib/http',
197 '-Ibin/default/source4/lib/messaging',
198 '-Ibin/default/source4/lib/socket',
199 '-Ibin/default/source4/lib/stream',
200 '-Ibin/default/source4/lib/tls',
201 '-Ibin/default/source4/libcli',
202 '-Ibin/default/source4/libcli/ldap',
203 '-Ibin/default/source4/librpc',
204 '-Ibin/default/source4/param',
205 '-Ibin/default/third_party/zlib',
209 '-Wdeclaration-after-statement',
211 '-Werror-implicit-function-declaration',
213 '-Werror=declaration-after-statement',
215 '-Werror=format-security',
216 '-Werror=pointer-arith',
217 '-Werror=return-type',
218 '-Werror=strict-prototypes',
219 '-Werror=uninitialized',
220 '-Werror=write-strings',
223 '-Wmissing-prototypes',
224 '-Wno-error=deprecated-declarations',
225 '-Wno-error=tautological-compare',
230 '-Wstrict-prototypes',
236 # Set this to the absolute path to the folder (NOT the file!) containing the
237 # compile_commands.json file to use that instead of 'flags'. See here for
238 # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
240 # You can get CMake to generate this file for you by adding:
241 # set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
242 # to your CMakeLists.txt file.
244 # Most projects will NOT need to set this to anything; you can just change the
245 # 'flags' list of compilation flags. Notice that YCM itself uses that approach.
246 compilation_database_folder
= ''
248 if os
.path
.exists( compilation_database_folder
):
249 database
= ycm_core
.CompilationDatabase( compilation_database_folder
)
253 SOURCE_EXTENSIONS
= [ '.C', '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
256 def DirectoryOfThisScript():
257 return os
.path
.dirname( os
.path
.abspath( __file__
) )
260 def MakeRelativePathsInFlagsAbsolute( flags
, working_directory
):
261 if not working_directory
:
264 make_next_absolute
= False
265 path_flags
= [ '-isystem', '-I', '-iquote', '--sysroot=' ]
269 if make_next_absolute
:
270 make_next_absolute
= False
271 if not flag
.startswith( '/' ):
272 new_flag
= os
.path
.join( working_directory
, flag
)
274 for path_flag
in path_flags
:
275 if flag
== path_flag
:
276 make_next_absolute
= True
279 if flag
.startswith( path_flag
):
280 path
= flag
[ len( path_flag
): ]
281 new_flag
= path_flag
+ os
.path
.join( working_directory
, path
)
285 new_flags
.append( new_flag
)
289 def IsHeaderFile( filename
):
290 extension
= os
.path
.splitext( filename
)[ 1 ]
291 return extension
in [ '.H', '.h', '.hxx', '.hpp', '.hh' ]
294 def GetCompilationInfoForFile( filename
):
295 # The compilation_commands.json file generated by CMake does not have entries
296 # for header files. So we do our best by asking the db for flags for a
297 # corresponding source file, if any. If one exists, the flags for that file
298 # should be good enough.
299 if IsHeaderFile( filename
):
300 basename
= os
.path
.splitext( filename
)[ 0 ]
301 for extension
in SOURCE_EXTENSIONS
:
302 replacement_file
= basename
+ extension
303 if os
.path
.exists( replacement_file
):
304 compilation_info
= database
.GetCompilationInfoForFile(
306 if compilation_info
.compiler_flags_
:
307 return compilation_info
309 return database
.GetCompilationInfoForFile( filename
)
312 def FlagsForFile( filename
, **kwargs
):
314 # Bear in mind that compilation_info.compiler_flags_ does NOT return a
315 # python list, but a "list-like" StringVec object
316 compilation_info
= GetCompilationInfoForFile( filename
)
317 if not compilation_info
:
320 final_flags
= MakeRelativePathsInFlagsAbsolute(
321 compilation_info
.compiler_flags_
,
322 compilation_info
.compiler_working_dir_
)
324 relative_to
= DirectoryOfThisScript()
325 final_flags
= MakeRelativePathsInFlagsAbsolute( flags
, relative_to
)
328 'flags': final_flags
,