[ObjC] use xcpretty if installed to reduce output

Include option to skip it if it was installed.

https://github.com/tuist/xcbeautify would also be an option (it supports bazel to),
but we'd have to install it.

PiperOrigin-RevId: 507852912
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index 89c80f7..d091a95 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -49,6 +49,9 @@
          Skip the invoke of Xcode to test the runtime on tvOS.
    --skip-objc-conformance
          Skip the Objective C conformance tests (run on OS X).
+   --skip-xcpretty
+         By default, if xcpretty is installed, it will be used, this option will
+         skip it even it it is installed.
    --xcode-quiet
          Pass -quiet to xcodebuild.
 
@@ -62,6 +65,16 @@
   echo "========================================================================"
 }
 
+xcodebuild_xcpretty() {
+  set -o pipefail && xcodebuild "${@}" | xcpretty
+}
+
+if hash xcpretty >/dev/null 2>&1 ; then
+  XCODEBUILD=xcodebuild_xcpretty
+else
+  XCODEBUILD=xcodebuild
+fi
+
 DO_CLEAN=no
 REGEN_DESCRIPTORS=no
 FULL_BUILD=no
@@ -110,6 +123,9 @@
     --skip-objc-conformance )
       DO_OBJC_CONFORMANCE_TESTS=no
       ;;
+    --skip-xcpretty )
+      XCODEBUILD=xcodebuild
+      ;;
     --xcode-quiet )
       XCODE_QUIET=yes
       ;;
@@ -210,7 +226,7 @@
 
 if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
   XCODEBUILD_TEST_BASE_IOS=(
-    xcodebuild
+    "${XCODEBUILD}"
       -project objectivec/ProtocolBuffers_iOS.xcodeproj
       -scheme ProtocolBuffers
   )
@@ -241,18 +257,18 @@
   esac
   if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
     header "Doing Xcode iOS build/tests - Debug"
-    time "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test
+    "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test
   fi
   if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
     header "Doing Xcode iOS build/tests - Release"
-    time "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test
+    "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test
   fi
   # Don't leave the simulator in the developer's face.
   killall Simulator 2> /dev/null || true
 fi
 if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
   XCODEBUILD_TEST_BASE_OSX=(
-    xcodebuild
+    "${XCODEBUILD}"
       -project objectivec/ProtocolBuffers_OSX.xcodeproj
       -scheme ProtocolBuffers
       # Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported.
@@ -269,16 +285,16 @@
   esac
   if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
     header "Doing Xcode OS X build/tests - Debug"
-    time "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test
+    "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test
   fi
   if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
     header "Doing Xcode OS X build/tests - Release"
-    time "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test
+    "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test
   fi
 fi
 if [[ "${DO_XCODE_TVOS_TESTS}" == "yes" ]] ; then
   XCODEBUILD_TEST_BASE_TVOS=(
-    xcodebuild
+    "${XCODEBUILD}"
       -project objectivec/ProtocolBuffers_tvOS.xcodeproj
       -scheme ProtocolBuffers
   )
@@ -305,11 +321,11 @@
   fi
   if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
     header "Doing Xcode tvOS build/tests - Debug"
-    time "${XCODEBUILD_TEST_BASE_TVOS[@]}" -configuration Debug test
+    "${XCODEBUILD_TEST_BASE_TVOS[@]}" -configuration Debug test
   fi
   if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then
     header "Doing Xcode tvOS build/tests - Release"
-    time "${XCODEBUILD_TEST_BASE_TVOS[@]}" -configuration Release test
+    "${XCODEBUILD_TEST_BASE_TVOS[@]}" -configuration Release test
   fi
 fi