FRESH AND RAW
[potpourri.git] / SConsStuff.py
blob787df5ad4efaa6a2fb525459c758119008789116
1 import os
2 from types import *
4 def pkg_config(package, prefix=""):
6 if type(package) is StringType:
8 command2 = ("""bash -c 'PKG_CONFIG_PATH=\"""" + prefix +
9 """\" pkg-config --cflags """ + package + """' """)
11 pkgpipe = os.popen(command2)
12 flags = (pkgpipe.read())[:-1]
13 pkgpipe.close()
15 slash_en = '\\n'
17 command1 = ("""bash -c 'PKG_CONFIG_PATH=\"""" +
18 prefix + """\" pkg-config --libs """ + package +
19 """ | sed -e "s/-l/""" + slash_en +
20 """LIB /g" | grep LIB | sed -e "s/LIB //g" | tr -d " "'""")
22 pkgpipe = os.popen(command1)
23 libs = (pkgpipe.read().split('\n'))[1:-1]
24 pkgpipe.close()
26 return [flags, libs]
28 if type(package) is TupleType or type(package) is ListType:
30 results = ['', []]
32 for input in package:
33 result = pkg_config(input, prefix)
35 if len(result):
36 results[0] += result[0]
37 results[1] += result[1]
39 return results
41 def other_command(command):
43 command_pipe = os.popen(command)
44 results = (command_pipe.read())[:-1]
45 command_pipe.close()
47 return results