bin/macos-add-entitlements-for-instruments.sh |   33 ++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

New commits:
commit ff95984c8e3475b7ff7832683d621bd09896852e
Author:     Patrick Luby <[email protected]>
AuthorDate: Thu May 18 13:47:40 2023 -0400
Commit:     Patrick Luby <[email protected]>
CommitDate: Thu May 18 21:53:08 2023 +0200

    Script that adds "com.apple.security.get-task-allow" entitlement to soffice
    
    To connect Xcode's Instruments application to profile LibreOffice, the
    "com.apple.security.get-task-allow" entitlement must be added to the
    soffice executable.
    
    This script will set the "com.apple.security.get-task-allow" entitlement
    instdir/LibreOfficeDev.app/Contents/MacOS/soffice executable so that
    profiling can be done using a local build.
    
    Credit for documenting this Xcode requirement goes to the following blog:
      https://cocoaphony.micro.blog/2022/10/29/solving-required-kernel.html
    
    Change-Id: I547edf7c1ad340267e9ed4c396fc723b7ea719be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151981
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <[email protected]>

diff --git a/bin/macos-add-entitlements-for-instruments.sh 
b/bin/macos-add-entitlements-for-instruments.sh
new file mode 100755
index 000000000000..e22b4ae6db50
--- /dev/null
+++ b/bin/macos-add-entitlements-for-instruments.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# Script that adds "com.apple.security.get-task-allow" entitlement to soffice
+#
+# To connect Xcode's Instruments application to profile LibreOffice, the
+# "com.apple.security.get-task-allow" entitlement must be added to the
+# soffice executable.
+#
+# This script will set the "com.apple.security.get-task-allow" entitlement
+# instdir/LibreOfficeDev.app/Contents/MacOS/soffice executable so that
+# profiling can be done using a local build.
+#
+# Credit for documenting this Xcode requirement goes to the following blog:
+#   https://cocoaphony.micro.blog/2022/10/29/solving-required-kernel.html
+
+SOFFICE=`dirname "$0"`/../instdir/LibreOfficeDev.app/Contents/MacOS/soffice
+if [ ! -f "$SOFFICE" -o ! -x "$SOFFICE" ] ; then
+    echo "Error: '$SOFFICE' is not an executable file" >&2
+    exit 1
+fi
+
+codesign -s - -v -f --entitlements /dev/stdin "$SOFFICE" << !
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"https://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
+<plist version="1.0">
+    <dict>
+        <key>com.apple.security.get-task-allow</key>
+        <true/>
+    </dict>
+</plist>
+!
+
+exit 0

Reply via email to