From 2cfa661c279b4c74b33a86bba600d02df5d2706c Mon Sep 17 00:00:00 2001
From: brad kittenbrink <brad@lindenlab.com>
Date: Thu, 27 May 2010 14:49:15 -0700
Subject: [PATCH] WIP VPLAT-248 - added a generate_breakpad_symbols target to
 the build and info to upload symbol files to s3 after the build.

---
 indra/newview/CMakeLists.txt               | 36 ++++++++++
 indra/newview/generate_breakpad_symbols.py | 78 ++++++++++++++++++++++
 2 files changed, 114 insertions(+)
 create mode 100644 indra/newview/generate_breakpad_symbols.py

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 4571aa10740..a0340a1e235 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1776,6 +1776,42 @@ if (INSTALL)
   include(${CMAKE_CURRENT_SOURCE_DIR}/ViewerInstall.cmake)
 endif (INSTALL)
 
+if (PACKAGE)
+  if (WINDOWS)
+    set(VIEWER_DIST_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
+    set(VIEWER_SYMBOL_FILE "secondlife-windows.breakpad.bz2")
+    set(VIEWER_EXE_GLOBS "SecondLife*.exe SLPlugin.exe")
+    set(VIEWER_LIB_GLOB "*${CMAKE_SHARED_MODULE_SUFFIX}")
+  endif (WINDOWS)
+  if (DARWIN)
+    set(VIEWER_DIST_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${product}.app")
+    set(VIEWER_SYMBOL_FILE "secondlife-darwin.breakpad.bz2")
+    set(VIEWER_EXE_GLOBS "Second?Life SLPlugin")
+    set(VIEWER_LIB_GLOB "*${CMAKE_SHARED_MODULE_SUFFIX}")
+  endif (DARWIN)
+  if (LINUX)
+    set(VIEWER_DIST_DIR "${CMAKE_CURRENT_BINARY_DIR}/packaged")
+    set(VIEWER_SYMBOL_FILE "secondlife-linux.breakpad.bz2")
+    set(VIEWER_EXE_GLOBS "do-not-directly-run-secondlife-bin SLPlugin")
+    set(VIEWER_LIB_GLOB "*${CMAKE_SHARED_MODULE_SUFFIX}*")
+  endif (LINUX)
+
+  add_custom_command(OUTPUT "${CMAKE_CFG_INTDIR}/${VIEWER_SYMBOL_FILE}"
+    COMMAND "${PYTHON_EXECUTABLE}"
+    ARGS
+      "${CMAKE_CURRENT_SOURCE_DIR}/generate_breakpad_symbols.py"
+      "${VIEWER_DIST_DIR}"
+      "${VIEWER_EXE_GLOBS}"
+      "${VIEWER_LIB_GLOB}"
+      "${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/bin/dump_syms"
+      "${CMAKE_CFG_INTDIR}/${VIEWER_SYMBOL_FILE}"
+    DEPENDS generate_breakpad_symbols.py
+  )
+  add_custom_target(generate_breakpad_symbols ALL DEPENDS "${VIEWER_SYMBOL_FILE}")
+  add_dependencies(generate_breakpad_symbols viewer)
+  add_dependencies(package generate_breakpad_symbols)
+endif (PACKAGE)
+
 if (LL_TESTS)
   # To add a viewer unit test, just add the test .cpp file below
   # This creates a separate test project per file listed.
diff --git a/indra/newview/generate_breakpad_symbols.py b/indra/newview/generate_breakpad_symbols.py
new file mode 100644
index 00000000000..884dd06f84f
--- /dev/null
+++ b/indra/newview/generate_breakpad_symbols.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+# @file generate_breakpad_symbols.py
+# @author Brad Kittenbrink <brad@lindenlab.com>
+# @brief Simple tool for generating google_breakpad symbol information
+#        for the crash reporter.
+#
+# $LicenseInfo:firstyear=2010&license=viewergpl$
+# 
+# Copyright (c) 2010-2010, Linden Research, Inc.
+# 
+# Second Life Viewer Source Code
+# The source code in this file ("Source Code") is provided by Linden Lab
+# to you under the terms of the GNU General Public License, version 2.0
+# ("GPL"), unless you have obtained a separate licensing agreement
+# ("Other License"), formally executed by you and Linden Lab.  Terms of
+# the GPL can be found in doc/GPL-license.txt in this distribution, or
+# online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+# 
+# There are special exceptions to the terms and conditions of the GPL as
+# it is applied to this Source Code. View the full text of the exception
+# in the file doc/FLOSS-exception.txt in this software distribution, or
+# online at
+# http://secondlifegrid.net/programs/open_source/licensing/flossexception
+# 
+# By copying, modifying or distributing this software, you acknowledge
+# that you have read and understood your obligations described above,
+# and agree to abide by those obligations.
+# 
+# ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+# WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+# COMPLETENESS OR PERFORMANCE.
+# $/LicenseInfo$
+
+
+import collections
+import fnmatch
+import itertools
+import os
+import sys
+import subprocess
+import bz2
+
+def usage():
+    print >>sys.stderr, "usage: %s viewer_dir viewer_exes libs_suffix dump_syms_tool viewer_symbol_file" % sys.argv[0]
+
+def main(viewer_dir, viewer_exes, libs_suffix, dump_syms_tool, viewer_symbol_file):
+    print "generate_breakpad_symbols: %s" % str((viewer_dir, viewer_exes, libs_suffix, dump_syms_tool, viewer_symbol_file))
+
+    def matches(f):
+        return f in viewer_exes or fnmatch.fnmatch(f, libs_suffix)
+
+    def list_files():
+        for (dirname, subdirs, filenames) in os.walk(viewer_dir):
+            #print "scanning '%s' for modules..." % dirname
+            for f in itertools.ifilter(matches, filenames):
+                yield os.path.join(dirname, f)
+
+    def dump_module(m):
+        print "dumping module '%s' with '%s'..." % (m, dump_syms_tool)
+        child = subprocess.Popen([dump_syms_tool, m] , stdout=subprocess.PIPE)
+        out, err = child.communicate()
+        return out
+
+    out = bz2.BZ2File(viewer_symbol_file, 'w')
+
+    for symbols in map(dump_module, list_files()):
+        out.writelines(symbols)
+
+    out.close()
+
+    return 0
+
+if __name__ == "__main__":
+    if len(sys.argv) != 6:
+        usage()
+        sys.exit(1)
+    sys.exit(main(*sys.argv[1:]))
+
-- 
GitLab