Skip to content

Commit

Permalink
Merge branch 'bazelbuild:master' into add-the-apple.no_legacy_swiftin…
Browse files Browse the repository at this point in the history
…terface-feature-to-disable-the-automatic-library-evolution-transition-on-framework-rules
  • Loading branch information
sewerynplazuk authored Apr 11, 2024
2 parents c42ce87 + d4b6341 commit fe9618e
Show file tree
Hide file tree
Showing 45 changed files with 480 additions and 450 deletions.
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module(
repo_name = "build_bazel_rules_apple",
)

bazel_dep(name = "apple_support", version = "1.14.0", repo_name = "build_bazel_apple_support")
bazel_dep(name = "apple_support", version = "1.15.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "rules_swift", version = "1.16.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "rules_swift", version = "1.18.0", repo_name = "build_bazel_rules_swift")

bazel_dep(
name = "stardoc",
Expand Down
151 changes: 45 additions & 106 deletions apple/internal/apple_toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,57 @@ A `File` referencing a plist template for dSYM bundles.
"process_and_sign_template": """\
A `File` referencing a template for a shell script to process and sign.
""",
"resolved_alticonstool": """\
A `struct` from `ctx.resolve_tools` referencing a tool to insert alternate icons entries in the app
"alticonstool": """\
The files_to_run for a tool to insert alternate icons entries in the app
bundle's `Info.plist`.
""",
"resolved_bundletool_experimental": """\
A `struct` from `ctx.resolve_tools` referencing an experimental tool to create an Apple bundle by
"bundletool_experimental": """\
The files_to_run for an experimental tool to create an Apple bundle by
combining the bundling, post-processing, and signing steps into a single action that eliminates the
archiving step.
""",
"resolved_clangrttool": """\
A `struct` from `ctx.resolve_tools` referencing a tool to find all Clang runtime libs linked to a
"clangrttool": """\
The files_to_run for a tool to find all Clang runtime libs linked to a
binary.
""",
"resolved_codesigningtool": """\
A `struct` from `ctx.resolve_tools` referencing a tool to select the appropriate signing identity
"codesigningtool": """\
The files_to_run for a tool to select the appropriate signing identity
for Apple apps and Apple executable bundles.
""",
"resolved_dossier_codesigningtool": """\
A `struct` from `ctx.resolve_tools` referencing a tool to generate codesigning dossiers.
"dossier_codesigningtool": """\
The files_to_run for a tool to generate codesigning dossiers.
""",
"resolved_environment_plist_tool": """\
A `struct` from `ctx.resolve_tools` referencing a tool for collecting dev environment values.
"environment_plist_tool": """\
The files_to_run for a tool for collecting dev environment values.
""",
"resolved_imported_dynamic_framework_processor": """\
A `struct` from `ctx.resolve_tools` referencing a tool to process an imported dynamic framework
"imported_dynamic_framework_processor": """\
The files_to_run for a tool to process an imported dynamic framework
such that the given framework only contains the same slices as the app binary, every file belonging
to the dynamic framework is copied to a temporary location, and the dynamic framework is codesigned
and zipped as a cacheable artifact.
""",
"resolved_main_thread_checker_tool": """\
A `struct` from `ctx.resolve_tools` referencing a tool to find libMainThreadChecker.dylib linked to a
"main_thread_checker_tool": """\
The files_to_run for a tool to find libMainThreadChecker.dylib linked to a
binary.
""",
"resolved_plisttool": """\
A `struct` from `ctx.resolve_tools` referencing a tool to perform plist operations such as variable
"plisttool": """\
The files_to_run for a tool to perform plist operations such as variable
substitution, merging, and conversion of plist files to binary format.
""",
"resolved_provisioning_profile_tool": """\
A `struct` from `ctx.resolve_tools` referencing a tool that extracts entitlements from a
"provisioning_profile_tool": """\
The files_to_run for a tool that extracts entitlements from a
provisioning profile.
""",
"resolved_swift_stdlib_tool": """\
A `struct` from `ctx.resolve_tools` referencing a tool that copies and lipos Swift stdlibs required
"swift_stdlib_tool": """\
The files_to_run for a tool that copies and lipos Swift stdlibs required
for the target to run.
""",
"resolved_xcframework_processor_tool": """\
A `struct` from `ctx.resolve_tools` referencing a tool that extracts and copies an XCFramework
"xcframework_processor_tool": """\
The files_to_run for a tool that extracts and copies an XCFramework
library for a target triplet.
""",
"resolved_xctoolrunner": """\
A `struct` from `ctx.resolve_tools` referencing a tool that acts as a wrapper for xcrun actions.
"xctoolrunner": """\
The files_to_run for a tool that acts as a wrapper for xcrun actions.
""",
},
)
Expand All @@ -106,12 +106,12 @@ target name and values are retrieved from the BuildSettingInfo provider for each
e.g. apple_xplat_tools_toolchaininfo.build_settings.signing_certificate_name
""",
"resolved_bundletool": """\
A `struct` from `ctx.resolve_tools` referencing a tool to create an Apple bundle by taking a list of
"bundletool": """\
A files_to_run for a tool to create an Apple bundle by taking a list of
files/ZIPs and destinations paths to build the directory structure for those files.
""",
"resolved_versiontool": """\
A `struct` from `ctx.resolve_tools` referencing a tool that acts as a wrapper for xcrun actions.
"versiontool": """\
A files_to_run for a tool that acts as a wrapper for xcrun actions.
""",
},
)
Expand All @@ -131,79 +131,24 @@ def _shared_attrs():
),
}

