-
Notifications
You must be signed in to change notification settings - Fork 12
/
mkycmflags
executable file
·60 lines (49 loc) · 1.31 KB
/
mkycmflags
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
import os
import subprocess
import sys
clang_version = 5.0
packages = ("gtk+-3.0", "vte-2.91", "libpcre2-8", "dbus-1", "dbus-glib-1")
lang = "c"
std = "c99"
localincs = ("build/src",)
clang_bin = "/usr/bin/clang-" + str(clang_version)
here = os.path.abspath(os.path.dirname(sys.argv[0]))
output = os.path.join(here, ".ycm_extra_conf.py")
flags = []
subprocess.call( \
clang_bin + " -E -x" + lang + " -std=" + std + \
" -v - < /dev/null >/dev/null 2>" + \
output,
shell = True)
fp = open(output, 'r')
inc = False
for l in fp.readlines():
l = l.strip()
if inc:
if l.startswith("End"):
break
else:
flags.extend(["-isystem", l])
elif l.startswith("#include <"):
inc = True
fp.close()
os.unlink(output)
subprocess.call("/usr/bin/pkg-config --cflags " + " ".join(packages) +
" > " + output, shell = True)
fp = open(output, 'r')
flags.extend(fp.read().strip().split())
fp.close()
for d in localincs:
flags.append("-I" + os.path.join(here, d))
flags.extend(["-I.", "-Wall", "-Wextra", "-x"+lang, "-std="+std])
os.unlink(output)
fp = open(output, 'w')
fp.write( \
"""def FlagsForFile(filename, **Kwargs):
return {
"flags": """ + str(flags) + """,
"do_cache": True
}
""")
fp.close()