Skip to content

Commit

Permalink
Add apple.codesign_frameworks_without_provisioning_profile feature
Browse files Browse the repository at this point in the history
This feature causes `*_{dynamic_,}framework` targets to codesign themselves even when they don’t have a provisioning profile set. This allows moving and caching some of the codesigning time into the framework targets, which can be a big win if your incremental builds don’t touch a lot of the frameworks.

Signed-off-by: Brentley Jones <[email protected]>
  • Loading branch information
brentleyjones committed Jan 8, 2025
1 parent 710570f commit ca6fbbe
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 41 deletions.
4 changes: 3 additions & 1 deletion apple/internal/codesigning_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ def _should_sign_bundles(*, provisioning_profile, rule_descriptor, features):
rule_support.codesigning_exceptions.sign_with_provisioning_profile):
# If the rule doesn't have a provisioning profile, do not sign the binary or its
# frameworks.
if not provisioning_profile:
if (not provisioning_profile and
"apple.codesign_frameworks_without_provisioning_profile" not in features):
should_sign_bundles = False
elif codesigning_exceptions == rule_support.codesigning_exceptions.skip_signing:
should_sign_bundles = False
Expand Down Expand Up @@ -825,5 +826,6 @@ codesigning_support = struct(
embedded_codesigning_dossier = _embedded_codesigning_dossier,
generate_codesigning_dossier_action = _generate_codesigning_dossier_action,
post_process_and_sign_archive_action = _post_process_and_sign_archive_action,
should_sign_bundles = _should_sign_bundles,
sign_binary_action = _sign_binary_action,
)
20 changes: 12 additions & 8 deletions apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,12 @@ def _ios_framework_impl(ctx):
provisioning_profile = ctx.file.provisioning_profile
resource_deps = ctx.attr.deps + ctx.attr.resources
signed_frameworks = []
if provisioning_profile:
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]
top_level_infoplists = resources.collect(
attr = ctx.attr,
res_attrs = ["infoplists"],
Expand Down Expand Up @@ -1489,10 +1491,12 @@ def _ios_dynamic_framework_impl(ctx):
)

signed_frameworks = []
if getattr(ctx.file, "provisioning_profile", None):
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = ctx.file.provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]

extra_linkopts = [
"-dynamiclib",
Expand Down
20 changes: 12 additions & 8 deletions apple/internal/macos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2796,10 +2796,12 @@ def _macos_framework_impl(ctx):
provisioning_profile = ctx.file.provisioning_profile
resource_deps = ctx.attr.deps + ctx.attr.resources
signed_frameworks = []
if provisioning_profile:
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]
top_level_infoplists = resources.collect(
attr = ctx.attr,
res_attrs = ["infoplists"],
Expand Down Expand Up @@ -3083,10 +3085,12 @@ def _macos_dynamic_framework_impl(ctx):
)

signed_frameworks = []
if getattr(ctx.file, "provisioning_profile", None):
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = ctx.file.provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]

extra_linkopts = [
"-dynamiclib",
Expand Down
20 changes: 12 additions & 8 deletions apple/internal/tvos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,12 @@ def _tvos_dynamic_framework_impl(ctx):
)

signed_frameworks = []
if getattr(ctx.file, "provisioning_profile", None):
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = ctx.file.provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]

link_result = linking_support.register_binary_linking_action(
ctx,
Expand Down Expand Up @@ -816,10 +818,12 @@ def _tvos_framework_impl(ctx):
provisioning_profile = ctx.file.provisioning_profile
resource_deps = ctx.attr.deps + ctx.attr.resources
signed_frameworks = []
if provisioning_profile:
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]
top_level_infoplists = resources.collect(
attr = ctx.attr,
res_attrs = ["infoplists"],
Expand Down
20 changes: 12 additions & 8 deletions apple/internal/visionos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,12 @@ def _visionos_dynamic_framework_impl(ctx):
)

signed_frameworks = []
if getattr(ctx.file, "provisioning_profile", None):
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = ctx.file.provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]

link_result = linking_support.register_binary_linking_action(
ctx,
Expand Down Expand Up @@ -821,10 +823,12 @@ def _visionos_framework_impl(ctx):
provisioning_profile = ctx.file.provisioning_profile
resource_deps = ctx.attr.deps + ctx.attr.resources
signed_frameworks = []
if provisioning_profile:
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]
top_level_infoplists = resources.collect(
attr = ctx.attr,
res_attrs = ["infoplists"],
Expand Down
20 changes: 12 additions & 8 deletions apple/internal/watchos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ def _watchos_framework_impl(ctx):
provisioning_profile = ctx.file.provisioning_profile
resource_deps = ctx.attr.deps + ctx.attr.resources
signed_frameworks = []
if provisioning_profile:
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]
top_level_infoplists = resources.collect(
attr = ctx.attr,
res_attrs = ["infoplists"],
Expand Down Expand Up @@ -474,10 +476,12 @@ def _watchos_dynamic_framework_impl(ctx):
)

signed_frameworks = []
if getattr(ctx.file, "provisioning_profile", None):
signed_frameworks = [
bundle_name + rule_descriptor.bundle_extension,
]
if codesigning_support.should_sign_bundles(
provisioning_profile = ctx.file.provisioning_profile,
rule_descriptor = rule_descriptor,
features = features,
):
signed_frameworks = [bundle_name + bundle_extension]

extra_linkopts = [
"-dynamiclib",
Expand Down

0 comments on commit ca6fbbe

Please sign in to comment.