libsmb: Handle long-running smb2cli_notify
[Samba.git] / .ycm_extra_conf.py
blobc96b59e373befe40e3473231c5f1b8a3bc572b61
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 '-I/usr/local/include',
51 '-I.',
52 '-Iauth',
53 '-Iauth/credentials',
54 '-Iauth/gensec',
55 '-Iauth/kerberos',
56 '-Iauth/ntlmssp',
57 '-Ictdb',
58 '-Ictdb/include',
59 '-Idynconfig',
60 '-Iinclude',
61 '-Iinclude/public',
62 '-Ilib',
63 '-Ilib/addns',
64 '-Ilib/afs',
65 '-Ilib/async_req',
66 '-Ilib/compression',
67 '-Ilib/crypto',
68 '-Ilib/dbwrap',
69 '-Ilib/krb5_wrap',
70 '-Ilib/ldb',
71 '-Ilib/ldb-samba',
72 '-Ilib/ldb/include',
73 '-Ilib/param',
74 '-Ilib/pthreadpool',
75 '-Ilib/replace',
76 '-Ilib/smbconf',
77 '-Ilib/socket',
78 '-Ilib/talloc',
79 '-Ilib/tdb',
80 '-Ilib/tdb/include',
81 '-Ilib/tevent',
82 '-Ilib/tsocket',
83 '-Ilib/util/charset',
84 '-Ilibcli/auth',
85 '-Ilibcli/cldap',
86 '-Ilibcli/drsuapi',
87 '-Ilibcli/ldap',
88 '-Ilibcli/lsarpc',
89 '-Ilibcli/named_pipe_auth',
90 '-Ilibcli/nbt',
91 '-Ilibcli/netlogon',
92 '-Ilibcli/registry',
93 '-Ilibcli/security',
94 '-Ilibcli/smb',
95 '-Ilibcli/util',
96 '-Ilibds/common',
97 '-Ilibrpc',
98 '-Insswitch',
99 '-Insswitch/libwbclient',
100 '-Isource3',
101 '-Isource3/auth',
102 '-Isource3/include',
103 '-Isource3/lib',
104 '-Isource3/librpc',
105 '-Isource3/modules',
106 '-Isource3/param',
107 '-Isource3/rpc_server',
108 '-Isource3/smbd/notifyd',
109 '-Isource4',
110 '-Isource4/auth',
111 '-Isource4/auth/gensec',
112 '-Isource4/auth/kerberos',
113 '-Isource4/cluster',
114 '-Isource4/dsdb',
115 '-Isource4/include',
116 '-Isource4/lib',
117 '-Isource4/lib/events',
118 '-Isource4/lib/http',
119 '-Isource4/lib/messaging',
120 '-Isource4/lib/socket',
121 '-Isource4/lib/stream',
122 '-Isource4/lib/tls',
123 '-Isource4/libcli',
124 '-Isource4/libcli/ldap',
125 '-Isource4/librpc',
126 '-Isource4/param',
127 '-Ithird_party/zlib',
128 '-Ibin/default',
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',
139 '-Ibin/default/lib',
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',
205 '-Wall',
206 '-Wcast-align',
207 '-Wcast-qual',
208 '-Wdeclaration-after-statement',
209 '-Werror',
210 '-Werror-implicit-function-declaration',
211 '-Werror=address',
212 '-Werror=declaration-after-statement',
213 '-Werror=format',
214 '-Werror=format-security',
215 '-Werror=pointer-arith',
216 '-Werror=return-type',
217 '-Werror=strict-prototypes',
218 '-Werror=uninitialized',
219 '-Werror=write-strings',
220 '-Wformat-security',
221 '-Wformat=2',
222 '-Wmissing-prototypes',
223 '-Wno-error=deprecated-declarations',
224 '-Wno-error=tautological-compare',
225 '-Wno-format-y2k',
226 '-Wpointer-arith',
227 '-Wreturn-type',
228 '-Wshadow',
229 '-Wstrict-prototypes',
230 '-Wuninitialized',
231 '-Wwrite-strings',
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 )
249 else:
250 database = None
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:
260 return list( flags )
261 new_flags = []
262 make_next_absolute = False
263 path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
264 for flag in flags:
265 new_flag = flag
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
275 break
277 if flag.startswith( path_flag ):
278 path = flag[ len( path_flag ): ]
279 new_flag = path_flag + os.path.join( working_directory, path )
280 break
282 if new_flag:
283 new_flags.append( new_flag )
284 return new_flags
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(
303 replacement_file )
304 if compilation_info.compiler_flags_:
305 return compilation_info
306 return None
307 return database.GetCompilationInfoForFile( filename )
310 def FlagsForFile( filename, **kwargs ):
311 if database:
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:
316 return None
318 final_flags = MakeRelativePathsInFlagsAbsolute(
319 compilation_info.compiler_flags_,
320 compilation_info.compiler_working_dir_ )
321 else:
322 relative_to = DirectoryOfThisScript()
323 final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
325 return {
326 'flags': final_flags,
327 'do_cache': True