diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-07 23:39:09 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-06-07 23:39:09 +0300 |
commit | 9323aa3ae3df5c9d2cae14cde6230bcc899c3b99 (patch) | |
tree | a3079576e6f350a768923b1a698ea19ff4c16667 /symbolextractor.py | |
parent | 01a387bc46dec8a35d9810e7fc86df9a6951cc49 (diff) | |
download | meson-9323aa3ae3df5c9d2cae14cde6230bcc899c3b99.zip meson-9323aa3ae3df5c9d2cae14cde6230bcc899c3b99.tar.gz meson-9323aa3ae3df5c9d2cae14cde6230bcc899c3b99.tar.bz2 |
Made symbol extractor work on OSX.
Diffstat (limited to 'symbolextractor.py')
-rwxr-xr-x | symbolextractor.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/symbolextractor.py b/symbolextractor.py index ef08cf3..f4fddf7 100755 --- a/symbolextractor.py +++ b/symbolextractor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 -tt +#!/usr/bin/env python3 # Copyright 2013 Jussi Pakkanen @@ -49,12 +49,32 @@ def linux_syms(libfilename, outfilename): output = pnm.communicate()[0].decode() if pnm.returncode != 0: raise RuntimeError('nm does not work.') - result += [x.split()[0] for x in output.split('\n') if len(x) > 0] + result += [' '.join(x.split()[0:2]) for x in output.split('\n') if len(x) > 0] + write_if_changed('\n'.join(result) + '\n', outfilename) + +def osx_syms(libfilename, outfilename): + pe = subprocess.Popen(['otool', '-l', libfilename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output = pe.communicate()[0].decode() + if pe.returncode != 0: + raise RuntimeError('Otool does not work.') + arr = output.split('\n') + for (i, val) in enumerate(arr): + if 'LC_ID_DYLIB' in val: + match = i + break + result = [arr[match+2], arr[match+5]] # Libreoffice stores all 5 lines but the others seem irrelevant. + pnm = subprocess.Popen(['nm', '-g', '-P', libfilename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output = pnm.communicate()[0].decode() + if pnm.returncode != 0: + raise RuntimeError('nm does not work.') + result += [' '.join(x.split()[0:2]) for x in output.split('\n') if len(x) > 0 and not x.endswith('U')] write_if_changed('\n'.join(result) + '\n', outfilename) def gen_symbols(libfilename, outfilename): if platform.system() == 'Linux': linux_syms(libfilename, outfilename) + if platform.system() == 'Darwin': + osx_syms(libfilename, outfilename) else: dummy_syms(outfilename) |