rpc: Always supply both the remote and local address to the auth subsystem
[Samba.git] / .ycm_extra_conf.py
blob580669bddeb366ebedb3f02a05f705e6e703a5a8
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 '-Iinclude',
53 '-Iinclude/public',
54 '-Ilib',
55 '-Ilib/replace',
56 '-Isource3',
57 '-Isource3/include',
58 '-Isource3/lib',
59 '-Isource4',
60 '-Isource4/include',
61 '-Isource4/lib',
62 '-Ibin/default',
63 '-Ibin/default/include',
64 '-Ibin/default/include/public',
65 '-Ibin/default/lib',
66 '-Ibin/default/lib/replace',
67 '-Ibin/default/source3',
68 '-Ibin/default/source3/include',
69 '-Ibin/default/source3/lib',
70 '-Ibin/default/source4',
71 '-Ibin/default/source4/include',
72 '-Ibin/default/source4/lib',
73 '-Wall',
74 '-Wcast-align',
75 '-Wcast-qual',
76 '-Wdeclaration-after-statement',
77 '-Werror',
78 '-Werror-implicit-function-declaration',
79 '-Werror=address',
80 '-Werror=declaration-after-statement',
81 '-Werror=format',
82 '-Werror=format-security',
83 '-Werror=pointer-arith',
84 '-Werror=return-type',
85 '-Werror=strict-prototypes',
86 '-Werror=uninitialized',
87 '-Werror=write-strings',
88 '-Wformat-security',
89 '-Wformat=2',
90 '-Wmissing-prototypes',
91 '-Wno-error=deprecated-declarations',
92 '-Wno-error=tautological-compare',
93 '-Wno-format-y2k',
94 '-Wpointer-arith',
95 '-Wreturn-type',
96 '-Wshadow',
97 '-Wstrict-prototypes',
98 '-Wuninitialized',
99 '-Wwrite-strings',
103 # Set this to the absolute path to the folder (NOT the file!) containing the
104 # compile_commands.json file to use that instead of 'flags'. See here for
105 # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
107 # You can get CMake to generate this file for you by adding:
108 # set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
109 # to your CMakeLists.txt file.
111 # Most projects will NOT need to set this to anything; you can just change the
112 # 'flags' list of compilation flags. Notice that YCM itself uses that approach.
113 compilation_database_folder = ''
115 if os.path.exists( compilation_database_folder ):
116 database = ycm_core.CompilationDatabase( compilation_database_folder )
117 else:
118 database = None
120 SOURCE_EXTENSIONS = [ '.C', '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
122 def DirectoryOfThisScript():
123 return os.path.dirname( os.path.abspath( __file__ ) )
126 def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
127 if not working_directory:
128 return list( flags )
129 new_flags = []
130 make_next_absolute = False
131 path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
132 for flag in flags:
133 new_flag = flag
135 if make_next_absolute:
136 make_next_absolute = False
137 if not flag.startswith( '/' ):
138 new_flag = os.path.join( working_directory, flag )
140 for path_flag in path_flags:
141 if flag == path_flag:
142 make_next_absolute = True
143 break
145 if flag.startswith( path_flag ):
146 path = flag[ len( path_flag ): ]
147 new_flag = path_flag + os.path.join( working_directory, path )
148 break
150 if new_flag:
151 new_flags.append( new_flag )
152 return new_flags
155 def IsHeaderFile( filename ):
156 extension = os.path.splitext( filename )[ 1 ]
157 return extension in [ '.H', '.h', '.hxx', '.hpp', '.hh' ]
160 def GetCompilationInfoForFile( filename ):
161 # The compilation_commands.json file generated by CMake does not have entries
162 # for header files. So we do our best by asking the db for flags for a
163 # corresponding source file, if any. If one exists, the flags for that file
164 # should be good enough.
165 if IsHeaderFile( filename ):
166 basename = os.path.splitext( filename )[ 0 ]
167 for extension in SOURCE_EXTENSIONS:
168 replacement_file = basename + extension
169 if os.path.exists( replacement_file ):
170 compilation_info = database.GetCompilationInfoForFile(
171 replacement_file )
172 if compilation_info.compiler_flags_:
173 return compilation_info
174 return None
175 return database.GetCompilationInfoForFile( filename )
178 def FlagsForFile( filename, **kwargs ):
179 if database:
180 # Bear in mind that compilation_info.compiler_flags_ does NOT return a
181 # python list, but a "list-like" StringVec object
182 compilation_info = GetCompilationInfoForFile( filename )
183 if not compilation_info:
184 return None
186 final_flags = MakeRelativePathsInFlagsAbsolute(
187 compilation_info.compiler_flags_,
188 compilation_info.compiler_working_dir_ )
189 else:
190 relative_to = DirectoryOfThisScript()
191 final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
193 return {
194 'flags': final_flags,
195 'do_cache': True