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 
9 import os
10 import sys
11 import subprocess
12 import re
13 
14 def 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 
38 sys.exit(main())
39 #------------------------------------------------------------------------------
def main()
Definition: getinclude.py:14