tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

check-libstdc++.py (1205B)


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