def _resolve_tools_for_executable(*, rule_ctx, attr_name):
"""Helper macro to resolve executable runfile dependencies across the rule boundary."""

# TODO(b/111036105) Migrate away from this helper and its outputs once ctx.executable works
# across rule boundaries.
executable = getattr(rule_ctx.executable, attr_name)
target = getattr(rule_ctx.attr, attr_name)
files_to_run = target[DefaultInfo].files_to_run
inputs, input_manifests = rule_ctx.resolve_tools(tools = [target])
return struct(
executable = executable,
files_to_run = files_to_run,
inputs = inputs,
input_manifests = input_manifests,
)

def _apple_mac_tools_toolchain_impl(ctx):
return [
AppleMacToolsToolchainInfo(
dsym_info_plist_template = ctx.file.dsym_info_plist_template,
process_and_sign_template = ctx.file.process_and_sign_template,
resolved_alticonstool = _resolve_tools_for_executable(
attr_name = "alticonstool",
rule_ctx = ctx,
),
resolved_bundletool_experimental = _resolve_tools_for_executable(
attr_name = "bundletool_experimental",
rule_ctx = ctx,
),
resolved_codesigningtool = _resolve_tools_for_executable(
attr_name = "codesigningtool",
rule_ctx = ctx,
),
resolved_dossier_codesigningtool = _resolve_tools_for_executable(
attr_name = "dossier_codesigningtool",
rule_ctx = ctx,
),
resolved_clangrttool = _resolve_tools_for_executable(
attr_name = "clangrttool",
rule_ctx = ctx,
),
resolved_main_thread_checker_tool = _resolve_tools_for_executable(
attr_name = "main_thread_checker_tool",
rule_ctx = ctx,
),
resolved_environment_plist_tool = _resolve_tools_for_executable(
attr_name = "environment_plist_tool",
rule_ctx = ctx,
),
resolved_imported_dynamic_framework_processor = _resolve_tools_for_executable(
attr_name = "imported_dynamic_framework_processor",
rule_ctx = ctx,
),
resolved_plisttool = _resolve_tools_for_executable(
attr_name = "plisttool",
rule_ctx = ctx,
),
resolved_provisioning_profile_tool = _resolve_tools_for_executable(
attr_name = "provisioning_profile_tool",
rule_ctx = ctx,
),
resolved_swift_stdlib_tool = _resolve_tools_for_executable(
attr_name = "swift_stdlib_tool",
rule_ctx = ctx,
),
resolved_xcframework_processor_tool = _resolve_tools_for_executable(
attr_name = "xcframework_processor_tool",
rule_ctx = ctx,
),
resolved_xctoolrunner = _resolve_tools_for_executable(
attr_name = "xctoolrunner",
rule_ctx = ctx,
),
alticonstool = ctx.attr.alticonstool.files_to_run,
bundletool_experimental = ctx.attr.bundletool_experimental.files_to_run,
codesigningtool = ctx.attr.codesigningtool.files_to_run,
dossier_codesigningtool = ctx.attr.dossier_codesigningtool.files_to_run,
clangrttool = ctx.attr.clangrttool.files_to_run,
main_thread_checker_tool = ctx.attr.main_thread_checker_tool.files_to_run,
environment_plist_tool = ctx.attr.environment_plist_tool.files_to_run,
imported_dynamic_framework_processor = ctx.attr.imported_dynamic_framework_processor.files_to_run,
plisttool = ctx.attr.plisttool.files_to_run,
provisioning_profile_tool = ctx.attr.provisioning_profile_tool.files_to_run,
swift_stdlib_tool = ctx.attr.swift_stdlib_tool.files_to_run,
xcframework_processor_tool = ctx.attr.xcframework_processor_tool.files_to_run,
xctoolrunner = ctx.attr.xctoolrunner.files_to_run,
),
DefaultInfo(),
]
Expand Down Expand Up @@ -321,14 +266,8 @@ def _apple_xplat_tools_toolchain_impl(ctx):
for build_setting in ctx.attr.build_settings
}
),
resolved_bundletool = _resolve_tools_for_executable(
attr_name = "bundletool",
rule_ctx = ctx,
),
resolved_versiontool = _resolve_tools_for_executable(
attr_name = "versiontool",
rule_ctx = ctx,
),
bundletool = ctx.attr.bundletool.files_to_run,
versiontool = ctx.attr.versiontool.files_to_run,
),
DefaultInfo(),
]
Expand Down
10 changes: 3 additions & 7 deletions apple/internal/apple_xcframework_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,14 @@ def _get_xcframework_library_with_xcframework_processor(
)
outputs.append(swiftinterface_file)

xcframework_processor_tool = apple_mac_toolchain_info.resolved_xcframework_processor_tool
xcframework_processor_tool = apple_mac_toolchain_info.xcframework_processor_tool

apple_support.run(
actions = actions,
apple_fragment = apple_fragment,
arguments = [args],
executable = xcframework_processor_tool.files_to_run,
inputs = depset(
inputs,
transitive = [xcframework_processor_tool.inputs],
),
input_manifests = xcframework_processor_tool.input_manifests,
executable = xcframework_processor_tool,
inputs = inputs,
mnemonic = "ProcessXCFrameworkFiles",
outputs = outputs,
xcode_config = xcode_config,
Expand Down
Loading

0 comments on commit fe9618e

Please sign in to comment.