Remove unused bluetooth.target
[platform/upstream/systemd.git] / .ycm_extra_conf.py
1 import itertools
2 import os
3 import subprocess
4
5 def GetFlagsFromMakefile(varname):
6   return subprocess.check_output([
7       "make", "-s", "print-%s" % varname]).decode().split()
8
9
10 def Flatten(lists):
11   return list(itertools.chain.from_iterable(lists))
12
13
14 def DirectoryOfThisScript():
15   return os.path.dirname(os.path.abspath(__file__))
16
17
18 def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
19   if not working_directory:
20     return flags
21   new_flags = []
22   make_next_absolute = False
23   path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
24   for flag in flags:
25     new_flag = flag
26
27     if make_next_absolute:
28       make_next_absolute = False
29       if not flag.startswith('/'):
30         new_flag = os.path.join(working_directory, flag)
31
32     for path_flag in path_flags:
33       if flag == path_flag:
34         make_next_absolute = True
35         break
36
37       if flag.startswith(path_flag):
38         path = flag[ len(path_flag): ]
39         new_flag = path_flag + os.path.join(working_directory, path)
40         break
41
42     if new_flag:
43       new_flags.append(new_flag)
44   return new_flags
45
46
47 def FlagsForFile(filename):
48   relative_to = DirectoryOfThisScript()
49
50   return {
51     'flags': MakeRelativePathsInFlagsAbsolute(flags, relative_to),
52     'do_cache': True
53   }
54
55 flags = Flatten(map(GetFlagsFromMakefile, [
56   'AM_CPPFLAGS',
57   'CPPFLAGS',
58   'AM_CFLAGS',
59   'CFLAGS',
60 ]))
61
62 # these flags cause crashes in libclang, so remove them
63 flags.remove('-Wlogical-op')
64 flags.remove('-Wsuggest-attribute=noreturn')
65 flags.remove('-Wdate-time')
66
67 # vim: set et ts=2 sw=2: