1# Generated by YCM Generator at 2015-06-04 16:56:30.936482
2
3# This file is NOT licensed under the GPLv3, which is the license for the rest
4# of YouCompleteMe.
5#
6# Here's the license text for this file:
7#
8# This is free and unencumbered software released into the public domain.
9#
10# Anyone is free to copy, modify, publish, use, compile, sell, or
11# distribute this software, either in source code form or as a compiled
12# binary, for any purpose, commercial or non-commercial, and by any
13# means.
14#
15# In jurisdictions that recognize copyright laws, the author or authors
16# of this software dedicate any and all copyright interest in the
17# software to the public domain. We make this dedication for the benefit
18# of the public at large and to the detriment of our heirs and
19# successors. We intend this dedication to be an overt act of
20# relinquishment in perpetuity of all present and future rights to this
21# software under copyright law.
22#
23# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29# OTHER DEALINGS IN THE SOFTWARE.
30#
31# For more information, please refer to <http://unlicense.org/>
32
33import os
34import ycm_core
35
36flags = [
37    '-x',
38    'c++',
39    '-DIQ_TREE',
40    '-D_IQTREE_MPI',
41    '-D__AVX',
42    '-D__SSE3',
43    '-I/home/CIBIV/tung/Dropbox/CODE_GIT_REPO/iqtree',
44    '-I/tmp/tmp6htKo0',
45    '-I/tmp/tmp6htKo0/zlib-1.2.7',
46]
47
48
49# Set this to the absolute path to the folder (NOT the file!) containing the
50# compile_commands.json file to use that instead of 'flags'. See here for
51# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
52#
53# You can get CMake to generate this file for you by adding:
54#   set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
55# to your CMakeLists.txt file.
56#
57# Most projects will NOT need to set this to anything; you can just change the
58# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
59compilation_database_folder = ''
60
61if os.path.exists( compilation_database_folder ):
62  database = ycm_core.CompilationDatabase( compilation_database_folder )
63else:
64  database = None
65
66SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
67
68def DirectoryOfThisScript():
69  return os.path.dirname( os.path.abspath( __file__ ) )
70
71
72def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
73  if not working_directory:
74    return list( flags )
75  new_flags = []
76  make_next_absolute = False
77  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
78  for flag in flags:
79    new_flag = flag
80
81    if make_next_absolute:
82      make_next_absolute = False
83      if not flag.startswith( '/' ):
84        new_flag = os.path.join( working_directory, flag )
85
86    for path_flag in path_flags:
87      if flag == path_flag:
88        make_next_absolute = True
89        break
90
91      if flag.startswith( path_flag ):
92        path = flag[ len( path_flag ): ]
93        new_flag = path_flag + os.path.join( working_directory, path )
94        break
95
96    if new_flag:
97      new_flags.append( new_flag )
98  return new_flags
99
100
101def IsHeaderFile( filename ):
102  extension = os.path.splitext( filename )[ 1 ]
103  return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
104
105
106def GetCompilationInfoForFile( filename ):
107  # The compilation_commands.json file generated by CMake does not have entries
108  # for header files. So we do our best by asking the db for flags for a
109  # corresponding source file, if any. If one exists, the flags for that file
110  # should be good enough.
111  if IsHeaderFile( filename ):
112    basename = os.path.splitext( filename )[ 0 ]
113    for extension in SOURCE_EXTENSIONS:
114      replacement_file = basename + extension
115      if os.path.exists( replacement_file ):
116        compilation_info = database.GetCompilationInfoForFile(
117          replacement_file )
118        if compilation_info.compiler_flags_:
119          return compilation_info
120    return None
121  return database.GetCompilationInfoForFile( filename )
122
123
124def FlagsForFile( filename, **kwargs ):
125  if database:
126    # Bear in mind that compilation_info.compiler_flags_ does NOT return a
127    # python list, but a "list-like" StringVec object
128    compilation_info = GetCompilationInfoForFile( filename )
129    if not compilation_info:
130      return None
131
132    final_flags = MakeRelativePathsInFlagsAbsolute(
133      compilation_info.compiler_flags_,
134      compilation_info.compiler_working_dir_ )
135
136  else:
137    relative_to = DirectoryOfThisScript()
138    final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
139
140  return {
141    'flags': final_flags,
142    'do_cache': True
143  }
144
145