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/>
38 '-Wno-unused-parameter',
42 '-DCONFIG_H_IS_FROM_SAMBA=1',
45 '-DAD_DC_BUILD_IS_ENABLED=1',
87 '-Ilibcli/named_pipe_auth',
97 '-Insswitch/libwbclient',
102 '-Isource3/lib/asys',
103 '-Isource3/lib/pthreadpool',
107 '-Isource3/rpc_server',
110 '-Isource4/auth/gensec',
111 '-Isource4/auth/kerberos',
115 '-Isource4/lib/events',
116 '-Isource4/lib/socket',
117 '-Isource4/lib/stream',
120 '-Isource4/libcli/ldap',
125 '-Ibin/default/auth/credentials',
126 '-Ibin/default/auth/gensec',
127 '-Ibin/default/file_server',
128 '-Ibin/default/include',
129 '-Ibin/default/include/public',
130 '-Ibin/default/include/public/core',
131 '-Ibin/default/include/public/gen_ndr',
132 '-Ibin/default/include/public/ndr',
133 '-Ibin/default/include/public/samba',
134 '-Ibin/default/include/public/util',
135 '-Ibin/default/libcli/nbt',
136 '-Ibin/default/lib/crypto',
137 '-Ibin/default/lib/ldb/include',
138 '-Ibin/default/lib/ldb-samba',
139 '-Ibin/default/lib/param',
140 '-Ibin/default/librpc/gen_ndr',
141 '-Ibin/default/lib/util',
142 '-Ibin/default/source3/include',
143 '-Ibin/default/source3/librpc/gen_ndr',
144 '-Ibin/default/source3/param',
145 '-Ibin/default/source4/auth',
146 '-Ibin/default/source4/auth/gensec',
147 '-Ibin/default/source4/auth/kerberos',
148 '-Ibin/default/source4/auth/ntlm',
149 '-Ibin/default/source4/cldap_server',
150 '-Ibin/default/source4/dsdb/common',
151 '-Ibin/default/source4/dsdb/kcc',
152 '-Ibin/default/source4/dsdb/repl',
153 '-Ibin/default/source4/dsdb/samdb',
154 '-Ibin/default/source4/dsdb/samdb/ldb_modules',
155 '-Ibin/default/source4/dsdb/schema',
156 '-Ibin/default/source4/heimdal/kdc',
157 '-Ibin/default/source4/heimdal/lib/asn1',
158 '-Ibin/default/source4/heimdal/lib/gssapi',
159 '-Ibin/default/source4/heimdal/lib/gssapi/krb5',
160 '-Ibin/default/source4/heimdal/lib/gssapi/spnego',
161 '-Ibin/default/source4/heimdal/lib/hdb',
162 '-Ibin/default/source4/heimdal/lib/hx509',
163 '-Ibin/default/source4/heimdal/lib/krb5',
164 '-Ibin/default/source4/heimdal/lib/ntlm',
165 '-Ibin/default/source4/heimdal/lib/wind',
166 '-Ibin/default/source4/ldap_server',
167 '-Ibin/default/source4/libcli',
168 '-Ibin/default/source4/libcli/composite',
169 '-Ibin/default/source4/libcli/ldap',
170 '-Ibin/default/source4/libcli/rap',
171 '-Ibin/default/source4/libcli/raw',
172 '-Ibin/default/source4/libcli/resolve',
173 '-Ibin/default/source4/libcli/smb2',
174 '-Ibin/default/source4/libcli/util',
175 '-Ibin/default/source4/libcli/wrepl',
176 '-Ibin/default/source4/lib/cmdline',
177 '-Ibin/default/source4/libnet',
178 '-Ibin/default/source4/lib/registry',
179 '-Ibin/default/source4/lib/registry/tests',
180 '-Ibin/default/source4/lib/registry/tools',
181 '-Ibin/default/source4/librpc/gen_ndr',
182 '-Ibin/default/source4/librpc/rpc',
183 '-Ibin/default/source4/lib/socket',
184 '-Ibin/default/source4/nbt_server',
185 '-Ibin/default/source4/nbt_server/dgram',
186 '-Ibin/default/source4/nbt_server/wins',
187 '-Ibin/default/source4/ntptr',
188 '-Ibin/default/source4/ntvfs',
189 '-Ibin/default/source4/ntvfs/cifs_posix_cli',
190 '-Ibin/default/source4/ntvfs/common',
191 '-Ibin/default/source4/ntvfs/ipc',
192 '-Ibin/default/source4/ntvfs/posix',
193 '-Ibin/default/source4/ntvfs/simple',
194 '-Ibin/default/source4/rpc_server',
195 '-Ibin/default/source4/rpc_server/backupkey',
196 '-Ibin/default/source4/rpc_server/common',
197 '-Ibin/default/source4/rpc_server/lsa',
198 '-Ibin/default/source4/rpc_server/samr',
199 '-Ibin/default/source4/rpc_server/srvsvc',
200 '-Ibin/default/source4/smbd',
201 '-Ibin/default/source4/smb_server',
202 '-Ibin/default/source4/smb_server/smb',
203 '-Ibin/default/source4/smb_server/smb2',
204 '-Ibin/default/source4/torture/auth',
205 '-Ibin/default/source4/torture/basic',
206 '-Ibin/default/source4/torture/dfs',
207 '-Ibin/default/source4/torture/drs',
208 '-Ibin/default/source4/torture/ldap',
209 '-Ibin/default/source4/torture/libnet',
210 '-Ibin/default/source4/torture/libnetapi',
211 '-Ibin/default/source4/torture/libsmbclient',
212 '-Ibin/default/source4/torture/local',
213 '-Ibin/default/source4/torture/nbench',
214 '-Ibin/default/source4/torture/nbt',
215 '-Ibin/default/source4/torture/ndr',
216 '-Ibin/default/source4/torture/ntp',
217 '-Ibin/default/source4/torture/rap',
218 '-Ibin/default/source4/torture/raw',
219 '-Ibin/default/source4/torture/rpc',
220 '-Ibin/default/source4/torture/smb2',
221 '-Ibin/default/source4/torture/unix',
222 '-Ibin/default/source4/torture/winbind',
223 '-Ibin/default/source4/winbind',
224 '-Ibin/default/source4/wrepl_server',
225 '-Ibin/default/testsuite/headers',
228 # Set this to the absolute path to the folder (NOT the file!) containing the
229 # compile_commands.json file to use that instead of 'flags'. See here for
230 # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
232 # Most projects will NOT need to set this to anything; you can just change the
233 # 'flags' list of compilation flags. Notice that YCM itself uses that approach.
234 compilation_database_folder
= ''
236 if os
.path
.exists( compilation_database_folder
):
237 database
= ycm_core
.CompilationDatabase( compilation_database_folder
)
241 SOURCE_EXTENSIONS
= [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
243 def DirectoryOfThisScript():
244 return os
.path
.dirname( os
.path
.abspath( __file__
) )
247 def MakeRelativePathsInFlagsAbsolute( flags
, working_directory
):
248 if not working_directory
:
251 make_next_absolute
= False
252 path_flags
= [ '-isystem', '-I', '-iquote', '--sysroot=' ]
256 if make_next_absolute
:
257 make_next_absolute
= False
258 if not flag
.startswith( '/' ):
259 new_flag
= os
.path
.join( working_directory
, flag
)
261 for path_flag
in path_flags
:
262 if flag
== path_flag
:
263 make_next_absolute
= True
266 if flag
.startswith( path_flag
):
267 path
= flag
[ len( path_flag
): ]
268 new_flag
= path_flag
+ os
.path
.join( working_directory
, path
)
272 new_flags
.append( new_flag
)
276 def IsHeaderFile( filename
):
277 extension
= os
.path
.splitext( filename
)[ 1 ]
278 return extension
in [ '.h', '.hxx', '.hpp', '.hh' ]
281 def GetCompilationInfoForFile( filename
):
282 # The compilation_commands.json file generated by CMake does not have entries
283 # for header files. So we do our best by asking the db for flags for a
284 # corresponding source file, if any. If one exists, the flags for that file
285 # should be good enough.
286 if IsHeaderFile( filename
):
287 basename
= os
.path
.splitext( filename
)[ 0 ]
288 for extension
in SOURCE_EXTENSIONS
:
289 replacement_file
= basename
+ extension
290 if os
.path
.exists( replacement_file
):
291 compilation_info
= database
.GetCompilationInfoForFile(
293 if compilation_info
.compiler_flags_
:
294 return compilation_info
296 return database
.GetCompilationInfoForFile( filename
)
299 def FlagsForFile( filename
, **kwargs
):
301 # Bear in mind that compilation_info.compiler_flags_ does NOT return a
302 # python list, but a "list-like" StringVec object
303 compilation_info
= GetCompilationInfoForFile( filename
)
304 if not compilation_info
:
307 final_flags
= MakeRelativePathsInFlagsAbsolute(
308 compilation_info
.compiler_flags_
,
309 compilation_info
.compiler_working_dir_
)
311 relative_to
= DirectoryOfThisScript()
312 final_flags
= MakeRelativePathsInFlagsAbsolute( flags
, relative_to
)
315 'flags': final_flags
,