Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bazelbuild:master' into master
Browse files Browse the repository at this point in the history
sewerynplazuk authored Jul 1, 2024
2 parents 445fa43 + 42fb193 commit 1c4885f
Showing 67 changed files with 972 additions and 462 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -21,6 +21,12 @@ build --nocheck_visibility
# dependencies cause us to use a newer version
build --check_direct_dependencies=off

# This is needed for Bazel 6 compatibility.
# It's enabled (and can't be disabled) in Bazel 7.
# TODO: Remove this once we drop Bazel 6 support.
# See also: https://github.com/bazelbuild/bazel/issues/14327
build --experimental_enable_aspect_hints

# Disable the worker, which has sandboxing disabled by default, which can hide
# issues with non-hermetic bugs.
build --spawn_strategy=sandboxed,local
4 changes: 2 additions & 2 deletions .github/generate-notes.sh
Original file line number Diff line number Diff line change
@@ -14,13 +14,13 @@ TODO
This release is compatible with: TODO
### MODULE.bazel Snippet
## MODULE.bazel Snippet
\`\`\`bzl
bazel_dep(name = "rules_apple", version = "$new_version", repo_name = "build_bazel_rules_apple")
\`\`\`
### Workspace Snippet
## Workspace Snippet
\`\`\`bzl
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
11 changes: 8 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -6,10 +6,15 @@ 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.17.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(
name = "rules_swift",
version = "1.18.0",
max_compatibility_level = 2,
repo_name = "build_bazel_rules_swift",
)

bazel_dep(
name = "stardoc",
1 change: 1 addition & 0 deletions apple/internal/BUILD
Original file line number Diff line number Diff line change
@@ -424,6 +424,7 @@ bzl_library(
"//apple/internal/partials:apple_bundle_info",
"//apple/internal/partials:apple_symbols_file",
"//apple/internal/partials:binary",
"//apple/internal/partials:cc_info_dylibs",
"//apple/internal/partials:clang_rt_dylibs",
"//apple/internal/partials:codesigning_dossier",
"//apple/internal/partials:debug_symbols",
151 changes: 45 additions & 106 deletions apple/internal/apple_toolchains.bzl
Original file line number Diff line number Diff line change
@@ -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.
""",
},
)
@@ -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.
""",
},
)
@@ -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(),
]
@@ -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(),
]
10 changes: 3 additions & 7 deletions apple/internal/apple_xcframework_import.bzl
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion apple/internal/aspects/docc_archive_aspect.bzl
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ def _docc_bundle_info_aspect_impl(target, ctx):
first_docc_bundle = _first_docc_bundle(target, ctx)
if first_docc_bundle:
return [DocCBundleInfo(bundle = first_docc_bundle)]
elif hasattr(ctx.rule.attr, "deps"):
if hasattr(ctx.rule.attr, "deps"):
# If this target has "deps", try to find a DocCBundleInfo provider in its deps.
for dep in ctx.rule.attr.deps:
if DocCBundleInfo in dep:
Loading

0 comments on commit 1c4885f

Please sign in to comment.