[build, mac] Sign shared libraries and fix incremental build for changes to signing script or entitlement files.

TEST=ci
Change-Id: Ied90ee7b81a23de266d6f7dc5e642a820dac9248
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506341
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2026-05-27 06:34:31 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 3263555dc5
commit b0a82e98d5
4 changed files with 49 additions and 2 deletions
+14
View File
@@ -161,6 +161,20 @@ template("mac_toolchain") {
command = "if $does_reexport_command ; then $link_command && $extract_toc_command > $tocname; else $link_command && $extract_toc_command > $temporary_tocname && $replace_command ; fi; fi" command = "if $does_reexport_command ; then $link_command && $extract_toc_command > $tocname; else $link_command && $extract_toc_command > $temporary_tocname && $replace_command ; fi; fi"
if (codesigning_identity != "") {
# codesign tool performs signing in-place. This does not fit very well
# into the overall build: we would have to produce unsigned binary with
# some suffix (e.g. dart_unsigned), then copy it to the final location
# and sign. To avoid this dance we choose to perform signing here
# at the link step. Unfortunately this also comes with some limitations:
# executable target can't push arbitrary configuration variables down
# to the link step. Which means we can't specify per target
# entitlement files - and instead rely on dart_codesign.py script to
# match binaries to their entitlement files by name.
signing_script = rebase_path("//runtime/tools/dart_codesign.py")
command += " && $signing_script --identity $codesigning_identity --binary $dylib"
}
rspfile_content = "{{inputs_newline}}" rspfile_content = "{{inputs_newline}}"
description = "SOLINK {{output}}" description = "SOLINK {{output}}"
+9
View File
@@ -931,6 +931,15 @@ template("dart_executable") {
"winmm.lib", "winmm.lib",
] ]
} }
# Can't be added by tool("link"), but make sure changes to entitlements
# trigger re-links.
if (is_mac) {
inputs = [
"../tools/dart_codesign.py",
"../tools/entitlements/${target_name}.plist",
]
}
} }
} }
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
+20 -2
View File
@@ -5,6 +5,8 @@
import("../../utils/aot_snapshot.gni") import("../../utils/aot_snapshot.gni")
import("../../utils/application_snapshot.gni") import("../../utils/application_snapshot.gni")
_dart_root = get_path_info("../..", "abspath")
# All samples. # All samples.
group("all") { group("all") {
deps = [ deps = [
@@ -112,6 +114,15 @@ template("sample") {
deps += [ "${dep}${conf.suffix}" ] deps += [ "${dep}${conf.suffix}" ]
} }
deps += extra_deps deps += extra_deps
# Can't be added by tool("link"), but make sure changes to entitlements
# trigger re-links.
if (is_mac) {
inputs = [
"$_dart_root/runtime/tools/dart_codesign.py",
"$_dart_root/runtime/tools/entitlements/${target_name}_aot.plist",
]
}
} }
executable("${target_name}${conf.suffix}_static") { executable("${target_name}${conf.suffix}_static") {
@@ -143,6 +154,15 @@ template("sample") {
deps += [ "${dep}${conf.suffix}_static" ] deps += [ "${dep}${conf.suffix}_static" ]
} }
deps += extra_deps deps += extra_deps
# Can't be added by tool("link"), but make sure changes to entitlements
# trigger re-links.
if (is_mac) {
inputs = [
"$_dart_root/runtime/tools/dart_codesign.py",
"$_dart_root/runtime/tools/entitlements/${target_name}_aot_static.plist",
]
}
} }
} }
} }
@@ -189,8 +209,6 @@ template("snapshots") {
} }
} }
_dart_root = get_path_info("../..", "abspath")
template("shims") { template("shims") {
name = target_name name = target_name
if (defined(invoker.name)) { if (defined(invoker.name)) {