Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/harfbuzz/src/check-static-inits.py @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 #!/usr/bin/env python3 | |
| 2 | |
| 3 import sys, os, shutil, subprocess, glob, re | |
| 4 | |
| 5 builddir = os.getenv ('builddir', os.path.dirname (__file__)) | |
| 6 libs = os.getenv ('libs', '.libs') | |
| 7 | |
| 8 objdump = os.getenv ('OBJDUMP', shutil.which ('objdump')) | |
| 9 if not objdump: | |
| 10 print ('check-static-inits.py: \'ldd\' not found; skipping test') | |
| 11 sys.exit (77) | |
| 12 | |
| 13 if sys.version_info < (3, 5): | |
| 14 print ('check-static-inits.py: needs python 3.5 for recursive support in glob') | |
| 15 sys.exit (77) | |
| 16 | |
| 17 OBJS = glob.glob (os.path.join (builddir, libs, '**', '*hb*.o'), recursive=True) | |
| 18 if not OBJS: | |
| 19 print ('check-static-inits.py: object files not found; skipping test') | |
| 20 sys.exit (77) | |
| 21 | |
| 22 stat = 0 | |
| 23 tested = 0 | |
| 24 | |
| 25 for obj in OBJS: | |
| 26 result = subprocess.run(objdump.split () + ['-t', obj], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| 27 | |
| 28 if result.returncode: | |
| 29 if result.stderr.find (b'not recognized') != -1: | |
| 30 # https://github.com/harfbuzz/harfbuzz/issues/3019 | |
| 31 print ('objdump %s returned "not recognized", skipping' % obj) | |
| 32 continue | |
| 33 print ('objdump %s returned error:\n%s' % (obj, result.stderr.decode ('utf-8'))) | |
| 34 stat = 2 | |
| 35 | |
| 36 result = result.stdout.decode ('utf-8') | |
| 37 | |
| 38 # Checking that no object file has static initializers | |
| 39 for l in re.findall (r'^.*\.[cd]tors.*$', result, re.MULTILINE): | |
| 40 if not re.match (r'.*\b0+\b', l): | |
| 41 print ('Ouch, %s has static initializers/finalizers' % obj) | |
| 42 stat = 1 | |
| 43 | |
| 44 # Checking that no object file has lazy static C++ constructors/destructors or other such stuff | |
| 45 if ('__cxa_' in result) and ('__ubsan_handle' not in result): | |
| 46 print ('Ouch, %s has lazy static C++ constructors/destructors or other such stuff' % obj) | |
| 47 stat = 1 | |
| 48 | |
| 49 tested += 1 | |
| 50 | |
| 51 sys.exit (stat if tested else 77) |
