Skip to content

Commit b35bbe1

Browse files
committed
Migrate ObjcInfo to rules_cc
Using #2801 as a starting point
1 parent 34db795 commit b35bbe1

14 files changed

+40
-23
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bazel_dep(name = "apple_support", version = "1.21.1", repo_name = "build_bazel_a
1111
bazel_dep(name = "bazel_features", version = "1.30.0")
1212
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1313
bazel_dep(name = "platforms", version = "0.0.11")
14-
bazel_dep(name = "rules_cc", version = "0.1.2")
14+
bazel_dep(name = "rules_cc", version = "0.2.14")
1515
bazel_dep(
1616
name = "rules_swift",
1717
version = "2.4.0",

WORKSPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ stardoc_external_deps()
7373
load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")
7474

7575
stardoc_pinned_maven_install()
76+
77+
load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo")
78+
79+
compatibility_proxy_repo()

apple/dtrace.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ load(
2828
)
2929
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
3030
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
31+
load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo")
3132
load(
3233
"//apple/internal/utils:bundle_paths.bzl",
3334
"bundle_paths",
@@ -69,7 +70,7 @@ def _dtrace_compile_impl(ctx):
6970
include_dir = hdr.path.removesuffix(hdr_suffix)
7071

7172
return [
72-
apple_common.new_objc_provider(
73+
ObjcInfo(
7374
strict_include = depset([include_dir]),
7475
),
7576
CcInfo(

apple/internal/apple_framework_import.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ load(
3737
"swift_common",
3838
)
3939
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
40+
load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo")
4041
load(
4142
"//apple:providers.bzl",
4243
"AppleFrameworkImportInfo",
@@ -347,11 +348,11 @@ def _apple_static_framework_import_impl(ctx):
347348
if swiftmodule:
348349
additional_objc_provider_fields.update(_ensure_swiftmodule_is_embedded(swiftmodule))
349350

350-
# Create apple_common.Objc provider
351+
# Create ObjcInfo provider
351352
additional_objc_providers.extend([
352-
dep[apple_common.Objc]
353+
dep[ObjcInfo]
353354
for dep in deps
354-
if apple_common.Objc in dep
355+
if ObjcInfo in dep
355356
])
356357

357358
linkopts = []

apple/internal/apple_xcframework_import.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ load(
2424
"swift_common",
2525
)
2626
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
27+
load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo")
2728
load("//apple:providers.bzl", "AppleFrameworkImportInfo")
2829
load(
2930
"//apple/internal:apple_toolchains.bzl",
@@ -659,9 +660,9 @@ def _apple_static_xcframework_import_impl(ctx):
659660

660661
# Create Objc provider
661662
additional_objc_providers.extend([
662-
dep[apple_common.Objc]
663+
dep[ObjcInfo]
663664
for dep in deps
664-
if apple_common.Objc in dep
665+
if ObjcInfo in dep
665666
])
666667

667668
sdk_linkopts = []

apple/internal/header_map.bzl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ load("@build_bazel_rules_swift//swift:providers.bzl", "SwiftInfo")
1818
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_common")
1919
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
2020
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
21+
load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo")
2122

2223
HeaderMapInfo = provider(
2324
doc = "Provides information about created `.hmap` (header map) files",
@@ -66,8 +67,8 @@ def _header_map_impl(ctx):
6667

6768
for dep in ctx.attr.deps:
6869
found_headers = []
69-
if apple_common.Objc in dep:
70-
found_headers.append(getattr(dep[apple_common.Objc], "direct_headers", []))
70+
if ObjcInfo in dep:
71+
found_headers.append(getattr(dep[ObjcInfo], "direct_headers", []))
7172
if CcInfo in dep:
7273
found_headers.append(dep[CcInfo].compilation_context.direct_headers)
7374
if not found_headers:
@@ -91,7 +92,7 @@ def _header_map_impl(ctx):
9192
swift_info = SwiftInfo()
9293

9394
return [
94-
apple_common.new_objc_provider(),
95+
ObjcInfo(),
9596
swift_info,
9697
CcInfo(
9798
compilation_context = cc_common.create_compilation_context(
@@ -117,7 +118,7 @@ header_map = rule(
117118
),
118119
"deps": attr.label_list(
119120
mandatory = False,
120-
providers = [[apple_common.Objc], [CcInfo]],
121+
providers = [[ObjcInfo], [CcInfo]],
121122
doc = "Targets whose direct headers should be added to the list of hdrs and rooted at the module_name",
122123
),
123124
"_hmaptool": attr.label(

apple/internal/linking_support.bzl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ load(
2121
load("@build_bazel_apple_support//lib:lipo.bzl", "lipo")
2222
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
2323
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
24+
load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo")
2425
load(
2526
"//apple/internal:cc_toolchain_info_support.bzl",
2627
"cc_toolchain_info_support",
@@ -41,8 +42,6 @@ load(
4142
"new_appledebugoutputsinfo",
4243
)
4344

44-
ObjcInfo = apple_common.Objc
45-
4645
def _archive_multi_arch_static_library(
4746
*,
4847
ctx,
@@ -435,7 +434,7 @@ def _register_binary_linking_action(
435434
This target must propagate the `AppleExecutableBinaryInfo` provider.
436435
This simplifies the process of passing the bundle loader to all the arguments
437436
that need it: the binary will automatically be added to the linker inputs, its
438-
path will be added to linkopts via `-bundle_loader`, and the `apple_common.Objc`
437+
path will be added to linkopts via `-bundle_loader`, and the `ObjcInfo`
439438
provider of its dependencies (obtained from the `AppleExecutableBinaryInfo` provider)
440439
will be passed as an additional `avoid_dep` to ensure that those dependencies are
441440
subtracted when linking the bundle's binary.
@@ -474,7 +473,7 @@ def _register_binary_linking_action(
474473
is a new universal (fat) binary obtained by invoking `lipo`.
475474
* `cc_info`: The CcInfo provider containing information about the targets that were
476475
linked.
477-
* `objc`: The `apple_common.Objc` provider containing information about the targets
476+
* `objc`: The `ObjcInfo` provider containing information about the targets
478477
that were linked.
479478
* `outputs`: A `list` of `struct`s containing the single-architecture binaries and
480479
debug outputs, with identifying information about the target platform, architecture,

apple/internal/providers.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ Contains the executable binary output that was built using
275275
fields = {
276276
# TODO: Remove when we drop 7.x
277277
"objc": """\
278-
apple_common.Objc provider used for legacy linking behavior.
278+
ObjcInfo provider used for legacy linking behavior.
279279
""",
280280
"binary": """\
281281
The executable binary artifact output by `link_multi_arch_binary`.

apple/internal/resource_rules/apple_resource_bundle.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Implementation of apple_resource_bundle rule."""
1616

1717
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
18+
load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo")
1819
load(
1920
"//apple/internal:providers.bzl",
2021
"new_appleresourcebundleinfo",
@@ -27,7 +28,7 @@ def _apple_resource_bundle_impl(_ctx):
2728
# be used to iterate through all relevant instances of this rule in the build graph.
2829
return [
2930
# TODO(b/122578556): Remove this ObjC provider instance.
30-
apple_common.new_objc_provider(),
31+
ObjcInfo(),
3132
CcInfo(),
3233
new_appleresourcebundleinfo(),
3334
]

apple/internal/rule_attrs.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ load(
2727
"SwiftInfo",
2828
)
2929
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
30+
load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo")
3031
load(
3132
"//apple:common.bzl",
3233
"entitlements_validation_mode",
@@ -664,7 +665,7 @@ def _settings_bundle_attrs():
664665
return {
665666
"settings_bundle": attr.label(
666667
aspects = [apple_resource_aspect],
667-
providers = [[AppleResourceBundleInfo], [apple_common.Objc]],
668+
providers = [[AppleResourceBundleInfo], [ObjcInfo]],
668669
doc = """
669670
A resource bundle (e.g. `apple_bundle_import`) target that contains the files that make up the
670671
application's settings bundle. These files will be copied into the root of the final application

0 commit comments

Comments
 (0)