From a381f438da96718cb8538acbeebc436ef14a9493 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 4 Aug 2021 16:24:27 -0400
Subject: [PATCH] Start to introduce windows Sentry

---
 autobuild.xml                      | 32 ++++++++++++++++++++++++++++--
 indra/cmake/Copy3rdPartyLibs.cmake | 18 +++++------------
 indra/cmake/Sentry.cmake           |  1 +
 indra/llcommon/llapp.cpp           |  2 +-
 indra/newview/CMakeLists.txt       | 11 +++++-----
 indra/newview/llappviewerwin32.h   |  1 +
 indra/newview/viewer_manifest.py   | 11 +++-------
 7 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/autobuild.xml b/autobuild.xml
index 5712e6a524a..9465c5373a7 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -2406,15 +2406,43 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
             <key>archive</key>
             <map>
               <key>hash</key>
-              <string>0efba1738965eae8ec392d010e884b3f37d5c1cc803d367c5090909665e087569a39dcc06839dd92d45c7b47ac8afd61</string>
+              <string>049580d94fa2c339dfaf265a578752e60c34983b9afc60c590043e7842287ee28e62ccdf1164e75a0071b89bb34ce1af</string>
               <key>hash_algorithm</key>
               <string>sha3_384</string>
               <key>url</key>
-              <string>https://git.alchemyviewer.org/api/v4/projects/164/packages/generic/sentry/1.0.0.1060/sentry-1.0.0-darwin64-1060.tar.xz</string>
+              <string>https://git.alchemyviewer.org/api/v4/projects/164/packages/generic/sentry/1.0.0.1063/sentry-1.0.0-darwin64-1063.tar.xz</string>
             </map>
             <key>name</key>
             <string>darwin64</string>
           </map>
+          <key>windows</key>
+          <map>
+            <key>archive</key>
+            <map>
+              <key>hash</key>
+              <string>d9b6c40dc8a1ce39d7cbced6e06b66cba181c42c610329e75b1c86ccc7d2072eae882e8c7c8e2331f4487cc6c47823da</string>
+              <key>hash_algorithm</key>
+              <string>sha3_384</string>
+              <key>url</key>
+              <string>https://git.alchemyviewer.org/api/v4/projects/164/packages/generic/sentry/1.0.0.1063/sentry-1.0.0-windows-1063.tar.xz</string>
+            </map>
+            <key>name</key>
+            <string>windows</string>
+          </map>
+          <key>windows64</key>
+          <map>
+            <key>archive</key>
+            <map>
+              <key>hash</key>
+              <string>954d9a589400a6fec4ded233b592c9c52f54765800af7070a83a3dbb18b60b09103efe15ddaf72916939ff34735bdcaa</string>
+              <key>hash_algorithm</key>
+              <string>sha3_384</string>
+              <key>url</key>
+              <string>https://git.alchemyviewer.org/api/v4/projects/164/packages/generic/sentry/1.0.0.1063/sentry-1.0.0-windows64-1063.tar.xz</string>
+            </map>
+            <key>name</key>
+            <string>windows64</string>
+          </map>
         </map>
         <key>version</key>
         <string>1.0.0</string>
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 34221fbdbf1..674a69cccc5 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -109,17 +109,9 @@ if(WINDOWS)
 
     # Filenames are different for 32/64 bit BugSplat file and we don't
     # have any control over them so need to branch.
-    if (USE_BUGSPLAT)
-      if(ADDRESS_SIZE EQUAL 32)
-        set(release_files ${release_files} BugSplat.dll)
-        set(release_files ${release_files} BugSplatRc.dll)
-        set(release_files ${release_files} BsSndRpt.exe)
-      else(ADDRESS_SIZE EQUAL 32)
-        set(release_files ${release_files} BugSplat64.dll)
-        set(release_files ${release_files} BugSplatRc64.dll)
-        set(release_files ${release_files} BsSndRpt64.exe)
-      endif(ADDRESS_SIZE EQUAL 32)
-    endif (USE_BUGSPLAT)
+    if (USE_SENTRY)
+      set(release_files ${release_files} sentry.dll)
+    endif ()
 
     if (USE_FMODSTUDIO)
       list(APPEND debug_files fmodL.dll)
