Imported Upstream version 2.6.7
[platform/upstream/harfbuzz.git] / src / check-libstdc++.py
1 #!/usr/bin/env python3
2
3 import sys, os, shutil, subprocess
4
5 os.chdir (os.environ.get ('srcdir', os.path.dirname (__file__)))
6
7 libs = os.environ.get ('libs', '.libs')
8
9 ldd = shutil.which ('ldd')
10 if ldd:
11         ldd = [ldd]
12 else:
13         ldd = shutil.which ('otool')
14         if ldd:
15                 ldd = [ldd, '-L'] # otool -L
16         else:
17                 print ('check-libstdc++.py: \'ldd\' not found; skipping test')
18                 sys.exit (77)
19
20 stat = 0
21 tested = False
22
23 # harfbuzz-icu links to libstdc++ because icu does.
24 for soname in ['harfbuzz', 'harfbuzz-subset', 'harfbuzz-gobject']:
25         for suffix in ['so', 'dylib']:
26                 so = os.path.join (libs, 'lib%s.%s' % (soname, suffix))
27                 if not os.path.exists (so): continue
28
29                 print ('Checking that we are not linking to libstdc++ or libc++ in %s' % so)
30                 ldd_result = subprocess.check_output (ldd + [so])
31                 if (b'libstdc++' in ldd_result) or (b'libc++' in ldd_result):
32                         print ('Ouch, %s is linked to libstdc++ or libc++' % so)
33                         stat = 1
34
35                 tested = True
36
37 if not tested:
38         print ('check-libstdc++.py: libharfbuzz shared library not found; skipping test')
39         sys.exit (77)
40
41 sys.exit (stat)