From 739b881030cae1eb4e0b2004c8974015cdf6a1a1 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 13 Dec 2024 11:13:49 -0600 Subject: [PATCH] Upgrade to rules_apple 3.16.1 (#3114) --- MODULE.bazel | 13 +++---- README.md | 3 +- buildbuddy.yaml | 9 +++-- examples/integration/MODULE.bazel | 2 +- .../integration/iOSApp/external/MODULE.bazel | 2 +- examples/rules_ios/MODULE.bazel | 2 +- xcodeproj/internal/compilation_providers.bzl | 4 +-- .../files/incremental_input_files.bzl | 8 ++--- .../files/incremental_output_files.bzl | 4 +-- .../internal/files/legacy_output_files.bzl | 4 +-- .../incremental_library_targets.bzl | 5 +-- .../incremental_top_level_targets.bzl | 32 ++++++++++++----- .../legacy_library_targets.bzl | 21 +++++++++-- .../legacy_top_level_targets.bzl | 36 ++++++++++++++++--- xcodeproj/internal/product.bzl | 15 ++++++-- xcodeproj/repositories.bzl | 4 +-- 16 files changed, 119 insertions(+), 45 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 8130affdb0..3d44c22c6a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,7 +16,7 @@ bazel_dep( ) bazel_dep( name = "rules_apple", - version = "3.6.0", + version = "3.16.1", repo_name = "build_bazel_rules_apple", ) bazel_dep(name = "rules_python", version = "0.27.1") @@ -56,11 +56,6 @@ bazel_dep( ) # To support Bazel 8 tests -single_version_override( - module_name = "rules_apple", - version = "3.5.1", -) - single_version_override( module_name = "rules_swift", version = "1.18.0", @@ -71,6 +66,12 @@ single_version_override( version = "1.15.1", ) +# Some of our deps are forcing a new stardoc on us, so pinning for now +single_version_override( + module_name = "stardoc", + version = "0.6.1", +) + # For Stardoc single_version_override( module_name = "bazel_skylib", diff --git a/README.md b/README.md index 9a5385df8e..dc578c0b19 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,8 @@ to include it in the list above. | rules_xcodeproj | Bazel | [rules_apple][1] | [rules_swift][2] | Xcode | macOS | Supporting Branch | | :-------------: | :---: | :--------------: | :--------------: | :---: | :---: | :---------------: | -| 1.17.0+ | 6.3-7.x | 1.0.1–2.x | 1.x | 13.3–15.x | 13–14.x | `main` | +| 2.10.0+ | 7.0-8.x | 3.16.1+ | 1.18.0+ | 13.3–15.x | 13–14.x | `main` | +| 1.17.0+ | 6.3-7.x | 1.0.1–2.x | 1.x | 13.3–15.x | 13–14.x | - | | 1.16.0 | 6.3-7.x | 1.0.1–2.x | 1.x | 13.3–15.2 | 13–14.x | - | | 1.14.0-1.15.0 | 6.1-7.x | 1.0.1–2.x | 1.x | 13.3–15.2 | 13–14.x | - | | 1.7.0-1.13.0 | 5.3–6.x | 1.0.1–2.x | 1.x | 13.3–15.2 | 12–13.x | - | diff --git a/buildbuddy.yaml b/buildbuddy.yaml index 09990c2884..276c3a74bd 100644 --- a/buildbuddy.yaml +++ b/buildbuddy.yaml @@ -17,16 +17,15 @@ x_templates: env: {} - &bazel_previous_lts env: - USE_BAZEL_VERSION: 6.x + USE_BAZEL_VERSION: 7.x - &bazel_lts env: + # FIXME: Adjust to 8.x USE_BAZEL_VERSION: 7.x - &bazel_head env: - # See https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3029 - # - # Temporary change to make CI pass until the fix is in `last_green` - USE_BAZEL_VERSION: dd2464a5933e0a5a6765024573832717b71989bf + # FIXME: Adjust to `last_green` + USE_BAZEL_VERSION: 7.x - &normal_resources resource_requests: { memory: 6GB } diff --git a/examples/integration/MODULE.bazel b/examples/integration/MODULE.bazel index ebb3fef268..42a164ceb6 100644 --- a/examples/integration/MODULE.bazel +++ b/examples/integration/MODULE.bazel @@ -10,7 +10,7 @@ bazel_dep( ) bazel_dep( name = "rules_apple", - version = "3.6.0", + version = "3.16.1", repo_name = "build_bazel_rules_apple", ) bazel_dep( diff --git a/examples/integration/iOSApp/external/MODULE.bazel b/examples/integration/iOSApp/external/MODULE.bazel index 5b19970140..dd5dfc0bf7 100644 --- a/examples/integration/iOSApp/external/MODULE.bazel +++ b/examples/integration/iOSApp/external/MODULE.bazel @@ -6,6 +6,6 @@ module( bazel_dep( name = "rules_apple", - version = "2.1.0", + version = "3.16.1", repo_name = "build_bazel_rules_apple", ) diff --git a/examples/rules_ios/MODULE.bazel b/examples/rules_ios/MODULE.bazel index 8b97a3cb3b..9592c21496 100644 --- a/examples/rules_ios/MODULE.bazel +++ b/examples/rules_ios/MODULE.bazel @@ -10,7 +10,7 @@ bazel_dep( ) bazel_dep( name = "rules_apple", - version = "3.2.1", + version = "3.16.1", repo_name = "build_bazel_rules_apple", ) bazel_dep( diff --git a/xcodeproj/internal/compilation_providers.bzl b/xcodeproj/internal/compilation_providers.bzl index 42bc39f83b..9fd1e31d0d 100644 --- a/xcodeproj/internal/compilation_providers.bzl +++ b/xcodeproj/internal/compilation_providers.bzl @@ -186,8 +186,8 @@ def _merge_compilation_providers( """Merges compilation providers from the deps of a target. Args: - apple_dynamic_framework_info: The - `apple_common.AppleDynamicFrameworkInfo` of the target, or `None`. + apple_dynamic_framework_info: The `AppleDynamicFrameworkInfo` of the + target, or `None`. cc_info: The `CcInfo` of the target, or `None`. propagate_providers: A `bool` indicating whether providers should be propagated to downstream targets. diff --git a/xcodeproj/internal/files/incremental_input_files.bzl b/xcodeproj/internal/files/incremental_input_files.bzl index 5906260966..b509a9e402 100644 --- a/xcodeproj/internal/files/incremental_input_files.bzl +++ b/xcodeproj/internal/files/incremental_input_files.bzl @@ -262,8 +262,8 @@ def _collect_incremental_input_files( avoid_deps: A `list` of the targets that already consumed resources, and their resources shouldn't be bundled with the target. framework_files: A `depset` of framework files from - `AppleDynamicFramework.framework_files`, if the target has the - `AppleDynamicFramework` provider. + `AppleDynamicFrameworkInfo.framework_files`, if the target has the + `AppleDynamicFrameworkInfo` provider. focused_labels: A `depset` of label strings of focused targets. This will include the current target (if focused) and any focused dependencies of the current target. This is only set for top-level @@ -955,8 +955,8 @@ def _merge_top_level_input_files( will include the current target (if focused) and any focused dependencies of the current target. framework_files: A `depset` of framework files from - `AppleDynamicFramework.framework_files`, if the target has the - `AppleDynamicFramework` provider. + `AppleDynamicFrameworkInfo.framework_files`, if the target has the + `AppleDynamicFrameworkInfo` provider. platform: A value from `platforms.collect`. resource_info: The `AppleResourceInfo` provider for the target if it is resource bundle consuming. diff --git a/xcodeproj/internal/files/incremental_output_files.bzl b/xcodeproj/internal/files/incremental_output_files.bzl index 19f8169991..febe94f62b 100644 --- a/xcodeproj/internal/files/incremental_output_files.bzl +++ b/xcodeproj/internal/files/incremental_output_files.bzl @@ -51,7 +51,7 @@ def _get_outputs(*, debug_outputs, product, swift_info, output_group_info): indexing process. Args: - debug_outputs: The `AppleDebugOutputs` provider for the target, or + debug_outputs: The `AppleDebugOutputsInfo` provider for the target, or `None`. output_group_info: The `OutputGroupInfo` provider for the target, or `None`. @@ -143,7 +143,7 @@ def _collect_incremental_output_files( copy_product_transitively: Whether or not to copy the product transitively. Currently this should only be true for top-level targets. - debug_outputs: The `AppleDebugOutputs` provider for the target, or + debug_outputs: The `AppleDebugOutputsInfo` provider for the target, or `None`. id: A unique identifier for the target. indexstore_overrides: A `list` of `(indexstore, target_name)` `tuple`s diff --git a/xcodeproj/internal/files/legacy_output_files.bzl b/xcodeproj/internal/files/legacy_output_files.bzl index 31fe9909c6..1e008154eb 100644 --- a/xcodeproj/internal/files/legacy_output_files.bzl +++ b/xcodeproj/internal/files/legacy_output_files.bzl @@ -50,7 +50,7 @@ def _get_outputs(*, debug_outputs, id, product, swift_info, output_group_info): indexing process. Args: - debug_outputs: The `AppleDebugOutputs` provider for the target, or + debug_outputs: The `AppleDebugOutputsInfo` provider for the target, or `None`. id: The unique identifier of the target. output_group_info: The `OutputGroupInfo` provider for the target, or @@ -137,7 +137,7 @@ def _collect_legacy_output_files( copy_product_transitively: Whether or not to copy the product transitively. Currently this should only be true for top-level targets. - debug_outputs: The `AppleDebugOutputs` provider for the target, or + debug_outputs: The `AppleDebugOutputsInfo` provider for the target, or `None`. id: A unique identifier for the target. output_group_info: The `OutputGroupInfo` provider for the target, or diff --git a/xcodeproj/internal/processed_targets/incremental_library_targets.bzl b/xcodeproj/internal/processed_targets/incremental_library_targets.bzl index 47e3ee2861..6a09c0437f 100644 --- a/xcodeproj/internal/processed_targets/incremental_library_targets.bzl +++ b/xcodeproj/internal/processed_targets/incremental_library_targets.bzl @@ -1,6 +1,7 @@ """Functions for processing library targets.""" load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") +load("@build_bazel_rules_apple//apple:providers.bzl", "AppleDebugOutputsInfo") load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "SwiftProtoInfo") load("//xcodeproj/internal:build_settings.bzl", "get_product_module_name") load("//xcodeproj/internal:compilation_providers.bzl", "compilation_providers") @@ -154,8 +155,8 @@ def _process_incremental_library_target( ] if not swift_debug_settings_file else None, ) - if apple_common.AppleDebugOutputs in target: - debug_outputs = target[apple_common.AppleDebugOutputs] + if AppleDebugOutputsInfo in target: + debug_outputs = target[AppleDebugOutputsInfo] else: debug_outputs = None diff --git a/xcodeproj/internal/processed_targets/incremental_top_level_targets.bzl b/xcodeproj/internal/processed_targets/incremental_top_level_targets.bzl index c7cd9e513a..73a9f2920c 100644 --- a/xcodeproj/internal/processed_targets/incremental_top_level_targets.bzl +++ b/xcodeproj/internal/processed_targets/incremental_top_level_targets.bzl @@ -5,6 +5,8 @@ load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load( "@build_bazel_rules_apple//apple:providers.bzl", "AppleBundleInfo", + "AppleDebugOutputsInfo", + "AppleDynamicFrameworkInfo", "AppleResourceInfo", ) load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "SwiftProtoInfo") @@ -84,6 +86,20 @@ _TEST_HOST_PRODUCT_TYPES = { "w": None, # com.apple.product-type.application.watchapp2 } +# TODO: Remove when we drop 7.x +_AppleDebugOutputsInfo = getattr( + apple_common, + "AppleDebugOutputs", + AppleDebugOutputsInfo, +) + +# TODO: Remove when we drop 7.x +_AppleDynamicFrameworkInfo = getattr( + apple_common, + "AppleDynamicFramework", + AppleDynamicFrameworkInfo, +) + def _calculate_product_type(*, target_files, bundle_info): """Calculates the product type for a top level target. @@ -272,9 +288,9 @@ def _process_focused_top_level_target( target = target, ) - if target and apple_common.AppleDynamicFramework in target: + if target and _AppleDynamicFrameworkInfo in target: framework_files = ( - target[apple_common.AppleDynamicFramework].framework_files + target[_AppleDynamicFrameworkInfo].framework_files ) product_file = product.file framework_product_mappings = [ @@ -491,8 +507,8 @@ def _process_focused_top_level_target( ], ) - if apple_common.AppleDebugOutputs in target: - debug_outputs = target[apple_common.AppleDebugOutputs] + if _AppleDebugOutputsInfo in target: + debug_outputs = target[_AppleDebugOutputsInfo] else: debug_outputs = None @@ -730,9 +746,9 @@ def _process_unfocused_top_level_target( target = target, ) - if target and apple_common.AppleDynamicFramework in target: + if target and _AppleDynamicFrameworkInfo in target: framework_files = ( - target[apple_common.AppleDynamicFramework].framework_files + target[_AppleDynamicFrameworkInfo].framework_files ) slim_product_file = slim_product.file framework_product_mappings = [ @@ -927,9 +943,9 @@ def _process_incremental_top_level_target( ), ) - if apple_common.AppleDynamicFramework in target: + if _AppleDynamicFrameworkInfo in target: apple_dynamic_framework_info = ( - target[apple_common.AppleDynamicFramework] + target[_AppleDynamicFrameworkInfo] ) else: apple_dynamic_framework_info = None diff --git a/xcodeproj/internal/processed_targets/legacy_library_targets.bzl b/xcodeproj/internal/processed_targets/legacy_library_targets.bzl index 786d253e48..95669908ed 100644 --- a/xcodeproj/internal/processed_targets/legacy_library_targets.bzl +++ b/xcodeproj/internal/processed_targets/legacy_library_targets.bzl @@ -1,5 +1,6 @@ """Functions for processing library targets.""" +load("@build_bazel_rules_apple//apple:providers.bzl", "AppleDebugOutputsInfo") load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo") load("//xcodeproj/internal:build_settings.bzl", "get_product_module_name") load("//xcodeproj/internal:collections.bzl", "set_if_true") @@ -36,6 +37,13 @@ load( processed_targets = "legacy_processed_targets", ) +# TODO: Remove when we drop 7.x +_AppleDebugOutputsInfo = getattr( + apple_common, + "AppleDebugOutputs", + AppleDebugOutputsInfo, +) + def _process_legacy_library_target( *, ctx, @@ -133,8 +141,17 @@ def _process_legacy_library_target( modulemaps = modulemaps, transitive_infos = transitive_infos, ) - debug_outputs = target[apple_common.AppleDebugOutputs] if apple_common.AppleDebugOutputs in target else None - output_group_info = target[OutputGroupInfo] if OutputGroupInfo in target else None + + if _AppleDebugOutputsInfo in target: + debug_outputs = target[_AppleDebugOutputsInfo] + else: + debug_outputs = None + + if OutputGroupInfo in target: + output_group_info = target[OutputGroupInfo] + else: + output_group_info = None + (target_outputs, provider_outputs) = output_files.collect( ctx = ctx, debug_outputs = debug_outputs, diff --git a/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl b/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl index 9892416d15..6e1787945e 100644 --- a/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl +++ b/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl @@ -1,5 +1,10 @@ """ Functions for processing top level targets """ +load( + "@build_bazel_rules_apple//apple:providers.bzl", + "AppleDebugOutputsInfo", + "AppleDynamicFrameworkInfo", +) load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo") load( "//xcodeproj/internal:build_settings.bzl", @@ -48,6 +53,20 @@ load( processed_targets = "legacy_processed_targets", ) +# TODO: Remove when we drop 7.x +_AppleDebugOutputsInfo = getattr( + apple_common, + "AppleDebugOutputs", + AppleDebugOutputsInfo, +) + +# TODO: Remove when we drop 7.x +_AppleDynamicFrameworkInfo = getattr( + apple_common, + "AppleDynamicFramework", + AppleDynamicFrameworkInfo, +) + def _get_codesign_opts(*, ctx, inputs_attr, opts_attr, rule_attr): if not opts_attr: return ([], []) @@ -325,9 +344,9 @@ def _process_legacy_top_level_target( else: avoid_compilation_providers = None - if apple_common.AppleDynamicFramework in target: + if _AppleDynamicFrameworkInfo in target: apple_dynamic_framework_info = ( - target[apple_common.AppleDynamicFramework] + target[_AppleDynamicFrameworkInfo] ) else: apple_dynamic_framework_info = None @@ -412,8 +431,17 @@ def _process_legacy_top_level_target( transitive_infos = transitive_infos, avoid_deps = avoid_deps, ) - debug_outputs = target[apple_common.AppleDebugOutputs] if apple_common.AppleDebugOutputs in target else None - output_group_info = target[OutputGroupInfo] if OutputGroupInfo in target else None + + if _AppleDebugOutputsInfo in target: + debug_outputs = target[_AppleDebugOutputsInfo] + else: + debug_outputs = None + + if OutputGroupInfo in target: + output_group_info = target[OutputGroupInfo] + else: + output_group_info = None + (target_outputs, provider_outputs) = output_files.collect( ctx = ctx, copy_product_transitively = True, diff --git a/xcodeproj/internal/product.bzl b/xcodeproj/internal/product.bzl index 34e29b1327..32d2b57f37 100644 --- a/xcodeproj/internal/product.bzl +++ b/xcodeproj/internal/product.bzl @@ -2,6 +2,10 @@ `generation_mode = "legacy"`.""" load("@bazel_skylib//lib:paths.bzl", "paths") +load( + "@build_bazel_rules_apple//apple:providers.bzl", + "AppleDynamicFrameworkInfo", +) load("//xcodeproj/internal/files:linker_input_files.bzl", "linker_input_files") load(":memory_efficiency.bzl", "EMPTY_DEPSET") @@ -43,6 +47,13 @@ _ARCHIVE_EXTENSIONS = { "zip": None, } +# TODO: Remove when we drop 7.x +_AppleDynamicFrameworkInfo = getattr( + apple_common, + "AppleDynamicFramework", + AppleDynamicFrameworkInfo, +) + def _codesign_executable(*, actions, executable): executable_path = "{}_codesigned".format( executable.basename, @@ -235,9 +246,9 @@ def process_product( original_path = None path = None - if target and apple_common.AppleDynamicFramework in target: + if target and _AppleDynamicFrameworkInfo in target: framework_files = ( - target[apple_common.AppleDynamicFramework].framework_files + target[_AppleDynamicFrameworkInfo].framework_files ) else: framework_files = EMPTY_DEPSET diff --git a/xcodeproj/repositories.bzl b/xcodeproj/repositories.bzl index 35d1fd7c7b..f3f43e6bd9 100644 --- a/xcodeproj/repositories.bzl +++ b/xcodeproj/repositories.bzl @@ -128,8 +128,8 @@ def xcodeproj_rules_dependencies( _maybe( http_archive, name = "build_bazel_rules_apple", - sha256 = "b4df908ec14868369021182ab191dbd1f40830c9b300650d5dc389e0b9266c8d", - url = "https://github.com/bazelbuild/rules_apple/releases/download/3.5.1/rules_apple.3.5.1.tar.gz", + sha256 = "352428421c89dba8859055c3e1ba42f742c224544bf0e196c926d1cf44a2d726", + url = "https://github.com/bazelbuild/rules_apple/releases/download/3.16.1/rules_apple.3.16.1.tar.gz", ignore_version_differences = ignore_version_differences, )