Skip to content

Commit

Permalink
PMNG-7009 [platform] Revert to commit before breaking + Add force loa…
Browse files Browse the repository at this point in the history
…d libs to CcInfo linking context in Bazel 7 (#3)

* Revert "Add force load libs to CcInfo linking context in Bazel 7 (#2)"

This reverts commit fb395f9.

* Revert "Re-add ios_multi_cpus transition setting from rules_ios (bazel-ios#856)"

This reverts commit 6d6e051.

* Revert "Safer objc_provider assignment in apple_framework_packaging (bazel-ios#855)"

This reverts commit 30733da.

* Revert "Forward package_name to swift_library part of apple_library (bazel-ios#853)"

This reverts commit 3b0ca4c.

* Revert "Allow consumers to set always_include_developer_search_paths in swift_library (bazel-ios#852)"

This reverts commit da630a2.

* Revert "Update transition support (bazel-ios#847)"

This reverts commit 144eb18.

* PMNG-7009 [platform] Add force load libs to CcInfo linking context in Bazel 7

---------

Co-authored-by: Leonid Melnyk <leonid.melnyk@revolut.com>
  • Loading branch information
leonidmelnyk and Leonid Melnyk authored Apr 5, 2024
1 parent fb395f9 commit d5d34b4
Show file tree
Hide file tree
Showing 20 changed files with 363 additions and 548 deletions.
16 changes: 0 additions & 16 deletions docs/transition_support_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

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: 0 additions & 1 deletion rules/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ bzl_library(
visibility = ["//visibility:public"],
deps = [
"@build_bazel_apple_support//configs:platforms",
"@build_bazel_rules_apple//apple",
],
)

Expand Down
3 changes: 1 addition & 2 deletions rules/force_load_direct_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def _force_load_direct_deps_impl(ctx):
avoid_deps.extend(dep[AvoidDepsInfo].libraries)

avoid_libraries = {}

_is_bazel_7 = not hasattr(apple_common, "apple_crosstool_transition")
if _is_bazel_7:
for dep in avoid_deps:
Expand Down Expand Up @@ -77,7 +76,7 @@ force_load_direct_deps = rule(
implementation = _force_load_direct_deps_impl,
attrs = {
"deps": attr.label_list(
cfg = transition_support.apple_platform_split_transition,
cfg = transition_support.split_transition,
mandatory = True,
doc =
"Deps",
Expand Down
18 changes: 9 additions & 9 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,8 @@ def _apple_framework_packaging_impl(ctx):
default_info = DefaultInfo(files = depset(out_files + bundle_outs.files.to_list()))

objc_provider = objc_provider_utils.merge_objc_providers(
providers = [dep[apple_common.Objc] for dep in deps if apple_common.Objc in dep],
transitive = [dep[apple_common.Objc] for dep in transitive_deps if apple_common.Objc in dep],
providers = [dep[apple_common.Objc] for dep in deps],
transitive = [dep[apple_common.Objc] for dep in transitive_deps],
)
return [
avoid_deps_info,
Expand All @@ -1106,23 +1106,23 @@ apple_framework_packaging = rule(
),
"deps": attr.label_list(
mandatory = True,
cfg = transition_support.apple_platform_split_transition,
cfg = transition_support.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.apple_platform_split_transition,
cfg = transition_support.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.apple_platform_split_transition,
cfg = transition_support.split_transition,
allow_files = True,
doc =
"""Objc or Swift rules to be packed by the framework rule
Expand All @@ -1144,15 +1144,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.apple_platform_split_transition,
cfg = transition_support.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.apple_platform_split_transition,
cfg = transition_support.split_transition,
doc =
"""Deps of the deps
""",
Expand Down Expand Up @@ -1197,7 +1197,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.apple_platform_split_transition,
cfg = transition_support.split_transition,
),
"_headermap_builder": attr.label(
executable = True,
Expand All @@ -1216,7 +1216,7 @@ that this target depends on.
""",
),
"_child_configuration_dummy": attr.label(
cfg = transition_support.apple_platform_split_transition,
cfg = transition_support.split_transition,
providers = [cc_common.CcToolchainInfo, ApplePlatformInfo],
default = Label("@build_bazel_rules_apple//apple:default_cc_toolchain_forwarder"),
),
Expand Down
11 changes: 6 additions & 5 deletions rules/internal/framework_middleman.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ load(
"new_iosframeworkbundleinfo",
)
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load(
"@build_bazel_rules_apple//apple/internal:partials.bzl",
Expand Down Expand Up @@ -166,7 +165,7 @@ framework_middleman = rule(
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
attrs = {
"framework_deps": attr.label_list(
cfg = transition_support.apple_platform_split_transition,
cfg = transition_support.split_transition,
mandatory = True,
doc =
"""Deps that may contain frameworks
Expand Down Expand Up @@ -198,7 +197,8 @@ framework_middleman = rule(
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
doc = """Needed to allow this rule to have an incoming edge configuration transition.
""",
),
},
doc = """
Expand Down Expand Up @@ -308,7 +308,7 @@ dep_middleman = rule(
implementation = _dep_middleman,
attrs = {
"deps": attr.label_list(
cfg = transition_support.apple_platform_split_transition,
cfg = transition_support.split_transition,
mandatory = True,
doc =
"""Deps that may contain frameworks
Expand All @@ -328,7 +328,8 @@ dep_middleman = rule(
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
doc = "Needed to allow this rule to have an incoming edge configuration transition.",
doc = """Needed to allow this rule to have an incoming edge configuration transition.
""",
),
},
doc = """
Expand Down
18 changes: 5 additions & 13 deletions rules/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ GLOBAL_INDEX_STORE_PATH = "bazel-out/_global_index_store"

_MANUAL = ["manual"]

_SWIFT_LIBRARY_KWARGS = [
"always_include_developer_search_paths",
"package_name",
"plugins",
]

def _private_headers_impl(ctx):
return [
PrivateHeadersInfo(
Expand Down Expand Up @@ -584,10 +578,7 @@ def apple_library(
defines = kwargs.pop("defines", [])
testonly = kwargs.pop("testonly", False)
features = kwargs.pop("features", [])

# Collect the swift_library related kwargs, these are typically only set when provided to allow
# for wider compatibility with rule_swift versions.
swift_kwargs = {arg: kwargs.pop(arg) for arg in _SWIFT_LIBRARY_KWARGS if arg in kwargs}
plugins = kwargs.pop("plugins", None)

for (k, v) in {"momc_copts": momc_copts, "mapc_copts": mapc_copts, "ibtool_copts": ibtool_copts}.items():
if v:
Expand Down Expand Up @@ -966,8 +957,9 @@ def apple_library(
)

if swift_sources:
# Forward the kwargs and the swift specific kwargs to the swift_library
swift_library_kwargs = dicts.add(kwargs, swift_kwargs)
# To be backward compatible with rules_apple 2.x
swift_kwargs = dicts.add(kwargs, {"plugins": plugins} if plugins else {})

swift_library(
name = swift_libname,
module_name = module_name,
Expand All @@ -993,7 +985,7 @@ def apple_library(
tags = tags_manual,
defines = defines + swift_defines,
testonly = testonly,
**swift_library_kwargs
**swift_kwargs
)
lib_names.append(swift_libname)

Expand Down
Loading

0 comments on commit d5d34b4

Please sign in to comment.