diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 321bcf68ad..f9622d0398 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -54,13 +54,13 @@ tasks: macos_last_green: name: "Last Green Bazel" # TODO: Move back to last_green ASAP - bazel: 5409637c4e2d5c010b7264172b1004a2afd46bfe + bazel: 9.0.0-pre.20250908.2 <<: *common doc_tests: name: "Doc tests" # TODO: Move back to last_green once rules_cc is fixed - bazel: 48555196ef92f54d0a331a01dac9db0a6aabc8b4 + bazel: a25f64adff6feabb8c34fdb3a5b36ca569a4c4bb platform: ubuntu2004 test_targets: - "doc/..." diff --git a/MODULE.bazel b/MODULE.bazel index 323eaf5cde..695e3cbce2 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -11,7 +11,7 @@ bazel_dep(name = "apple_support", version = "1.21.1", repo_name = "build_bazel_a bazel_dep(name = "bazel_features", version = "1.30.0") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "platforms", version = "0.0.11") -bazel_dep(name = "rules_cc", version = "0.1.2") +bazel_dep(name = "rules_cc", version = "0.2.14") bazel_dep( name = "rules_swift", version = "2.4.0", diff --git a/WORKSPACE b/WORKSPACE index 719c4da6bc..25b87e00ff 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -73,3 +73,7 @@ stardoc_external_deps() load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install") stardoc_pinned_maven_install() + +load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo") + +compatibility_proxy_repo() diff --git a/apple/dtrace.bzl b/apple/dtrace.bzl index 3c110aebc0..58e169ede1 100644 --- a/apple/dtrace.bzl +++ b/apple/dtrace.bzl @@ -28,6 +28,7 @@ load( ) load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "new_objc_provider") load( "//apple/internal/utils:bundle_paths.bzl", "bundle_paths", @@ -69,7 +70,7 @@ def _dtrace_compile_impl(ctx): include_dir = hdr.path.removesuffix(hdr_suffix) return [ - apple_common.new_objc_provider( + new_objc_provider( strict_include = depset([include_dir]), ), CcInfo( diff --git a/apple/internal/apple_framework_import.bzl b/apple/internal/apple_framework_import.bzl index f4b5625a12..c465064ea6 100644 --- a/apple/internal/apple_framework_import.bzl +++ b/apple/internal/apple_framework_import.bzl @@ -37,6 +37,7 @@ load( "swift_common", ) load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo") load( "//apple:providers.bzl", "AppleFrameworkImportInfo", @@ -347,11 +348,11 @@ def _apple_static_framework_import_impl(ctx): if swiftmodule: additional_objc_provider_fields.update(_ensure_swiftmodule_is_embedded(swiftmodule)) - # Create apple_common.Objc provider + # Create ObjcInfo provider additional_objc_providers.extend([ - dep[apple_common.Objc] + dep[ObjcInfo] for dep in deps - if apple_common.Objc in dep + if ObjcInfo in dep ]) linkopts = [] diff --git a/apple/internal/apple_xcframework_import.bzl b/apple/internal/apple_xcframework_import.bzl index 66369076a2..1932dd842f 100644 --- a/apple/internal/apple_xcframework_import.bzl +++ b/apple/internal/apple_xcframework_import.bzl @@ -24,6 +24,7 @@ load( "swift_common", ) load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo") load("//apple:providers.bzl", "AppleFrameworkImportInfo") load( "//apple/internal:apple_toolchains.bzl", @@ -659,9 +660,9 @@ def _apple_static_xcframework_import_impl(ctx): # Create Objc provider additional_objc_providers.extend([ - dep[apple_common.Objc] + dep[ObjcInfo] for dep in deps - if apple_common.Objc in dep + if ObjcInfo in dep ]) sdk_linkopts = [] diff --git a/apple/internal/header_map.bzl b/apple/internal/header_map.bzl index 04972e4275..0d103923dc 100644 --- a/apple/internal/header_map.bzl +++ b/apple/internal/header_map.bzl @@ -18,6 +18,7 @@ load("@build_bazel_rules_swift//swift:providers.bzl", "SwiftInfo") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_common") load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo", "new_objc_provider") HeaderMapInfo = provider( doc = "Provides information about created `.hmap` (header map) files", @@ -66,8 +67,8 @@ def _header_map_impl(ctx): for dep in ctx.attr.deps: found_headers = [] - if apple_common.Objc in dep: - found_headers.append(getattr(dep[apple_common.Objc], "direct_headers", [])) + if ObjcInfo in dep: + found_headers.append(getattr(dep[ObjcInfo], "direct_headers", [])) if CcInfo in dep: found_headers.append(dep[CcInfo].compilation_context.direct_headers) if not found_headers: @@ -91,7 +92,7 @@ def _header_map_impl(ctx): swift_info = SwiftInfo() return [ - apple_common.new_objc_provider(), + new_objc_provider(), swift_info, CcInfo( compilation_context = cc_common.create_compilation_context( @@ -117,7 +118,7 @@ header_map = rule( ), "deps": attr.label_list( mandatory = False, - providers = [[apple_common.Objc], [CcInfo]], + providers = [[ObjcInfo], [CcInfo]], doc = "Targets whose direct headers should be added to the list of hdrs and rooted at the module_name", ), "_hmaptool": attr.label( diff --git a/apple/internal/linking_support.bzl b/apple/internal/linking_support.bzl index 7475005f7a..b7d98afea8 100644 --- a/apple/internal/linking_support.bzl +++ b/apple/internal/linking_support.bzl @@ -21,6 +21,7 @@ load( load("@build_bazel_apple_support//lib:lipo.bzl", "lipo") load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo") load( "//apple/internal:cc_toolchain_info_support.bzl", "cc_toolchain_info_support", @@ -41,8 +42,6 @@ load( "new_appledebugoutputsinfo", ) -ObjcInfo = apple_common.Objc - def _archive_multi_arch_static_library( *, ctx, @@ -435,7 +434,7 @@ def _register_binary_linking_action( This target must propagate the `AppleExecutableBinaryInfo` provider. This simplifies the process of passing the bundle loader to all the arguments that need it: the binary will automatically be added to the linker inputs, its - path will be added to linkopts via `-bundle_loader`, and the `apple_common.Objc` + path will be added to linkopts via `-bundle_loader`, and the `ObjcInfo` provider of its dependencies (obtained from the `AppleExecutableBinaryInfo` provider) will be passed as an additional `avoid_dep` to ensure that those dependencies are subtracted when linking the bundle's binary. @@ -474,7 +473,7 @@ def _register_binary_linking_action( is a new universal (fat) binary obtained by invoking `lipo`. * `cc_info`: The CcInfo provider containing information about the targets that were linked. - * `objc`: The `apple_common.Objc` provider containing information about the targets + * `objc`: The `ObjcInfo` provider containing information about the targets that were linked. * `outputs`: A `list` of `struct`s containing the single-architecture binaries and debug outputs, with identifying information about the target platform, architecture, diff --git a/apple/internal/providers.bzl b/apple/internal/providers.bzl index 54f606f224..9c6a087033 100644 --- a/apple/internal/providers.bzl +++ b/apple/internal/providers.bzl @@ -275,7 +275,7 @@ Contains the executable binary output that was built using fields = { # TODO: Remove when we drop 7.x "objc": """\ -apple_common.Objc provider used for legacy linking behavior. +ObjcInfo provider used for legacy linking behavior. """, "binary": """\ The executable binary artifact output by `link_multi_arch_binary`. diff --git a/apple/internal/resource_rules/apple_resource_bundle.bzl b/apple/internal/resource_rules/apple_resource_bundle.bzl index ae87e73e7f..4656657769 100644 --- a/apple/internal/resource_rules/apple_resource_bundle.bzl +++ b/apple/internal/resource_rules/apple_resource_bundle.bzl @@ -15,6 +15,7 @@ """Implementation of apple_resource_bundle rule.""" load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "new_objc_provider") load( "//apple/internal:providers.bzl", "new_appleresourcebundleinfo", @@ -27,7 +28,7 @@ def _apple_resource_bundle_impl(_ctx): # be used to iterate through all relevant instances of this rule in the build graph. return [ # TODO(b/122578556): Remove this ObjC provider instance. - apple_common.new_objc_provider(), + new_objc_provider(), CcInfo(), new_appleresourcebundleinfo(), ] diff --git a/apple/internal/rule_attrs.bzl b/apple/internal/rule_attrs.bzl index c223375353..5a45cef090 100644 --- a/apple/internal/rule_attrs.bzl +++ b/apple/internal/rule_attrs.bzl @@ -27,6 +27,7 @@ load( "SwiftInfo", ) load("@rules_cc//cc/common:cc_common.bzl", "cc_common") +load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo") load( "//apple:common.bzl", "entitlements_validation_mode", @@ -664,7 +665,7 @@ def _settings_bundle_attrs(): return { "settings_bundle": attr.label( aspects = [apple_resource_aspect], - providers = [[AppleResourceBundleInfo], [apple_common.Objc]], + providers = [[AppleResourceBundleInfo], [ObjcInfo]], doc = """ A resource bundle (e.g. `apple_bundle_import`) target that contains the files that make up the application's settings bundle. These files will be copied into the root of the final application diff --git a/apple/internal/testing/apple_test_bundle_support.bzl b/apple/internal/testing/apple_test_bundle_support.bzl index 91711b4603..0c8511a357 100644 --- a/apple/internal/testing/apple_test_bundle_support.bzl +++ b/apple/internal/testing/apple_test_bundle_support.bzl @@ -23,6 +23,7 @@ load( "SwiftInfo", ) load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "ObjcInfo") load( "//apple:providers.bzl", "AppleBundleInfo", @@ -150,8 +151,8 @@ def _apple_test_info_aspect_impl(target, ctx): module_maps.append(test_info.module_maps) swift_modules.append(test_info.swift_modules) - if apple_common.Objc in target: - objc_provider = target[apple_common.Objc] + if ObjcInfo in target: + objc_provider = target[ObjcInfo] includes.append(objc_provider.strict_include) if CcInfo in target: diff --git a/apple/internal/visionos_rules.bzl b/apple/internal/visionos_rules.bzl index 0543bf9d32..376d529a4f 100644 --- a/apple/internal/visionos_rules.bzl +++ b/apple/internal/visionos_rules.bzl @@ -21,6 +21,7 @@ load( ) load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") +load("@rules_cc//cc/common:objc_info.bzl", "new_objc_provider") load( "//apple/internal:apple_product_type.bzl", "apple_product_type", @@ -746,7 +747,7 @@ def _visionos_dynamic_framework_impl(ctx): libraries = provider.framework_files.to_list(), ) additional_providers.extend([ - apple_common.new_objc_provider( + new_objc_provider( dynamic_framework_file = provider.framework_files, ), CcInfo( diff --git a/apple/repositories.bzl b/apple/repositories.bzl index f93173aa02..667550bf8c 100644 --- a/apple/repositories.bzl +++ b/apple/repositories.bzl @@ -126,7 +126,13 @@ def apple_rules_dependencies(ignore_version_differences = False, include_bzlmod_ url = "https://github.com/bazelbuild/rules_swift/releases/download/2.4.0/rules_swift.2.4.0.tar.gz", ignore_version_differences = ignore_version_differences, ) - + _maybe( + http_archive, + name = "rules_cc", + sha256 = "472ddca8cec1e64ad78e4f0cabbec55936a3baddbe7bef072764ca91504bd523", + strip_prefix = "rules_cc-0.2.13", + url = "https://github.com/bazelbuild/rules_cc/releases/download/0.2.13/rules_cc-0.2.13.tar.gz", + ) _maybe( http_archive, name = "platforms", diff --git a/doc/providers.md b/doc/providers.md index 82dd724421..bbd7280b3c 100644 --- a/doc/providers.md +++ b/doc/providers.md @@ -299,7 +299,7 @@ Contains the executable binary output that was built using | Name | Description | | :------------- | :------------- | -| objc | apple_common.Objc provider used for legacy linking behavior. | +| objc | ObjcInfo provider used for legacy linking behavior. | | binary | The executable binary artifact output by `link_multi_arch_binary`. | | cc_info | A `CcInfo` which contains information about the transitive dependencies linked into the binary. |