@@ -127,8 +119,8 @@ if(WINDOWS)
     endif (USE_FMODSTUDIO)
 
     if (USE_OPENAL)
-        list(APPEND debug_files OpenAL32.dll alut.dll)
-        list(APPEND release_files OpenAL32.dll alut.dll)
+      list(APPEND debug_files OpenAL32.dll alut.dll)
+      list(APPEND release_files OpenAL32.dll alut.dll)
     endif ()
 
     if (USE_KDU)
diff --git a/indra/cmake/Sentry.cmake b/indra/cmake/Sentry.cmake
index 53f947b41e8..76be83c2e51 100644
--- a/indra/cmake/Sentry.cmake
+++ b/indra/cmake/Sentry.cmake
@@ -8,6 +8,7 @@ if (USE_SENTRY)
         include(Prebuilt)
         use_prebuilt_binary(sentry)
         if (WINDOWS)
+            set(SENTRY_LIBRARIES ${ARCH_PREBUILT_DIRS_RELEASE}/sentry.lib)
         elseif (DARWIN)
             find_library(SENTRY_LIBRARIES Sentry REQUIRED
                 NO_DEFAULT_PATH PATHS "${ARCH_PREBUILT_DIRS_RELEASE}")
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index adcbb2a3a0e..e987e9a1fd1 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -379,7 +379,7 @@ void LLApp::setupErrorHandling(bool second_instance)
 	// This sets a callback to handle w32 signals to the console window.
 	// The viewer shouldn't be affected, sicne its a windowed app.
 	SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ConsoleCtrlHandler, TRUE);
-#endif // LL_SEND_CRASH_REPORTS && ! defined(LL_BUGSPLAT)
+#endif // LL_SEND_CRASH_REPORTS && ! defined(USE_SENTRY)
 #else  // ! LL_WINDOWS
 	//
 	// Start up signal handling.
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index c1c38f29e90..b17dbd26f1d 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1800,12 +1800,11 @@ endif (SDL_FOUND)
 if (USE_SENTRY)
   set_property(TARGET ${VIEWER_BINARY_NAME}
     PROPERTY COMPILE_DEFINITIONS "${SENTRY_DEFINE}")
-  if (USE_SENTRY)
-    list(APPEND viewer_LIBRARIES
-      ${SENTRY_LIBRARIES}
-      )
-  endif ()
-endif (USE_SENTRY)
+
+  list(APPEND viewer_LIBRARIES
+       ${SENTRY_LIBRARIES}
+       )
+endif ()
 
 # add package files
 file(GLOB EVENT_HOST_SCRIPT_GLOB_LIST
diff --git a/indra/newview/llappviewerwin32.h b/indra/newview/llappviewerwin32.h
index 83ae875a151..278e00f95fc 100644
--- a/indra/newview/llappviewerwin32.h
+++ b/indra/newview/llappviewerwin32.h
@@ -66,6 +66,7 @@ class LLAppViewerWin32 : public LLAppViewer
 
 	std::string mCmdLine;
 	bool mIsConsoleAllocated;
+	bool mSentryInitialized = false;
 };
 
 #endif // LL_LLAPPVIEWERWIN32_H
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 7aa7e1a241b..fe18634fe37 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -526,14 +526,9 @@ def construct(self):
 
             # Sentry
             if self.args.get('sentry'):
-                if(self.address_size == 64):
-                    self.path("BsSndRpt64.exe")
-                    self.path("BugSplat64.dll")
-                    self.path("BugSplatRc64.dll")
-                else:
-                    self.path("BsSndRpt.exe")
-                    self.path("BugSplat.dll")
-                    self.path("BugSplatRc.dll")
+                self.path("sentry.dll")
+                with self.prefix(src=os.path.join(pkgdir, 'bin', 'release')):
+                    self.path("crashpad_handler.exe")
 
         self.path(src="licenses-win32.txt", dst="licenses.txt")
         self.path("featuretable.txt")
-- 
GitLab