-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_compile_commands.py
35 lines (25 loc) · 982 Bytes
/
make_compile_commands.py
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
# Run this file to make a compile_commands.json file in your project root directory
# The compile_commands.json generated by cmake has info for all binaries but not the header files
# Due to that there might be squiggles in ide while working with some ides
# https://pypi.org/project/compdb/
# This script will use compdb to generate compile_commands.json file
# which will have header information as well
# Running format : python make_compile_commands.py (<build_directory>)?
import sys
import subprocess
try:
import compdb
except:
p = subprocess.Popen(['pip', 'install', 'compdb', '--user'])
p.wait()
import compdb
def main():
build = "build"
if(len(sys.argv) >= 2):
build = sys.argv[1]
process = subprocess.Popen(
['compdb', '-p', build, 'list'], stdout=subprocess.PIPE)
text = process.communicate()[0]
open('compile_commands.json', 'wb').write(text)
print("Wrote compile_commands.json successfully")
main()