ctdbd_conn: let register_with_ctdbd() call CTDB_CONTROL_REGISTER_SRVID just once
[Samba.git] / .ycm_extra_conf.py
blob7e47e804d5b4e24419221390cac5a0214a8616f5
1 # This file is NOT licensed under the GPLv3, which is the license for the rest
2 # of Samba.
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
11 # means.
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/>
31 import os
32 import ycm_core
34 flags = [
35 # This is a C project
36 '-x', 'c',
37 '-DDEBUG_PASSWORD',
38 '-DDEVELOPER',
39 '-DHAVE_CONFIG_H=1',
40 '-DCONFIG_H_IS_FROM_SAMBA=1',
41 '-DSTATIC_replace_MODULES=NULL',
42 '-DSTATIC_replace_MODULES_PROTO=extern',
43 '-D_GNU_SOURCE=1',
44 '-D_POSIX_PTHREAD_SEMANTICS',
45 '-D_REENTRANT',
46 '-D_SAMBA_BUILD_=4',
47 '-D_XOPEN_SOURCE_EXTENDED=1',
48 '-DAD_DC_BUILD_IS_ENABLED=1',
49 '-DHAVE_IPV6=1',
50 '-DFALL_THROUGH',
51 '-I/usr/local/include',
52 '-I.',
53 '-Iauth',
54 '-Iauth/credentials',
55 '-Iauth/gensec',
56 '-Iauth/kerberos',
57 '-Iauth/ntlmssp',
58 '-Ictdb',
59 '-Ictdb/include',
60 '-Idynconfig',
61 '-Iinclude',
62 '-Iinclude/public',
63 '-Ilib',
64 '-Ilib/addns',
65 '-Ilib/afs',
66 '-Ilib/async_req',
67 '-Ilib/compression',
68 '-Ilib/crypto',
69 '-Ilib/dbwrap',
70 '-Ilib/krb5_wrap',
71 '-Ilib/ldb',
72 '-Ilib/ldb-samba',
73 '-Ilib/ldb/include',
74 '-Ilib/param',
75 '-Ilib/pthreadpool',
76 '-Ilib/replace',
77 '-Ilib/smbconf',
78 '-Ilib/socket',
79 '-Ilib/talloc',
80 '-Ilib/tdb',
81 '-Ilib/tdb/include',
82 '-Ilib/tevent',
83 '-Ilib/tsocket',
84 '-Ilib/util/charset',
85 '-Ilibcli/auth',
86 '-Ilibcli/cldap',
87 '-Ilibcli/drsuapi',
88 '-Ilibcli/ldap',
89 '-Ilibcli/lsarpc',
90 '-Ilibcli/named_pipe_auth',
91 '-Ilibcli/nbt',
92 '-Ilibcli/netlogon',
93 '-Ilibcli/registry',
94 '-Ilibcli/security',
95 '-Ilibcli/smb',
96 '-Ilibcli/util',
97 '-Ilibds/common',
98 '-Ilibrpc',
99 '-Insswitch',
100 '-Insswitch/libwbclient',
101 '-Isource3',
102 '-Isource3/auth',
103 '-Isource3/include',
104 '-Isource3/lib',
105 '-Isource3/librpc',
106 '-Isource3/modules',
107 '-Isource3/param',
108 '-Isource3/rpc_server',
109 '-Isource3/smbd/notifyd',
110 '-Isource4',
111 '-Isource4/auth',
112 '-Isource4/auth/gensec',
113 '-Isource4/auth/kerberos',
114 '-Isource4/cluster',
115 '-Isource4/dsdb',
116 '-Isource4/include',
117 '-Isource4/lib',
118 '-Isource4/lib/events',
119 '-Isource4/lib/http',
120 '-Isource4/lib/messaging',
121 '-Isource4/lib/socket',
122 '-Isource4/lib/stream',
123 '-Isource4/lib/tls',
124 '-Isource4/libcli',
125 '-Isource4/libcli/ldap',
126 '-Isource4/librpc',
127 '-Isource4/param',
128 '-Ithird_party/zlib',
129 '-Ibin/default',
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',
140 '-Ibin/default/lib',
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',
206 '-Wall',
207 '-Wcast-align',
208 '-Wcast-qual',
209 '-Wdeclaration-after-statement',
210 '-Werror',
211 '-Werror-implicit-function-declaration',
212 '-Werror=address',
213 '-Werror=declaration-after-statement',
214 '-Werror=format',
215 '-Werror=format-security',
216 '-Werror=pointer-arith',
217 '-Werror=return-type',
218 '-Werror=strict-prototypes',
219 '-Werror=uninitialized',
220 '-Werror=write-strings',
221 '-Wformat-security',
222 '-Wformat=2',
223 '-Wmissing-prototypes',
224 '-Wno-error=deprecated-declarations',
225 '-Wno-error=tautological-compare',
226 '-Wno-format-y2k',
227 '-Wpointer-arith',
228 '-Wreturn-type',
229 '-Wshadow',
230 '-Wstrict-prototypes',
231 '-Wuninitialized',
232 '-Wwrite-strings',
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 )
250 else:
251 database = None
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:
262 return list( flags )
263 new_flags = []
264 make_next_absolute = False
265 path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
266 for flag in flags:
267 new_flag = flag
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
277 break
279 if flag.startswith( path_flag ):
280 path = flag[ len( path_flag ): ]
281 new_flag = path_flag + os.path.join( working_directory, path )
282 break
284 if new_flag:
285 new_flags.append( new_flag )
286 return new_flags
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(
305 replacement_file )
306 if compilation_info.compiler_flags_:
307 return compilation_info
308 return None
309 return database.GetCompilationInfoForFile( filename )
312 def FlagsForFile( filename, **kwargs ):
313 if database:
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:
318 return None
320 final_flags = MakeRelativePathsInFlagsAbsolute(
321 compilation_info.compiler_flags_,
322 compilation_info.compiler_working_dir_ )
323 else:
324 relative_to = DirectoryOfThisScript()
325 final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
327 return {
328 'flags': final_flags,
329 'do_cache': True