getinclude.py
Go to the documentation of this file.
1#! /usr/bin/env python
2#
3#
4# C++ Insights, copyright (C) by Andreas Fertig
5# Distributed under an MIT license. See LICENSE for details
6#
7#------------------------------------------------------------------------------
8
9import os
10import sys
11import subprocess
12import re
13
14def main():
15 cxx = 'g++'
16 if 2 == len(sys.argv):
17 cxx = sys.argv[1]
18
19 cmd = [cxx, '-E', '-x', 'c++', '-v', '/dev/null']
20 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
21 stdout, stderr = p.communicate()
22
23 m = re.findall(b'\n (/.*)', stderr)
24
25 includes = ''
26
27 for x in m:
28 if -1 != x.find(b'(framework directory)'):
29 continue
30
31 includes += '-isystem%s ' % os.path.normpath(x.decode())
32
33 print(includes)
34
35 return 1
36#------------------------------------------------------------------------------
37
38sys.exit(main())
39#------------------------------------------------------------------------------