]> git.ipfire.org Git - thirdparty/systemd.git/blame - .ycm_extra_conf.py
journal: coalesce ftruncate()s in 250ms windows
[thirdparty/systemd.git] / .ycm_extra_conf.py
CommitLineData
0d8efe35 1import itertools
328b5bc9 2import os
0d8efe35
DR
3import subprocess
4
5def GetFlagsFromMakefile(varname):
6 return subprocess.check_output([
7 "make", "-s", "print-%s" % varname]).decode().split()
8
9
10def Flatten(lists):
11 return list(itertools.chain.from_iterable(lists))
328b5bc9
DR
12
13
14def DirectoryOfThisScript():
15 return os.path.dirname(os.path.abspath(__file__))
16
17
18def 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
47def FlagsForFile(filename):
0d8efe35 48 relative_to = DirectoryOfThisScript()
328b5bc9
DR
49
50 return {
0d8efe35 51 'flags': MakeRelativePathsInFlagsAbsolute(flags, relative_to),
328b5bc9
DR
52 'do_cache': True
53 }
0d8efe35
DR
54
55flags = 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
63flags.remove('-Wlogical-op')
64flags.remove('-Wsuggest-attribute=noreturn')
d0069261 65flags.remove('-Wdate-time')
0d8efe35
DR
66
67# vim: set et ts=2 sw=2: