SL-821: Create macOS symbol-file archive while packaging.

meow-7.2.2
Nat Goodspeed 2018-06-14 10:55:38 -04:00
parent c32ede22bb
commit 5caeacb3f6
1 changed files with 53 additions and 14 deletions

View File

@ -26,19 +26,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
$/LicenseInfo$
"""
import sys
import os
import os.path
import shutil
import errno
import json
import os
import os.path
import plistlib
import random
import re
import shutil
import stat
import subprocess
import sys
import tarfile
import time
import zipfile
viewer_dir = os.path.dirname(__file__)
# Add indra/lib/python to our path so we don't have to muck with PYTHONPATH.
@ -903,6 +904,9 @@ class DarwinManifest(ViewerManifest):
launcher_app, launcher_icon = "Second Life Launcher.app", "secondlife.icns"
viewer_app, viewer_icon = "Second Life Viewer.app", "secondlife.icns"
# capture the path to the directory containing toplevel_app
parentdir = os.path.join(self.get_dst_prefix(), os.pardir)
# copy over the build result (this is a no-op if run within the xcode script)
self.path(os.path.join(self.args['configuration'], toplevel_app), dst="")
@ -914,10 +918,12 @@ class DarwinManifest(ViewerManifest):
# top-level Second Life application is only a container
with self.prefix(src="", dst="Contents"): # everything goes in Contents
# top-level Info.plist is as generated by CMake
Info_plist = "Info.plist"
## This self.path() call reports 0 files... skip?
self.path(Info_plist)
Info_plist = self.dst_path_of(Info_plist)
Info_plist = self.dst_path_of("Info.plist")
# except we twiddle these entries
Info = plistlib.readPlist(Info_plist)
Info["CFBundleGetInfoString"] = self.channel()
Info["CFBundleShortVersionString"] = '.'.join(self.args['version'])
plistlib.writePlist(Info, Info_plist)
# the one file in top-level MacOS directory is the trampoline to
# our nested launcher_app
@ -1046,14 +1052,47 @@ open "%s" --args "$@"
# now do it, only without relativizing paths
os.rename(fromwhere, towhere)
# NOTE: the -S argument to strip causes it to keep
# enough info for annotated backtraces (i.e. function
# names in the crash log). 'strip' with no arguments
# yields a slightly smaller binary but makes crash
# logs mostly useless. This may be desirable for the
# final release. Or not.
if ("package" in self.args['actions'] or
"unpacked" in self.args['actions']):
# only if we're engaging BugSplat
if "BUGSPLAT_DB" in os.environ:
# Create a symbol archive BEFORE stripping the
# binary.
self.run_command(['dsymutil', os.path.join(here, 'Second Life')])
# This should produce a Second Life.dSYM bundle directory.
try:
# Now pretend we're Xcode making a .xcarchive file.
# Put it as a sibling of the top-level .app.
# From "Dave" at BugSplat support:
# "More from our Mac lead: I think zipping
# a folder containing the binary and
# symbols would be sufficient. Assuming
# symbol files are created with CMake. I'm
# not sure if CMake strips symbols into
# separate files at build time, and if so
# they're in a supported format."
xcarchive = os.path.join(parentdir,
'Second Life.xcarchive.zip')
with zipfile.ZipFile(xcarchive, 'w',
compression=zipfile.ZIP_DEFLATED) as zf:
print "Creating {}".format(xcarchive)
for base, dirs, files in os.walk(here):
for fn in files:
fullfn = os.path.join(base, fn)
relfn = os.path.relpath(fullfn, here)
print " {}".format(relfn)
zf.write(fullfn, relfn)
finally:
# Whether or not we were able to create the
# .xcarchive file, clean up the .dSYM bundle
shutil.rmtree(os.path.join(here, 'Second Life.dSYM'))
# NOTE: the -S argument to strip causes it to keep
# enough info for annotated backtraces (i.e. function
# names in the crash log). 'strip' with no arguments
# yields a slightly smaller binary but makes crash
# logs mostly useless. This may be desirable for the
# final release. Or not.
self.run_command(
['strip', '-S', self.dst_path_of('Second Life')])