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