Advertisement
Guest User

Untitled

a guest
May 20th, 2013
1,510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. # This file is NOT licensed under the GPLv3, which is the license for the rest
  2. # of YouCompleteMe.
  3. #
  4. # Here's the license text for this file:
  5. #
  6. # This is free and unencumbered software released into the public domain.
  7. #
  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.
  12. #
  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.
  20. #
  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.
  28. #
  29. # For more information, please refer to <http://unlicense.org/>
  30.  
  31. import os
  32. import ycm_core
  33. from clang_helpers import PrepareClangFlags
  34.  
  35. # These are the compilation flags that will be used in case there's no
  36. # compilation database set (by default, one is not set).
  37. # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
  38.  
  39. flags = [
  40. '-x',
  41. 'objective-c',
  42. '-arch i386',
  43. '-fmessage-length=0',
  44. '-std=gnu99',
  45. '-fobjc-arc',
  46. '-Wno-trigraphs',
  47. '-fpascal-strings',
  48. '-Os',
  49. '-Wno-missing-field-initializers',
  50. '-Wno-missing-prototypes',
  51. '-Wreturn-type',
  52. '-Wno-implicit-atomic-properties',
  53. '-Wno-receiver-is-weak',
  54. '-Wduplicate-method-match',
  55. '-Wformat',
  56. '-Wno-missing-braces',
  57. '-Wparentheses',
  58. '-Wswitch',
  59. '-Wno-unused-function',
  60. '-Wno-unused-label',
  61. '-Wno-unused-parameter',
  62. '-Wunused-variable',
  63. '-Wunused-value',
  64. '-Wempty-body',
  65. '-Wuninitialized',
  66. '-Wno-unknown-pragmas',
  67. '-Wno-shadow',
  68. '-Wno-four-char-constants',
  69. '-Wno-conversion',
  70. '-Wno-constant-conversion',
  71. '-Wno-int-conversion',
  72. '-Wno-enum-conversion',
  73. '-Wno-shorten-64-to-32',
  74. '-Wpointer-sign',
  75. '-Wno-newline-eof',
  76. '-Wno-selector',
  77. '-Wno-strict-selector-match',
  78. '-Wno-undeclared-selector',
  79. '-Wno-deprecated-implementations',
  80. '-isysroot',
  81. '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk',
  82. '-fexceptions',
  83. '-fasm-blocks',
  84. '-fstrict-aliasing',
  85. '-Wprotocol',
  86. '-Wdeprecated-declarations',
  87. '-g',
  88. '-fvisibility=hidden',
  89. '-Wno-sign-conversion',
  90. '-fobjc-abi-version=2',
  91. '-fobjc-legacy-dispatch',
  92. '-mios-simulator-version-min=6.0',
  93. '-iquote',
  94. '-I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/Foundation.framework/Headers',
  95. '-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include',
  96. '-I/Users/user/another/random/folder/here',
  97. '-I/Users/user/random/folder/here',
  98. '-I/Users/random/folder/here',
  99. '-DNS_BLOCK_ASSERTIONS=1',
  100. '-MMD',
  101. '-MT',
  102. '-MF'
  103. ]
  104.  
  105. # Set this to the absolute path to the folder (NOT the file!) containing the
  106. # compile_commands.json file to use that instead of 'flags'. See here for
  107. # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
  108. #
  109. # Most projects will NOT need to set this to anything; you can just change the
  110. # 'flags' list of compilation flags. Notice that YCM itself uses that approach.
  111. compilation_database_folder = ''
  112.  
  113. if compilation_database_folder:
  114. database = ycm_core.CompilationDatabase( compilation_database_folder )
  115. else:
  116. database = None
  117.  
  118.  
  119. def DirectoryOfThisScript():
  120. return os.path.dirname( os.path.abspath( __file__ ) )
  121.  
  122.  
  123. def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
  124. if not working_directory:
  125. return flags
  126. new_flags = []
  127. make_next_absolute = False
  128. path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
  129. for flag in flags:
  130. new_flag = flag
  131.  
  132. if make_next_absolute:
  133. make_next_absolute = False
  134. if not flag.startswith( '/' ):
  135. new_flag = os.path.join( working_directory, flag )
  136.  
  137. for path_flag in path_flags:
  138. if flag == path_flag:
  139. make_next_absolute = True
  140. break
  141.  
  142. if flag.startswith( path_flag ):
  143. path = flag[ len( path_flag ): ]
  144. new_flag = path_flag + os.path.join( working_directory, path )
  145. break
  146.  
  147. if new_flag:
  148. new_flags.append( new_flag )
  149. return new_flags
  150.  
  151.  
  152. def FlagsForFile( filename ):
  153. if database:
  154. # Bear in mind that compilation_info.compiler_flags_ does NOT return a
  155. # python list, but a "list-like" StringVec object
  156. compilation_info = database.GetCompilationInfoForFile( filename )
  157. final_flags = PrepareClangFlags(
  158. MakeRelativePathsInFlagsAbsolute(
  159. compilation_info.compiler_flags_,
  160. compilation_info.compiler_working_dir_ ),
  161. filename )
  162.  
  163. # NOTE: This is just for YouCompleteMe; it's highly likely that your project
  164. # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
  165. # ycm_extra_conf IF YOU'RE NOT 100% YOU NEED IT.
  166. try:
  167. final_flags.remove( '-stdlib=libc++' )
  168. except ValueError:
  169. pass
  170. else:
  171. relative_to = DirectoryOfThisScript()
  172. final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
  173.  
  174. return {
  175. 'flags': final_flags,
  176. 'do_cache': True
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement