From 232cbef2b356f7a3a05fbb35f585363254bbac77 Mon Sep 17 00:00:00 2001 From: Lucas Romano Date: Tue, 10 Dec 2024 19:03:33 -0300 Subject: [PATCH] fix to use bazel 8 --- MODULE.bazel | 16 +-- xcodeproj/internal/compilation_providers.bzl | 2 +- .../files/incremental_input_files.bzl | 8 +- .../files/incremental_output_files.bzl | 4 +- .../internal/files/legacy_output_files.bzl | 4 +- xcodeproj/internal/pbxproj_partials.bzl | 3 +- xcodeproj/internal/platforms.bzl | 99 ++++++++++--------- .../incremental_library_targets.bzl | 5 +- .../incremental_top_level_targets.bzl | 16 +-- .../legacy_library_targets.bzl | 3 +- .../legacy_top_level_targets.bzl | 10 +- xcodeproj/internal/product.bzl | 14 ++- 12 files changed, 102 insertions(+), 82 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 8130affdb0..f601e20230 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,16 +7,16 @@ module( ) bazel_dep(name = "bazel_features", version = "1.3.0") -bazel_dep(name = "bazel_skylib", version = "1.3.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep( name = "rules_swift", - version = "1.18.0", + version = "2.3.0", max_compatibility_level = 2, repo_name = "build_bazel_rules_swift", ) bazel_dep( name = "rules_apple", - version = "3.6.0", + version = "3.16.0", repo_name = "build_bazel_rules_apple", ) bazel_dep(name = "rules_python", version = "0.27.1") @@ -34,7 +34,7 @@ use_repo( bazel_dep( name = "apple_support", - version = "1.11.1", + version = "1.17.1", dev_dependency = True, repo_name = "build_bazel_apple_support", ) @@ -58,23 +58,23 @@ bazel_dep( # To support Bazel 8 tests single_version_override( module_name = "rules_apple", - version = "3.5.1", + version = "3.16.0", ) single_version_override( module_name = "rules_swift", - version = "1.18.0", + version = "2.3.0", ) single_version_override( module_name = "apple_support", - version = "1.15.1", + version = "1.17.0", ) # For Stardoc single_version_override( module_name = "bazel_skylib", - version = "1.6.0", + version = "1.7.1", ) apple_cc_configure = use_extension( diff --git a/xcodeproj/internal/compilation_providers.bzl b/xcodeproj/internal/compilation_providers.bzl index 42bc39f83b..d32dc60ec9 100644 --- a/xcodeproj/internal/compilation_providers.bzl +++ b/xcodeproj/internal/compilation_providers.bzl @@ -187,7 +187,7 @@ def _merge_compilation_providers( Args: apple_dynamic_framework_info: The - `apple_common.AppleDynamicFrameworkInfo` of the target, or `None`. + `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/pbxproj_partials.bzl b/xcodeproj/internal/pbxproj_partials.bzl index 1bb32fa7ba..5298fa3b10 100644 --- a/xcodeproj/internal/pbxproj_partials.bzl +++ b/xcodeproj/internal/pbxproj_partials.bzl @@ -17,7 +17,8 @@ _UNIT_TEST_PRODUCT_TYPE = "u" # com.apple.product-type.bundle.unit-test # Utility def _apple_platform_to_platform_name(platform): - return PLATFORM_NAME[platform] + apple_platform = "{}".format(platform) + return PLATFORM_NAME[apple_platform] def _dsym_files_to_string(dsym_files): dsym_paths = [] diff --git a/xcodeproj/internal/platforms.bzl b/xcodeproj/internal/platforms.bzl index d9aa298fd7..186275d9ae 100644 --- a/xcodeproj/internal/platforms.bzl +++ b/xcodeproj/internal/platforms.bzl @@ -1,63 +1,63 @@ """Module for dealing with Apple platform information.""" PLATFORM_NAME = { - apple_common.platform.ios_device: "iphoneos", - apple_common.platform.ios_simulator: "iphonesimulator", - apple_common.platform.macos: "macosx", - apple_common.platform.tvos_device: "appletvos", - apple_common.platform.tvos_simulator: "appletvsimulator", - apple_common.platform.visionos_device: "xros", - apple_common.platform.visionos_simulator: "xrsimulator", - apple_common.platform.watchos_device: "watchos", - apple_common.platform.watchos_simulator: "watchsimulator", + apple_common.platform.ios_device.name: "iphoneos", + apple_common.platform.ios_simulator.name: "iphonesimulator", + apple_common.platform.macos.name: "macosx", + apple_common.platform.tvos_device.name: "appletvos", + apple_common.platform.tvos_simulator.name: "appletvsimulator", + apple_common.platform.visionos_device.name: "xros", + apple_common.platform.visionos_simulator.name: "xrsimulator", + apple_common.platform.watchos_device.name: "watchos", + apple_common.platform.watchos_simulator.name: "watchsimulator", } _IS_SIMULATOR = { - apple_common.platform.ios_device: False, - apple_common.platform.ios_simulator: True, - apple_common.platform.macos: False, - apple_common.platform.tvos_device: False, - apple_common.platform.tvos_simulator: True, - apple_common.platform.visionos_device: False, - apple_common.platform.visionos_simulator: True, - apple_common.platform.watchos_device: False, - apple_common.platform.watchos_simulator: True, + apple_common.platform.ios_device.name: False, + apple_common.platform.ios_simulator.name: True, + apple_common.platform.macos.name: False, + apple_common.platform.tvos_device.name: False, + apple_common.platform.tvos_simulator.name: True, + apple_common.platform.visionos_device.name: False, + apple_common.platform.visionos_simulator.name: True, + apple_common.platform.watchos_device.name: False, + apple_common.platform.watchos_simulator.name: True, } _LLDB_TRIPLE_PREFIX = { - apple_common.platform.ios_device: "ios", - apple_common.platform.ios_simulator: "ios", - apple_common.platform.macos: "macosx", - apple_common.platform.tvos_device: "tvos", - apple_common.platform.tvos_simulator: "tvos", - apple_common.platform.visionos_device: "xros", - apple_common.platform.visionos_simulator: "xros", - apple_common.platform.watchos_device: "watchos", - apple_common.platform.watchos_simulator: "watchos", + apple_common.platform.ios_device.name: "ios", + apple_common.platform.ios_simulator.name: "ios", + apple_common.platform.macos.name: "macosx", + apple_common.platform.tvos_device.name: "tvos", + apple_common.platform.tvos_simulator.name: "tvos", + apple_common.platform.visionos_device.name: "xros", + apple_common.platform.visionos_simulator.name: "xros", + apple_common.platform.watchos_device.name: "watchos", + apple_common.platform.watchos_simulator.name: "watchos", } _SWIFT_TRIPLE_PREFIX = { - apple_common.platform.ios_device: "ios", - apple_common.platform.ios_simulator: "ios", - apple_common.platform.macos: "macos", - apple_common.platform.tvos_device: "tvos", - apple_common.platform.tvos_simulator: "tvos", - apple_common.platform.visionos_device: "xros", - apple_common.platform.visionos_simulator: "xros", - apple_common.platform.watchos_device: "watchos", - apple_common.platform.watchos_simulator: "watchos", + apple_common.platform.ios_device.name: "ios", + apple_common.platform.ios_simulator.name: "ios", + apple_common.platform.macos.name: "macos", + apple_common.platform.tvos_device.name: "tvos", + apple_common.platform.tvos_simulator.name: "tvos", + apple_common.platform.visionos_device.name: "xros", + apple_common.platform.visionos_simulator.name: "xros", + apple_common.platform.watchos_device.name: "watchos", + apple_common.platform.watchos_simulator.name: "watchos", } _TRIPLE_SUFFIX = { - apple_common.platform.ios_device: "", - apple_common.platform.ios_simulator: "-simulator", - apple_common.platform.macos: "", - apple_common.platform.tvos_device: "", - apple_common.platform.tvos_simulator: "-simulator", - apple_common.platform.visionos_device: "", - apple_common.platform.visionos_simulator: "-simulator", - apple_common.platform.watchos_device: "", - apple_common.platform.watchos_simulator: "-simulator", + apple_common.platform.ios_device.name: "", + apple_common.platform.ios_simulator.name: "-simulator", + apple_common.platform.macos.name: "", + apple_common.platform.tvos_device.name: "", + apple_common.platform.tvos_simulator.name: "-simulator", + apple_common.platform.visionos_device.name: "", + apple_common.platform.visionos_simulator.name: "-simulator", + apple_common.platform.watchos_device.name: "", + apple_common.platform.watchos_simulator.name: "-simulator", } def _collect_platform(*, ctx): @@ -109,10 +109,11 @@ def _platform_to_dto(platform): Args: platform: A value from `platforms.collect`. """ + apple_platform = "{}".format(platform.apple_platform) dto = { "a": platform.arch, "m": platform.os_version, - "v": PLATFORM_NAME[platform.apple_platform], + "v": PLATFORM_NAME[apple_platform], } return dto @@ -123,7 +124,7 @@ def _platform_to_swift_triple(platform): Args: platform: A value from `platforms.collect`. """ - apple_platform = platform.apple_platform + apple_platform = "{}".format(platform.apple_platform) return "{arch}-apple-{triple_prefix}{triple_suffix}".format( arch = platform.arch, triple_prefix = _SWIFT_TRIPLE_PREFIX[apple_platform], @@ -136,7 +137,9 @@ def _platform_to_lldb_context_triple(platform): Args: platform: A value from `platforms.collect`. """ - apple_platform = platform.apple_platform + apple_platform = "{}".format(platform.apple_platform) + + # struct(apple_platform = ios_simulator, arch = "arm64", os_version = "13.0") return "{arch}-apple-{triple_prefix}{triple_suffix}".format( arch = platform.arch, triple_prefix = _LLDB_TRIPLE_PREFIX[apple_platform], 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..0732c39dc8 100644 --- a/xcodeproj/internal/processed_targets/incremental_top_level_targets.bzl +++ b/xcodeproj/internal/processed_targets/incremental_top_level_targets.bzl @@ -5,8 +5,12 @@ load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load( "@build_bazel_rules_apple//apple:providers.bzl", "AppleBundleInfo", + "AppleDebugOutputsInfo", "AppleResourceInfo", ) + +# buildifier: disable=bzl-visibility +load("@build_bazel_rules_apple//apple/internal/providers:apple_dynamic_framework_info.bzl", "AppleDynamicFrameworkInfo") load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo", "SwiftProtoInfo") load( "//xcodeproj/internal:build_settings.bzl", @@ -272,9 +276,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 +495,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 @@ -927,9 +931,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..1ee1c080d3 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") @@ -133,7 +134,7 @@ 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 + debug_outputs = target[AppleDebugOutputsInfo] if AppleDebugOutputsInfo in target else None output_group_info = target[OutputGroupInfo] if OutputGroupInfo in target else None (target_outputs, provider_outputs) = output_files.collect( ctx = ctx, diff --git a/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl b/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl index 9892416d15..5cc52d7ac5 100644 --- a/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl +++ b/xcodeproj/internal/processed_targets/legacy_top_level_targets.bzl @@ -1,5 +1,9 @@ """ Functions for processing top level targets """ +load("@build_bazel_rules_apple//apple:providers.bzl", "AppleDebugOutputsInfo") + +# buildifier: disable=bzl-visibility +load("@build_bazel_rules_apple//apple/internal/providers:apple_dynamic_framework_info.bzl", "AppleDynamicFrameworkInfo") load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo") load( "//xcodeproj/internal:build_settings.bzl", @@ -325,9 +329,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,7 +416,7 @@ 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 + debug_outputs = target[AppleDebugOutputsInfo] if AppleDebugOutputsInfo in target else None output_group_info = target[OutputGroupInfo] if OutputGroupInfo in target else None (target_outputs, provider_outputs) = output_files.collect( ctx = ctx, diff --git a/xcodeproj/internal/product.bzl b/xcodeproj/internal/product.bzl index 34e29b1327..cf569f4987 100644 --- a/xcodeproj/internal/product.bzl +++ b/xcodeproj/internal/product.bzl @@ -2,6 +2,12 @@ `generation_mode = "legacy"`.""" load("@bazel_skylib//lib:paths.bzl", "paths") + +# buildifier: disable=bzl-visibility +load("@build_bazel_rules_apple//apple/internal:providers.bzl", "AppleExecutableBinaryInfo") + +# buildifier: disable=bzl-visibility +load("@build_bazel_rules_apple//apple/internal/providers:apple_dynamic_framework_info.bzl", "AppleDynamicFrameworkInfo") load("//xcodeproj/internal/files:linker_input_files.bzl", "linker_input_files") load(":memory_efficiency.bzl", "EMPTY_DEPSET") @@ -235,15 +241,15 @@ 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 - if target and apple_common.AppleExecutableBinary in target: - executable = target[apple_common.AppleExecutableBinary].binary + if target and AppleExecutableBinaryInfo in target: + executable = target[AppleExecutableBinaryInfo].binary else: executable = None