Browse Source

CMake: Add a command for codesigning with the get-task-allow entitlement

This allows developers on macOS to open Ladybird.app in Instruments.

Add some documentation for how to use the command as well. It is enabled
automatically when CMAKE_BUILD_TYPE is not Release or RelWithDebInfo.
Andrew Kaster 9 months ago
parent
commit
d220cf3abd
3 changed files with 34 additions and 1 deletions
  1. 15 1
      Documentation/BuildInstructionsLadybird.md
  2. 11 0
      Ladybird/CMakeLists.txt
  3. 8 0
      Meta/debug.plist

+ 15 - 1
Documentation/BuildInstructionsLadybird.md

@@ -204,8 +204,22 @@ After running Ladybird as suggested above with `./Meta/ladybird.sh run ladybird`
 
 Now breakpoints, stepping and variable inspection will work.
 
-### Debugging with Xcode on macOS
+### Debugging with Xcode or Instruments on macOS
 
+If all you want to do is use Instruments, then an Xcode project is not required.
+
+Simply run the `ladybird.sh` script as normal, and then make sure to codesign the Ladybird binary with the proper entitlements to allow Instruments to attach to it.
+
+```
+./Meta/ladybird.sh build
+ ninja -C build/ladybird apply-debug-entitlements
+ # or
+ codesign -s - -v -f --entitlements Meta/debug.plist Build/ladybird/bin/Ladybird.app
+```
+
+Now you can open the Instruments app and point it to the Ladybird app bundle.
+
+If you want to use Xcode itself for debugging, you will need to generate an Xcode project.
 The `ladybird.sh` build script does not know how to generate Xcode projects, so creating the project must be done manually.
 
 ```

+ 11 - 0
Ladybird/CMakeLists.txt

@@ -34,6 +34,17 @@ function(create_ladybird_bundle target_name)
         add_custom_command(TARGET ${target_name} POST_BUILD
             COMMAND "${CMAKE_COMMAND}" -E create_symlink "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" "${bundle_dir}/Contents/lib"
         )
+
+        if (NOT CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo")
+            add_custom_command(TARGET ${target_name} POST_BUILD
+                COMMAND codesign -s - -v -f --entitlements "${LADYBIRD_SOURCE_DIR}/Meta/debug.plist" "${bundle_dir}"
+            )
+        else()
+            add_custom_target(apply-debug-entitlements
+                COMMAND codesign -s - -v -f --entitlements "${LADYBIRD_SOURCE_DIR}/Meta/debug.plist" "${bundle_dir}"
+                USES_TERMINAL
+            )
+        endif()
     endif()
 
     if (APPLE)

+ 8 - 0
Meta/debug.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>com.apple.security.get-task-allow</key>
+	<true/>
+</dict>
+</plist>