Ebrahim Byagowi | 7250ade | 2020-05-29 12:34:30 +0430 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | import sys, os, shutil, subprocess |
| 4 | |
Ebrahim Byagowi | a07672d | 2020-07-04 14:12:55 +0430 | [diff] [blame] | 5 | os.chdir (os.getenv ('srcdir', os.path.dirname (__file__))) |
Ebrahim Byagowi | 7250ade | 2020-05-29 12:34:30 +0430 | [diff] [blame] | 6 | |
Ebrahim Byagowi | a07672d | 2020-07-04 14:12:55 +0430 | [diff] [blame] | 7 | libs = os.getenv ('libs', '.libs') |
Ebrahim Byagowi | 7250ade | 2020-05-29 12:34:30 +0430 | [diff] [blame] | 8 | |
Behdad Esfahbod | 13c6ad9 | 2021-06-12 11:00:19 -0600 | [diff] [blame] | 9 | ldd = os.getenv ('LDD', shutil.which ('ldd')) |
| 10 | if not ldd: |
| 11 | otool = os.getenv ('OTOOL', shutil.which ('otool')) |
| 12 | if otool: |
| 13 | ldd = otool + ' -L' |
Ebrahim Byagowi | 7250ade | 2020-05-29 12:34:30 +0430 | [diff] [blame] | 14 | else: |
| 15 | print ('check-libstdc++.py: \'ldd\' not found; skipping test') |
| 16 | sys.exit (77) |
| 17 | |
| 18 | stat = 0 |
| 19 | tested = False |
| 20 | |
| 21 | # harfbuzz-icu links to libstdc++ because icu does. |
| 22 | for soname in ['harfbuzz', 'harfbuzz-subset', 'harfbuzz-gobject']: |
| 23 | for suffix in ['so', 'dylib']: |
| 24 | so = os.path.join (libs, 'lib%s.%s' % (soname, suffix)) |
| 25 | if not os.path.exists (so): continue |
| 26 | |
| 27 | print ('Checking that we are not linking to libstdc++ or libc++ in %s' % so) |
Behdad Esfahbod | 13c6ad9 | 2021-06-12 11:00:19 -0600 | [diff] [blame] | 28 | ldd_result = subprocess.check_output (ldd.split() + [so]) |
Ebrahim Byagowi | 7250ade | 2020-05-29 12:34:30 +0430 | [diff] [blame] | 29 | if (b'libstdc++' in ldd_result) or (b'libc++' in ldd_result): |
| 30 | print ('Ouch, %s is linked to libstdc++ or libc++' % so) |
| 31 | stat = 1 |
| 32 | |
| 33 | tested = True |
| 34 | |
| 35 | if not tested: |
| 36 | print ('check-libstdc++.py: libharfbuzz shared library not found; skipping test') |
| 37 | sys.exit (77) |
| 38 | |
| 39 | sys.exit (stat) |