aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-06-07 23:39:09 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-06-07 23:39:09 +0300
commit9323aa3ae3df5c9d2cae14cde6230bcc899c3b99 (patch)
treea3079576e6f350a768923b1a698ea19ff4c16667
parent01a387bc46dec8a35d9810e7fc86df9a6951cc49 (diff)
downloadmeson-9323aa3ae3df5c9d2cae14cde6230bcc899c3b99.zip
meson-9323aa3ae3df5c9d2cae14cde6230bcc899c3b99.tar.gz
meson-9323aa3ae3df5c9d2cae14cde6230bcc899c3b99.tar.bz2
Made symbol extractor work on OSX.
-rwxr-xr-xenvironment.py2
-rwxr-xr-xsymbolextractor.py24
2 files changed, 23 insertions, 3 deletions
diff --git a/environment.py b/environment.py
index 46aa349..af0c9e7 100755
--- a/environment.py
+++ b/environment.py
@@ -1,4 +1,4 @@
- #!/usr/bin/python3 -tt
+#!/usr/bin/python3 -tt
# Copyright 2012 Jussi Pakkanen
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)