-
-
Notifications
You must be signed in to change notification settings - Fork 244
/
getinclude.py
executable file
·39 lines (29 loc) · 947 Bytes
/
getinclude.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
36
37
38
39
#! /usr/bin/env python
#
#
# C++ Insights, copyright (C) by Andreas Fertig
# Distributed under an MIT license. See LICENSE for details
#
#------------------------------------------------------------------------------
import os
import sys
import subprocess
import re
def main():
cxx = 'g++'
if 2 == len(sys.argv):
cxx = sys.argv[1]
cmd = [cxx, '-E', '-x', 'c++', '-v', '/dev/null']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
m = re.findall(b'\n (/.*)', stderr)
includes = ''
for x in m:
if -1 != x.find(b'(framework directory)'):
continue
includes += '-isystem%s ' % os.path.normpath(x.decode())
print(includes)
return 1
#------------------------------------------------------------------------------
sys.exit(main())
#------------------------------------------------------------------------------