Skip to content

Commit

Permalink
Update transition_support to better match rules_apple
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Mar 7, 2024
1 parent 005c2b3 commit ecdfc8d
Show file tree
Hide file tree
Showing 19 changed files with 522 additions and 357 deletions.
16 changes: 16 additions & 0 deletions docs/transition_support_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

Starlark transition support for Apple rules.

This module makes the following distinctions around Apple CPU-adjacent values for clarity, based in
part on the language used for XCFramework library identifiers:

- `architecture`s or "arch"s represent the type of binary slice ("arm64", "x86_64").

- `environment`s represent a platform variant ("device", "sim"). These sometimes appear in the "cpu"
keys out of necessity to distinguish new "cpu"s from an existing Apple "cpu" when a new
Crosstool-provided toolchain is established.

- `platform_type`s represent the Apple OS being built for ("ios", "macos", "tvos", "visionos",
"watchos").

- `cpu`s are keys to match a Crosstool-provided toolchain ("ios_sim_arm64", "ios_x86_64").
Essentially it is a raw key that implicitly references the other three values for the purpose of
getting the right Apple toolchain to build outputs with from the Apple Crosstool.

<a id="transition_support.current_apple_platform"></a>

## transition_support.current_apple_platform
Expand Down
1 change: 1 addition & 0 deletions rules/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bzl_library(
visibility = ["//visibility:public"],
deps = [
"@build_bazel_apple_support//configs:platforms",
"@build_bazel_rules_apple//apple",
],
)

Expand Down
2 changes: 1 addition & 1 deletion rules/force_load_direct_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ force_load_direct_deps = rule(
implementation = _impl,
attrs = {
"deps": attr.label_list(
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
mandatory = True,
doc =
"Deps",
Expand Down
16 changes: 8 additions & 8 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ load("@build_bazel_rules_apple//apple/internal:rule_support.bzl", "rule_support"
load("@build_bazel_rules_apple//apple/internal:apple_toolchains.bzl", "AppleMacToolsToolchainInfo", "AppleXPlatToolsToolchainInfo")
load("@build_bazel_rules_apple//apple/internal:swift_support.bzl", "swift_support")
load("@build_bazel_rules_apple//apple/internal/utils:clang_rt_dylibs.bzl", "clang_rt_dylibs")
load("@build_bazel_rules_apple//apple/internal:providers.bzl", "AppleBundleInfo", "IosFrameworkBundleInfo", "new_applebundleinfo", "new_iosframeworkbundleinfo")
load("@build_bazel_rules_apple//apple/internal:providers.bzl", "AppleBundleInfo", "ApplePlatformInfo", "IosFrameworkBundleInfo", "new_applebundleinfo", "new_iosframeworkbundleinfo")
load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "swift_clang_module_aspect", "swift_common")
load(
"@build_bazel_rules_apple//apple/internal/aspects:resource_aspect.bzl",
Expand Down Expand Up @@ -1094,23 +1094,23 @@ apple_framework_packaging = rule(
),
"deps": attr.label_list(
mandatory = True,
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
aspects = [apple_resource_aspect],
doc =
"""Objc or Swift rules to be packed by the framework rule
""",
),
"private_deps": attr.label_list(
mandatory = False,
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
aspects = [apple_resource_aspect],
doc =
"""Objc or Swift private rules to be packed by the framework rule
""",
),
"data": attr.label_list(
mandatory = False,
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
allow_files = True,
doc =
"""Objc or Swift rules to be packed by the framework rule
Expand All @@ -1132,15 +1132,15 @@ The default behavior bakes this into the top level app. When false, it's statica
),
"vfs": attr.label_list(
mandatory = False,
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
doc =
"""Additional VFS for the framework to export
""",
),
"transitive_deps": attr.label_list(
aspects = [swift_clang_module_aspect],
mandatory = True,
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
doc =
"""Deps of the deps
""",
Expand Down Expand Up @@ -1185,7 +1185,7 @@ A list of framework targets (see
[`ios_framework`](https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-ios.md#ios_framework))
that this target depends on.
""",
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
),
"_headermap_builder": attr.label(
executable = True,
Expand All @@ -1204,7 +1204,7 @@ that this target depends on.
""",
),
"_child_configuration_dummy": attr.label(
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
),
"bundle_id": attr.string(
Expand Down
4 changes: 2 additions & 2 deletions rules/internal/framework_middleman.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ framework_middleman = rule(
implementation = _framework_middleman,
attrs = {
"framework_deps": attr.label_list(
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
mandatory = True,
doc =
"""Deps that may contain frameworks
Expand Down Expand Up @@ -260,7 +260,7 @@ dep_middleman = rule(
implementation = _dep_middleman,
attrs = {
"deps": attr.label_list(
cfg = transition_support.split_transition,
cfg = transition_support.apple_platform_split_transition,
mandatory = True,
doc =
"""Deps that may contain frameworks
Expand Down
Loading

0 comments on commit ecdfc8d

Please sign in to comment.