Skip to content

Commit

Permalink
Apple Rules: rename rule implementations to follow naming convention
Browse files Browse the repository at this point in the history
Summary:
Apple and prelude rule implementation follow the convention of ending in `rule_name_impl`, this makes it very easy to search for.

Rename the non-compliant Apple implementations to follow the same convention.

Reviewed By: rmaz

Differential Revision: D63900834

fbshipit-source-id: 2cdc354dd205de28e018ea39c949bf9a40b82fe6
  • Loading branch information
milend authored and facebook-github-bot committed Oct 7, 2024
1 parent 372d72c commit c4d37d3
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions apple/apple_resource_dedupe_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ load("@prelude//apple:apple_common.bzl", "apple_common")
load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec")
load("@prelude//apple/user/apple_resource_transition.bzl", "apple_resource_transition")

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _apple_resource_dedupe_alias_impl(ctx: AnalysisContext) -> list[Provider]:
return ctx.attrs.actual.providers

registration_spec = RuleRegistrationSpec(
name = "apple_resource_dedupe_alias",
impl = _impl,
impl = _apple_resource_dedupe_alias_impl,
attrs = {
"actual": attrs.transition_dep(cfg = apple_resource_transition),
} | apple_common.skip_universal_resource_dedupe_arg(),
Expand Down
4 changes: 2 additions & 2 deletions apple/apple_static_archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ load("@prelude//linking:linkables.bzl", "linkables")
load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec")
load("@prelude//utils:arglike.bzl", "ArgLike")

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _apple_static_archive_impl(ctx: AnalysisContext) -> list[Provider]:
libtool = ctx.attrs._apple_toolchain[AppleToolchainInfo].libtool
archive_name = ctx.attrs.name if ctx.attrs.archive_name == None else ctx.attrs.archive_name
output = ctx.actions.declare_output(archive_name)
Expand Down Expand Up @@ -106,7 +106,7 @@ def _get_static_link_args(ctx: AnalysisContext) -> list[ArgLike]:

registration_spec = RuleRegistrationSpec(
name = "apple_static_archive",
impl = _impl,
impl = _apple_static_archive_impl,
attrs = {
"archive_name": attrs.option(attrs.string(), default = None),
"deps": attrs.list(attrs.dep(), default = []),
Expand Down
4 changes: 2 additions & 2 deletions apple/user/apple_resource_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _get_apple_resources_toolchain_attr():
# FIXME: prelude// should be standalone (not refer to fbcode//)
return attrs.toolchain_dep(default = "fbcode//buck2/platform/toolchain:apple-resources", providers = [AppleToolchainInfo])

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _apple_resource_bundle_impl(ctx: AnalysisContext) -> list[Provider]:
resource_output = get_apple_bundle_resource_part_list(ctx)
return [
DefaultInfo(),
Expand Down Expand Up @@ -58,6 +58,6 @@ def _apple_resource_bundle_attrs():

registration_spec = RuleRegistrationSpec(
name = "apple_resource_bundle",
impl = _impl,
impl = _apple_resource_bundle_impl,
attrs = _apple_resource_bundle_attrs(),
)
4 changes: 2 additions & 2 deletions apple/user/apple_resource_transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def _is_universal(platform: PlatformInfo, refs: struct) -> bool:
universal = platform.configuration.constraints.get(refs.universal[ConstraintSettingInfo].label)
return universal.label == refs.universal_enabled[ConstraintValueInfo].label if universal != None else False

def _impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
def _apple_resource_transition_impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
if attrs.skip_universal_resource_dedupe or not _is_universal(platform, refs):
return platform
else:
Expand All @@ -28,7 +28,7 @@ def _impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
)

apple_resource_transition = transition(
impl = _impl,
impl = _apple_resource_transition_impl,
refs = {
"cpu": "config//cpu/constraints:cpu",
"universal": "config//cpu/constraints:universal",
Expand Down
4 changes: 2 additions & 2 deletions apple/user/apple_selective_debugging.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ _SelectiveDebuggingJsonType = enum(*_SelectiveDebuggingJsonTypes)

_LOCAL_LINK_THRESHOLD = 0.2

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _apple_selective_debugging_impl(ctx: AnalysisContext) -> list[Provider]:
json_type = _SelectiveDebuggingJsonType(ctx.attrs.json_type)

# process inputs and provide them up the graph with typing
Expand Down Expand Up @@ -221,7 +221,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:

registration_spec = RuleRegistrationSpec(
name = "apple_selective_debugging",
impl = _impl,
impl = _apple_selective_debugging_impl,
attrs = {
"exclude_build_target_patterns": attrs.list(attrs.string(), default = []),
"exclude_regular_expressions": attrs.list(attrs.string(), default = []),
Expand Down
4 changes: 2 additions & 2 deletions apple/user/apple_toolchain_override.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ load("@prelude//apple:apple_toolchain_types.bzl", "AppleToolchainInfo")
load("@prelude//cxx:cxx_toolchain_types.bzl", "CxxToolchainInfo")
load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec")

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _apple_toolchain_override_impl(ctx: AnalysisContext) -> list[Provider]:
base = ctx.attrs.base[AppleToolchainInfo]
cxx_toolchain_override = ctx.attrs.cxx_toolchain[CxxToolchainInfo]
return [
Expand Down Expand Up @@ -48,7 +48,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:

registration_spec = RuleRegistrationSpec(
name = "apple_toolchain_override",
impl = _impl,
impl = _apple_toolchain_override_impl,
attrs = {
"base": attrs.toolchain_dep(providers = [AppleToolchainInfo]),
"cxx_toolchain": attrs.toolchain_dep(providers = [CxxToolchainInfo]),
Expand Down
4 changes: 2 additions & 2 deletions apple/user/apple_tools.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
load("@prelude//apple:apple_toolchain_types.bzl", "AppleToolsInfo")
load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec")

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _apple_tools_impl(ctx: AnalysisContext) -> list[Provider]:
return [
DefaultInfo(),
AppleToolsInfo(
Expand All @@ -31,7 +31,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
# toolchain/SDK specific, they're just internal helper tools.
registration_spec = RuleRegistrationSpec(
name = "apple_tools",
impl = _impl,
impl = _apple_tools_impl,
attrs = {
"adhoc_codesign_tool": attrs.option(attrs.dep(providers = [RunInfo]), default = None),
"assemble_bundle": attrs.dep(providers = [RunInfo]),
Expand Down
4 changes: 2 additions & 2 deletions apple/user/apple_xcframework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
load("@prelude//apple:apple_toolchain_types.bzl", "AppleToolsInfo")
load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec")

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _apple_xcframework_impl(ctx: AnalysisContext) -> list[Provider]:
apple_tools = ctx.attrs._apple_tools[AppleToolsInfo]

xcframework_dir = ctx.actions.declare_output(ctx.attrs.framework_name + ".xcframework", dir = True)
Expand Down Expand Up @@ -168,7 +168,7 @@ framework_split_transition = transition(

registration_spec = RuleRegistrationSpec(
name = "apple_xcframework",
impl = _impl,
impl = _apple_xcframework_impl,
attrs = {
"framework": attrs.split_transition_dep(cfg = framework_split_transition),
"framework_name": attrs.string(),
Expand Down
4 changes: 2 additions & 2 deletions apple/user/macos_transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Transforms both OS and SDK constraints.
Only sanity check for source configuration is done.
"""

def _impl(platform: PlatformInfo, refs: struct) -> PlatformInfo:
def _macos_transition_impl(platform: PlatformInfo, refs: struct) -> PlatformInfo:
# This functions operates in the following way:
# - Start with all the constraints from the platform and filter out the constraints for OS and SDK.
# - Always set the new OS constraint to macOS.
Expand Down Expand Up @@ -43,7 +43,7 @@ def _impl(platform: PlatformInfo, refs: struct) -> PlatformInfo:
configuration = new_cfg,
)

macos_transition = transition(impl = _impl, refs = {
macos_transition = transition(impl = _macos_transition_impl, refs = {
"maccatalyst_sdk": "config//os/sdk/apple/constraints:maccatalyst",
"macos": "config//os/constraints:macos",
"macos_sdk": "config//os/sdk/apple/constraints:macosx",
Expand Down
4 changes: 2 additions & 2 deletions apple/user/resource_group_map.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ load(
load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec")
load("@prelude//utils:utils.bzl", "flatten")

def _impl(ctx: AnalysisContext) -> list[Provider]:
def _resource_group_map_impl(ctx: AnalysisContext) -> list[Provider]:
resource_groups = parse_groups_definitions(ctx.attrs.map, lambda root: root.label)

resource_group_to_implicit_deps_mapping = {
Expand Down Expand Up @@ -98,7 +98,7 @@ def _fixup_mapping_to_only_include_roots_in_the_map(mapping: GroupMapping, node_

registration_spec = RuleRegistrationSpec(
name = "resource_group_map",
impl = _impl,
impl = _resource_group_map_impl,
attrs = {
"map": attrs.list(
attrs.tuple(
Expand Down
4 changes: 2 additions & 2 deletions apple/user/target_sdk_version_transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This overrides any existing target_sdk_version select.

load("@prelude//apple:versions.bzl", "TARGET_SDK_VERSIONS")

def _impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
def _target_sdk_version_transition_impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
target_sdk_version = attrs.propagated_target_sdk_version
if not target_sdk_version:
return platform
Expand All @@ -39,7 +39,7 @@ def _impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
)

target_sdk_version_transition = transition(
impl = _impl,
impl = _target_sdk_version_transition_impl,
refs = dict(
[("version", "@config//version:constraint-setting-target-sdk-version")] + {
version: "@config//version:constraint-value-target-sdk-version-" + version
Expand Down
4 changes: 2 additions & 2 deletions apple/user/watch_transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Only sanity check for source configuration is done.
load("@prelude//transitions:utils.bzl", "filtered_platform_constraints", "get_constraint_value")
load("@prelude//utils:expect.bzl", "expect")

def _impl(platform: PlatformInfo, refs: struct) -> PlatformInfo:
def _watch_transition_impl(platform: PlatformInfo, refs: struct) -> PlatformInfo:
# This functions operates in the following way:
# - Start with all the constraints from the platform and filter out the constraints for OS and SDK.
# - If the old OS constraint was iOS or watchOS, set the new constraint to be always watchOS.
Expand Down Expand Up @@ -59,7 +59,7 @@ def _impl(platform: PlatformInfo, refs: struct) -> PlatformInfo:
configuration = new_cfg,
)

watch_transition = transition(impl = _impl, refs = {
watch_transition = transition(impl = _watch_transition_impl, refs = {
"ios": "config//os/constraints:iphoneos",
"ios_device_sdk": "config//os/sdk/apple/constraints:iphoneos",
"ios_simulator_sdk": "config//os/sdk/apple/constraints:iphonesimulator",
Expand Down

0 comments on commit c4d37d3

Please sign in to comment.