From 3eea556c28f86d1c1334879ff4d7dfc36201485e Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Sat, 2 Sep 2023 11:02:23 -0400
Subject: [PATCH] SL-19243: Post xcarchive.zip instead of separate symbols
 tarball.

On Mac, in the CMake USE_BUGSPLAT logic, we created both xcarchive.zip (which
is what BugSplat wants to see) and secondlife-symbols-darwin -64.tar.bz2 (which
we don't think is used for anything). The tarball was posted to codeticket --
but why? If the point is to manually re-upload to BugSplat in case of failure,
we'll do better saving xcarchive.zip to codeticket.

For SL-19243, posting xcarchive.zip directly supports the goal of breaking out
the upload to BugSplat as a separate step.

Anyway, since xcarchive.zip is a superset of the tarball, the tarball can be
recreated from the zip file, whereas the zip file can't be recreated from the
tarball without opening the .dmg installer and extracting the viewer executable.

If the xcarchive.zip file exists (that is, on Mac), post that to codeticket or
GitHub, as applicable, instead of the tarball. In fact, in the USE_BUGSPLAT
case, don't even bother creating the tarball since we're going to ignore it.

Make the new build.sh logic that insists on BUGSPLAT_USER and BUGSPLAT_PASS
conditional on BUGSPLAT_DB.
---
 build.sh                     | 56 ++++++++++++++++++++----------------
 indra/newview/CMakeLists.txt | 19 ++----------
 2 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/build.sh b/build.sh
index 18b0e8df6fd..4f67fb9603c 100755
--- a/build.sh
+++ b/build.sh
@@ -153,7 +153,7 @@ pre_build()
     RELEASE_CRASH_REPORTING=ON
     HAVOK=ON
     SIGNING=()
-    if [ "$arch" == "Darwin" -a "$variant" == "Release" ]
+    if [[ "$arch" == "Darwin" && "$variant" == "Release" ]]
     then SIGNING=("-DENABLE_SIGNING:BOOL=YES" \
                   "-DSIGNING_IDENTITY:STRING=Developer ID Application: Linden Research, Inc.")
     fi
@@ -177,24 +177,27 @@ pre_build()
         VIEWER_SYMBOL_FILE="$(native_path "$abs_build_dir/newview/$variant/secondlife-symbols-$symplat-${AUTOBUILD_ADDRSIZE}.tar.bz2")"
     fi
 
-    # don't spew credentials into build log
-    set +x
     # expect these variables to be set in the environment from GitHub secrets
-    if [[ -z "$BUGSPLAT_USER" || -z "$BUGSPLAT_PASS" ]]
+    if [[ -n "$BUGSPLAT_DB" ]]
     then
-        # older mechanism involving build-secrets repo -
-        # if build_secrets_checkout isn't set, report its name
-        bugsplat_sh="${build_secrets_checkout:-\$build_secrets_checkout}/bugsplat/bugsplat.sh"
-        if [ -r "$bugsplat_sh" ]
-        then # show that we're doing this, just not the contents
-            echo source "$bugsplat_sh"
-            source "$bugsplat_sh"
-        else
-            fatal "BUGSPLAT_USER or BUGSPLAT_PASS missing, and no $bugsplat_sh"
+        # don't spew credentials into build log
+        set +x
+        if [[ -z "$BUGSPLAT_USER" || -z "$BUGSPLAT_PASS" ]]
+        then
+            # older mechanism involving build-secrets repo -
+            # if build_secrets_checkout isn't set, report its name
+            bugsplat_sh="${build_secrets_checkout:-\$build_secrets_checkout}/bugsplat/bugsplat.sh"
+            if [ -r "$bugsplat_sh" ]
+            then # show that we're doing this, just not the contents
+                echo source "$bugsplat_sh"
+                source "$bugsplat_sh"
+            else
+                fatal "BUGSPLAT_USER or BUGSPLAT_PASS missing, and no $bugsplat_sh"
+            fi
         fi
+        set -x
+        export BUGSPLAT_USER BUGSPLAT_PASS
     fi
-    set -x
-    export BUGSPLAT_USER BUGSPLAT_PASS
 
     # honor autobuild_configure_parameters same as sling-buildscripts
     eval_autobuild_configure_parameters=$(eval $(echo echo $autobuild_configure_parameters))
@@ -578,11 +581,23 @@ then
           # nat 2016-12-22: without RELEASE_CRASH_REPORTING, we have no symbol file.
           if [ "${RELEASE_CRASH_REPORTING:-}" != "OFF" ]
           then
+              # BugSplat wants to see xcarchive.zip
+              # e.g. build-darwin-x86_64/newview/Release/Second Life Test.xcarchive.zip
+              symbol_file="${build_dir}/newview/${variant}/${viewer_channel}.xcarchive.zip"
+              if [[ ! -f "$symbol_file" ]]
+              then
+                  # symbol tarball we prep for (e.g.) Breakpad
+                  symbol_file="$VIEWER_SYMBOL_FILE"
+              else
+                  # SL-19243 HACK: List contents of xcarchive.zip, before running
+                  # upload-mac-symbols.sh which moves it to /tmp
+                  unzip -l "$symbol_file"
+              fi
               # Upload crash reporter file
-              retry_cmd 4 30 python_cmd "$helpers/codeticket.py" addoutput "Symbolfile" "$VIEWER_SYMBOL_FILE" \
+              retry_cmd 4 30 python_cmd "$helpers/codeticket.py" addoutput "Symbolfile" "$symbol_file" \
                   || fatal "Upload of symbolfile failed"
               wait_for_codeticket
-              symbolfile+=("$VIEWER_SYMBOL_FILE")
+              symbolfile+=("$symbol_file")
           fi
 
           # Upload the llphysicsextensions_tpv package, if one was produced
@@ -604,13 +619,6 @@ then
       ## SL-19243 HACK: testing separate GH upload job on Windows
       if [[ "$arch" != "CYGWIN" ]]
       then
-          # SL-19243 HACK: List contents of xcarchive.zip, before running
-          # upload-mac-symbols.sh which moves it to /tmp
-          if [[ "$arch" == "Darwin" ]]
-          then
-              # e.g. build-darwin-x86_64/newview/Release/Second Life Test.xcarchive.zip
-              unzip -l "${build_dir}/newview/${variant}/${viewer_channel}.xcarchive.zip"
-          fi
           if [ -d ${build_dir}/packages/upload-extensions ]; then
               for extension in ${build_dir}/packages/upload-extensions/*.sh; do
                   begin_section "Upload Extension $extension"
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index dbd1f1b4acb..f23e4fa849a 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -2141,20 +2141,6 @@ if (PACKAGE AND (RELEASE_CRASH_REPORTING OR NON_RELEASE_CRASH_REPORTING) AND VIE
         )
       add_custom_target(dsym_generate DEPENDS "${VIEWER_APP_DSYM}")
       add_dependencies(dsym_generate ${VIEWER_BINARY_NAME})
-      add_custom_command(OUTPUT "${VIEWER_SYMBOL_FILE}"
-        # See above comments about "tar ...j"
-        COMMAND "tar"
-        ARGS
-          "cjf"
-          "${VIEWER_SYMBOL_FILE}"
-          "-C"
-          "${VIEWER_APP_DSYM}/.."
-          "${product}.dSYM"
-        DEPENDS "${VIEWER_APP_DSYM}"
-        COMMENT "Packing dSYM into ${VIEWER_SYMBOL_FILE}"
-        )
-      add_custom_target(dsym_tarball DEPENDS "${VIEWER_SYMBOL_FILE}")
-      add_dependencies(dsym_tarball dsym_generate)
       add_custom_command(OUTPUT "${VIEWER_APP_XCARCHIVE}"
         COMMAND "zip"
         ARGS
@@ -2172,16 +2158,15 @@ if (PACKAGE AND (RELEASE_CRASH_REPORTING OR NON_RELEASE_CRASH_REPORTING) AND VIE
       add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dsym.stamp"
         COMMAND rm -rf "${VIEWER_APP_DSYM}"
         COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/dsym.stamp"
-        DEPENDS "${VIEWER_SYMBOL_FILE}" "${VIEWER_APP_XCARCHIVE}"
+        DEPENDS "${VIEWER_APP_XCARCHIVE}"
         COMMENT "Cleaning up dSYM"
         )
       add_custom_target(generate_symbols DEPENDS
         "${VIEWER_APP_DSYM}"
-        "${VIEWER_SYMBOL_FILE}"
         "${VIEWER_APP_XCARCHIVE}"
         "${CMAKE_CURRENT_BINARY_DIR}/dsym.stamp"
         )
-      add_dependencies(generate_symbols dsym_tarball dsym_xcarchive)
+      add_dependencies(generate_symbols dsym_xcarchive)
     endif (DARWIN)
     if (LINUX)
       # TBD
-- 
GitLab