Skip to content

Commit

Permalink
Migrate uses of ctx.fragments.apple.multi_arch_platform(...) to platf…
Browse files Browse the repository at this point in the history
…orm constraints. (#268)

PiperOrigin-RevId: 568558393
(cherry picked from commit 42d2c7c)

---------

Co-authored-by: Nicholas Levin <nglevin@google.com>
Co-authored-by: Brentley Jones <github@brentleyjones.com>
  • Loading branch information
3 people authored Oct 17, 2023
1 parent d4fbadc commit 21bd81c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/apple_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,53 @@ def _action_required_attrs():
),
}

def _platform_constraint_attrs():
"""Returns a dictionary of all known Apple platform constraints that can be resolved.
The returned `dict` can be added to the rule's attributes using Skylib's `dicts.add()` method.
Returns:
A `dict` object containing attributes to be added to rule implementations.
"""
return {
"_ios_constraint": attr.label(
default = Label("@platforms//os:ios"),
),
"_macos_constraint": attr.label(
default = Label("@platforms//os:macos"),
),
"_tvos_constraint": attr.label(
default = Label("@platforms//os:tvos"),
),
"_visionos_constraint": attr.label(
default = Label("@platforms//os:visionos"),
),
"_watchos_constraint": attr.label(
default = Label("@platforms//os:watchos"),
),
"_arm64_constraint": attr.label(
default = Label("@platforms//cpu:arm64"),
),
"_arm64e_constraint": attr.label(
default = Label("@platforms//cpu:arm64e"),
),
"_arm64_32_constraint": attr.label(
default = Label("@platforms//cpu:arm64_32"),
),
"_armv7k_constraint": attr.label(
default = Label("@platforms//cpu:armv7k"),
),
"_x86_64_constraint": attr.label(
default = Label("@platforms//cpu:x86_64"),
),
"_apple_device_constraint": attr.label(
default = Label("//constraints:device"),
),
"_apple_simulator_constraint": attr.label(
default = Label("//constraints:simulator"),
),
}

def _run(
ctx = None,
xcode_path_resolve_level = _XCODE_PATH_RESOLVE_LEVEL.none,
Expand Down Expand Up @@ -568,6 +615,7 @@ apple_support = struct(
sdkroot = _sdkroot_path_placeholder,
xcode = _xcode_path_placeholder,
),
platform_constraint_attrs = _platform_constraint_attrs,
run = _run,
run_shell = _run_shell,
target_arch_from_rule_ctx = _target_arch_from_rule_ctx,
Expand Down

0 comments on commit 21bd81c

Please sign in to comment.