diff --git a/MODULE.bazel b/MODULE.bazel index 3d44c22c6a..c529b0b03e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -45,7 +45,7 @@ bazel_dep( ) bazel_dep( name = "rules_pkg", - version = "0.9.1", + version = "1.0.1", dev_dependency = True, ) bazel_dep( @@ -55,15 +55,15 @@ bazel_dep( repo_name = "io_bazel_stardoc", ) -# To support Bazel 8 tests +# Use newer versions of deps in development single_version_override( - module_name = "rules_swift", - version = "1.18.0", + module_name = "apple_support", + version = "1.17.1", ) single_version_override( - module_name = "apple_support", - version = "1.15.1", + module_name = "rules_swift", + version = "2.3.0", ) # Some of our deps are forcing a new stardoc on us, so pinning for now @@ -72,12 +72,6 @@ single_version_override( version = "0.6.1", ) -# For Stardoc -single_version_override( - module_name = "bazel_skylib", - version = "1.6.0", -) - apple_cc_configure = use_extension( "@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension", diff --git a/README.md b/README.md index dc578c0b19..6676833aeb 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ to include it in the list above. | rules_xcodeproj | Bazel | [rules_apple][1] | [rules_swift][2] | Xcode | macOS | Supporting Branch | | :-------------: | :---: | :--------------: | :--------------: | :---: | :---: | :---------------: | -| 2.10.0+ | 7.0-8.x | 3.16.1+ | 1.18.0+ | 13.3–15.x | 13–14.x | `main` | +| 2.10.0+ | 7.0-9.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 | - | diff --git a/bazel_6.bazelrc b/bazel_6.bazelrc deleted file mode 100644 index 95dd1cf60b..0000000000 --- a/bazel_6.bazelrc +++ /dev/null @@ -1,12 +0,0 @@ -build:cache --experimental_remote_build_event_upload=minimal - -# Use Bzlmod -build --enable_bzlmod - -# Use apple_support Xcode toolchain -build --apple_crosstool_top=@local_config_apple_cc//:toolchain -build --crosstool_top=@local_config_apple_cc//:toolchain -build --host_crosstool_top=@local_config_apple_cc//:toolchain - -# Work around https://github.com/bazelbuild/bazel/issues/13912 -build --experimental_action_cache_store_output_metadata diff --git a/bazel_7.bazelrc b/bazel_7.bazelrc index 62fb48fec0..5ef382d3da 100644 --- a/bazel_7.bazelrc +++ b/bazel_7.bazelrc @@ -1,3 +1 @@ -common --incompatible_fail_on_unknown_attributes - -build:cache --remote_build_event_upload=minimal +common --incompatible_disallow_empty_glob diff --git a/bazel_9.bazelrc b/bazel_9.bazelrc new file mode 100644 index 0000000000..e69de29bb2 diff --git a/buildbuddy.yaml b/buildbuddy.yaml index 276c3a74bd..e5eec32499 100644 --- a/buildbuddy.yaml +++ b/buildbuddy.yaml @@ -20,12 +20,10 @@ x_templates: USE_BAZEL_VERSION: 7.x - &bazel_lts env: - # FIXME: Adjust to 8.x - USE_BAZEL_VERSION: 7.x + USE_BAZEL_VERSION: 8.x - &bazel_head env: - # FIXME: Adjust to `last_green` - USE_BAZEL_VERSION: 7.x + USE_BAZEL_VERSION: last_green - &normal_resources resource_requests: { memory: 6GB } diff --git a/examples/integration/.bazelrc b/examples/integration/.bazelrc index 45aa71ea1c..20b23d536f 100644 --- a/examples/integration/.bazelrc +++ b/examples/integration/.bazelrc @@ -3,6 +3,9 @@ import %workspace%/../../shared.bazelrc build --experimental_cc_implementation_deps +# Until we fix our examples for Bazel 8 +common --enable_workspace + # Exercise the extra flags feature build:rules_xcodeproj --@rules_xcodeproj//xcodeproj:extra_common_flags='--verbose_failures' diff --git a/examples/integration/iOSApp/Resources/ExampleResources/dep_resources_collector.bzl b/examples/integration/iOSApp/Resources/ExampleResources/dep_resources_collector.bzl index 851733276a..4d6f025a25 100644 --- a/examples/integration/iOSApp/Resources/ExampleResources/dep_resources_collector.bzl +++ b/examples/integration/iOSApp/Resources/ExampleResources/dep_resources_collector.bzl @@ -26,8 +26,6 @@ _deps_aspect = aspect( attr_aspects = ["*"], ) -_is_bazel_6 = hasattr(apple_common, "link_multi_arch_static_library") - def _dep_resources_collector_impl(ctx): all_deps = depset( transitive = [dep[DepCollectorInfo].dep_names for dep in ctx.attr.deps], @@ -39,9 +37,7 @@ def _dep_resources_collector_impl(ctx): command = "echo '{}' > {}".format("\n".join(all_deps), output.path), ) - res = [output] - if _is_bazel_6: - res = {tuple(): res} + res = {tuple(): [output]} return resources.bucketize( resources = res, diff --git a/examples/integration/test/fixtures/bazel-8/bwb_replacements.txt b/examples/integration/test/fixtures/bazel-8/bwb_replacements.txt index 092d848571..b5bfe38e0e 100644 --- a/examples/integration/test/fixtures/bazel-8/bwb_replacements.txt +++ b/examples/integration/test/fixtures/bazel-8/bwb_replacements.txt @@ -1,35 +1,35 @@ CONFIGURATION-STABLE-0 darwin_x86_64-dbg-ST-376989c9bb44 CONFIGURATION-STABLE-1 darwin_x86_64-dbg-ST-65b9ae3229ca CONFIGURATION-STABLE-2 darwin_x86_64-opt-ST-4603bbaf5d98 -CONFIGURATION-STABLE-3 ios_x86_64-dbg-ios-x86_64-min15.0-applebin_ios-ST-ec49b5570e6a -CONFIGURATION-STABLE-4 watchos_x86_64-dbg-watchos-x86_64-min7.0-applebin_watchos-ST-c601ed35d954 -CONFIGURATION-STABLE-5 ios_x86_64-dbg-ios-x86_64-min16.0-applebin_ios-ST-7c661f35007d -CONFIGURATION-STABLE-6 tvos_x86_64-dbg-tvos-x86_64-min15.0-applebin_tvos-ST-8fa93ae60f3c -CONFIGURATION-STABLE-7 darwin_x86_64-dbg-macos-x86_64-min12.0-applebin_macos-ST-e4d1b54e0a5f -CONFIGURATION-STABLE-8 ios_arm64-dbg-ios-arm64-min15.0-applebin_ios-ST-d4ed85805c03 -CONFIGURATION-STABLE-9 watchos_arm64_32-dbg-watchos-arm64_32-min7.0-applebin_watchos-ST-2d1383ea1bfd -CONFIGURATION-STABLE-10 ios_arm64-dbg-ios-arm64-min16.0-applebin_ios-ST-9d40ca217462 -CONFIGURATION-STABLE-11 tvos_arm64-dbg-tvos-arm64-min15.0-applebin_tvos-ST-f0bf1e4db2b5 -CONFIGURATION-STABLE-12 ios_x86_64-opt-ios-x86_64-min15.0-applebin_ios-ST-f0647120a524 -CONFIGURATION-STABLE-13 watchos_x86_64-opt-watchos-x86_64-min7.0-applebin_watchos-ST-9b6da1c1ca96 -CONFIGURATION-STABLE-14 ios_x86_64-opt-ios-x86_64-min16.0-applebin_ios-ST-98784b0141f7 -CONFIGURATION-STABLE-15 tvos_x86_64-opt-tvos-x86_64-min15.0-applebin_tvos-ST-fd3222aa8913 -CONFIGURATION-STABLE-16 darwin_x86_64-opt-macos-x86_64-min12.0-applebin_macos-ST-478bd2e7095f -CONFIGURATION-STABLE-17 ios_arm64-opt-ios-arm64-min15.0-applebin_ios-ST-d4b659e4a9d4 -CONFIGURATION-STABLE-18 watchos_arm64_32-opt-watchos-arm64_32-min7.0-applebin_watchos-ST-ecd9d94fb4e5 -CONFIGURATION-STABLE-19 ios_arm64-opt-ios-arm64-min16.0-applebin_ios-ST-9a1b0839beb3 -CONFIGURATION-STABLE-20 tvos_arm64-opt-tvos-arm64-min15.0-applebin_tvos-ST-618e0eabc398 -CONFIGURATION-STABLE-21 watchos_x86_64-dbg-watchos-x86_64-min8.0-applebin_watchos-ST-65044d9cb033 -CONFIGURATION-STABLE-22 watchos_arm64_32-dbg-watchos-arm64_32-min8.0-applebin_watchos-ST-e2adfc6423ec -CONFIGURATION-STABLE-23 watchos_x86_64-opt-watchos-x86_64-min8.0-applebin_watchos-ST-b7000f81fbba -CONFIGURATION-STABLE-24 watchos_arm64_32-opt-watchos-arm64_32-min8.0-applebin_watchos-ST-58e24dd35eea -CONFIGURATION-STABLE-25 darwin_x86_64-dbg-macos-x86_64-min11.0-applebin_macos-ST-23ced71d870c -CONFIGURATION-STABLE-26 darwin_x86_64-opt-macos-x86_64-min11.0-applebin_macos-ST-5c2767082c6b -CONFIGURATION-STABLE-27 darwin_x86_64-dbg-macos-x86_64-min11.0-applebin_macos-ST-7c4786726810 -CONFIGURATION-STABLE-28 darwin_arm64-dbg-macos-arm64-min11.0-applebin_macos-ST-5f46583411cc -CONFIGURATION-STABLE-29 darwin_x86_64-dbg-macos-x86_64-min11.0-applebin_macos-ST-a6b23e99dd1c -CONFIGURATION-STABLE-30 darwin_x86_64-opt-macos-x86_64-min11.0-applebin_macos-ST-d247baf1a2e1 -CONFIGURATION-STABLE-31 darwin_arm64-opt-macos-arm64-min11.0-applebin_macos-ST-4320432566be -CONFIGURATION-STABLE-32 darwin_x86_64-opt-macos-x86_64-min11.0-applebin_macos-ST-11b4a0ee8e7b +CONFIGURATION-STABLE-3 ios_x86_64-dbg-ios-x86_64-min15.0-applebin_ios-ST-729671d856ea +CONFIGURATION-STABLE-4 watchos_x86_64-dbg-watchos-x86_64-min7.0-applebin_watchos-ST-a56208b3ea17 +CONFIGURATION-STABLE-5 ios_x86_64-dbg-ios-x86_64-min16.0-applebin_ios-ST-e07395093609 +CONFIGURATION-STABLE-6 tvos_x86_64-dbg-tvos-x86_64-min15.0-applebin_tvos-ST-f2eafbbb2c71 +CONFIGURATION-STABLE-7 darwin_x86_64-dbg-macos-x86_64-min12.0-applebin_macos-ST-c5aba9a2664d +CONFIGURATION-STABLE-8 ios_arm64-dbg-ios-arm64-min15.0-applebin_ios-ST-ebc965843194 +CONFIGURATION-STABLE-9 watchos_arm64_32-dbg-watchos-arm64_32-min7.0-applebin_watchos-ST-ee37b6f7c2f8 +CONFIGURATION-STABLE-10 ios_arm64-dbg-ios-arm64-min16.0-applebin_ios-ST-22e6ffafd033 +CONFIGURATION-STABLE-11 tvos_arm64-dbg-tvos-arm64-min15.0-applebin_tvos-ST-34aed803ff64 +CONFIGURATION-STABLE-12 ios_x86_64-opt-ios-x86_64-min15.0-applebin_ios-ST-7e26020362db +CONFIGURATION-STABLE-13 watchos_x86_64-opt-watchos-x86_64-min7.0-applebin_watchos-ST-0b3052a22d34 +CONFIGURATION-STABLE-14 ios_x86_64-opt-ios-x86_64-min16.0-applebin_ios-ST-24288e6a8a11 +CONFIGURATION-STABLE-15 tvos_x86_64-opt-tvos-x86_64-min15.0-applebin_tvos-ST-839820e646a4 +CONFIGURATION-STABLE-16 darwin_x86_64-opt-macos-x86_64-min12.0-applebin_macos-ST-fdfd02bb595a +CONFIGURATION-STABLE-17 ios_arm64-opt-ios-arm64-min15.0-applebin_ios-ST-a175c2921f59 +CONFIGURATION-STABLE-18 watchos_arm64_32-opt-watchos-arm64_32-min7.0-applebin_watchos-ST-52c88b620570 +CONFIGURATION-STABLE-19 ios_arm64-opt-ios-arm64-min16.0-applebin_ios-ST-d9e7edaa2e03 +CONFIGURATION-STABLE-20 tvos_arm64-opt-tvos-arm64-min15.0-applebin_tvos-ST-09f0630d9e9d +CONFIGURATION-STABLE-21 watchos_x86_64-dbg-watchos-x86_64-min8.0-applebin_watchos-ST-c0f93201a38e +CONFIGURATION-STABLE-22 watchos_arm64_32-dbg-watchos-arm64_32-min8.0-applebin_watchos-ST-5383078a5ee1 +CONFIGURATION-STABLE-23 watchos_x86_64-opt-watchos-x86_64-min8.0-applebin_watchos-ST-040af2a54015 +CONFIGURATION-STABLE-24 watchos_arm64_32-opt-watchos-arm64_32-min8.0-applebin_watchos-ST-023f6c62a458 +CONFIGURATION-STABLE-25 darwin_x86_64-dbg-macos-x86_64-min11.0-applebin_macos-ST-ab644b0d3414 +CONFIGURATION-STABLE-26 darwin_x86_64-opt-macos-x86_64-min11.0-applebin_macos-ST-03342bc805f6 +CONFIGURATION-STABLE-27 darwin_x86_64-dbg-macos-x86_64-min11.0-applebin_macos-ST-66f6a67d07be +CONFIGURATION-STABLE-28 darwin_arm64-dbg-macos-arm64-min11.0-applebin_macos-ST-857af5314a24 +CONFIGURATION-STABLE-29 darwin_x86_64-dbg-macos-x86_64-min11.0-applebin_macos-ST-ca73ce429e0a +CONFIGURATION-STABLE-30 darwin_x86_64-opt-macos-x86_64-min11.0-applebin_macos-ST-34857d59845d +CONFIGURATION-STABLE-31 darwin_arm64-opt-macos-arm64-min11.0-applebin_macos-ST-4e8ee0b7762f +CONFIGURATION-STABLE-32 darwin_x86_64-opt-macos-x86_64-min11.0-applebin_macos-ST-db9afb28d4b1 CONFIGURATION-STABLE-33 darwin_x86_64-dbg-ST-3a99c2752788 CONFIGURATION-STABLE-34 darwin_x86_64-opt-ST-a99a48f137fe diff --git a/examples/sanitizers/.bazelrc b/examples/sanitizers/.bazelrc index 7d4dd75134..0f99e57b8e 100644 --- a/examples/sanitizers/.bazelrc +++ b/examples/sanitizers/.bazelrc @@ -1,6 +1,9 @@ # Import parent workspace settings import %workspace%/../../shared.bazelrc +# Until bzlmod is supported in this example +common --enable_workspace + # This example doesn't support bzlmod yet build --noexperimental_enable_bzlmod diff --git a/shared.bazelrc b/shared.bazelrc index 485ccc90a2..1ca4927831 100644 --- a/shared.bazelrc +++ b/shared.bazelrc @@ -1,9 +1,3 @@ -# Opt into future migrations -build --incompatible_disallow_empty_glob - -# Support rules_swift 2.0 on Bazel 6 -common --experimental_enable_aspect_hints - # Don't create convenience symlinks build --experimental_convenience_symlinks=ignore @@ -27,8 +21,6 @@ startup --output_base=bazel-output-base build --deleted_packages=test/fixtures/generated/xcodeproj_bwx,test/fixtures/generated/xcodeproj_bwb # Ensure we work with BwtB -build --experimental_inmemory_jdeps_files -build --experimental_inmemory_dotd_files build --remote_download_outputs=minimal test --remote_download_outputs=toplevel diff --git a/tools/bazel b/tools/bazel index 374fdcdfdb..18c095038a 100755 --- a/tools/bazel +++ b/tools/bazel @@ -17,7 +17,7 @@ readonly workspace_dir="${tool_location%/*/*}" bazel_version=$("$BAZEL_REAL" info release | /usr/bin/cut -d ' ' -f 2 | /usr/bin/cut -d '.' -f 1) if [[ "$bazel_version" == "version" ]]; then - bazel_version=8 + bazel_version=9 fi flags=("--noworkspace_rc") diff --git a/xcodeproj/internal/opts.bzl b/xcodeproj/internal/opts.bzl index bebd90d36b..744aaddeda 100644 --- a/xcodeproj/internal/opts.bzl +++ b/xcodeproj/internal/opts.bzl @@ -64,7 +64,8 @@ def _legacy_get_unprocessed_cc_compiler_opts( if is_objc: objc = ctx.fragments.objc user_copts = ( - objc.copts + + # TODO: Remove when we drop 7.x + getattr(objc, "copts", []) + user_copts + objc.copts_for_current_compilation_mode ) diff --git a/xcodeproj/internal/pbxproj_partials.bzl b/xcodeproj/internal/pbxproj_partials.bzl index 1bb32fa7ba..b57f3e3c1c 100644 --- a/xcodeproj/internal/pbxproj_partials.bzl +++ b/xcodeproj/internal/pbxproj_partials.bzl @@ -10,15 +10,12 @@ load( "FALSE_ARG", "TRUE_ARG", ) -load(":platforms.bzl", "PLATFORM_NAME") +load(":platforms.bzl", "platforms") _UNIT_TEST_PRODUCT_TYPE = "u" # com.apple.product-type.bundle.unit-test # Utility -def _apple_platform_to_platform_name(platform): - return PLATFORM_NAME[platform] - def _dsym_files_to_string(dsym_files): dsym_paths = [] for file in dsym_files.to_list(): @@ -135,7 +132,9 @@ _FLAGS = struct( def _write_consolidation_map_targets( *, actions, - apple_platform_to_platform_name = _apple_platform_to_platform_name, + apple_platform_to_platform_name = ( + platforms.apple_platform_to_platform_name + ), colorize, consolidation_map, default_xcode_configuration, @@ -654,7 +653,9 @@ def _write_generated_xcfilelist( def _write_pbxproj_prefix( *, actions, - apple_platform_to_platform_name = _apple_platform_to_platform_name, + apple_platform_to_platform_name = ( + platforms.apple_platform_to_platform_name + ), colorize, config, default_xcode_configuration, @@ -814,7 +815,9 @@ def _write_pbxproj_prefix( def _write_pbxtargetdependencies( *, actions, - apple_platform_to_platform_name = _apple_platform_to_platform_name, + apple_platform_to_platform_name = ( + platforms.apple_platform_to_platform_name + ), colorize, generator_name, install_path, diff --git a/xcodeproj/internal/platforms.bzl b/xcodeproj/internal/platforms.bzl index d9aa298fd7..9e173823ab 100644 --- a/xcodeproj/internal/platforms.bzl +++ b/xcodeproj/internal/platforms.bzl @@ -1,65 +1,82 @@ """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", -} +# TODO: Remove this once we drop 7.x +def _legacy_apple_platform_starlark_name(platform): + return platform + +def _modern_apple_platform_starlark_name(platform): + return platform.name + +_apple_platform_starlark_name = _modern_apple_platform_starlark_name if hasattr(apple_common.platform.ios_device, "name") else _legacy_apple_platform_starlark_name _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_platform_starlark_name(apple_common.platform.ios_device): False, + _apple_platform_starlark_name(apple_common.platform.ios_simulator): True, + _apple_platform_starlark_name(apple_common.platform.macos): False, + _apple_platform_starlark_name(apple_common.platform.tvos_device): False, + _apple_platform_starlark_name(apple_common.platform.tvos_simulator): True, + _apple_platform_starlark_name(apple_common.platform.visionos_device): False, + _apple_platform_starlark_name(apple_common.platform.visionos_simulator): True, + _apple_platform_starlark_name(apple_common.platform.watchos_device): False, + _apple_platform_starlark_name(apple_common.platform.watchos_simulator): 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_platform_starlark_name(apple_common.platform.ios_device): "ios", + _apple_platform_starlark_name(apple_common.platform.ios_simulator): "ios", + _apple_platform_starlark_name(apple_common.platform.macos): "macosx", + _apple_platform_starlark_name(apple_common.platform.tvos_device): "tvos", + _apple_platform_starlark_name(apple_common.platform.tvos_simulator): "tvos", + _apple_platform_starlark_name(apple_common.platform.visionos_device): "xros", + _apple_platform_starlark_name(apple_common.platform.visionos_simulator): "xros", + _apple_platform_starlark_name(apple_common.platform.watchos_device): "watchos", + _apple_platform_starlark_name(apple_common.platform.watchos_simulator): "watchos", +} + +_PLATFORM_NAME = { + _apple_platform_starlark_name(apple_common.platform.ios_device): "iphoneos", + _apple_platform_starlark_name(apple_common.platform.ios_simulator): "iphonesimulator", + _apple_platform_starlark_name(apple_common.platform.macos): "macosx", + _apple_platform_starlark_name(apple_common.platform.tvos_device): "appletvos", + _apple_platform_starlark_name(apple_common.platform.tvos_simulator): "appletvsimulator", + _apple_platform_starlark_name(apple_common.platform.visionos_device): "xros", + _apple_platform_starlark_name(apple_common.platform.visionos_simulator): "xrsimulator", + _apple_platform_starlark_name(apple_common.platform.watchos_device): "watchos", + _apple_platform_starlark_name(apple_common.platform.watchos_simulator): "watchsimulator", } _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_platform_starlark_name(apple_common.platform.ios_device): "ios", + _apple_platform_starlark_name(apple_common.platform.ios_simulator): "ios", + _apple_platform_starlark_name(apple_common.platform.macos): "macos", + _apple_platform_starlark_name(apple_common.platform.tvos_device): "tvos", + _apple_platform_starlark_name(apple_common.platform.tvos_simulator): "tvos", + _apple_platform_starlark_name(apple_common.platform.visionos_device): "xros", + _apple_platform_starlark_name(apple_common.platform.visionos_simulator): "xros", + _apple_platform_starlark_name(apple_common.platform.watchos_device): "watchos", + _apple_platform_starlark_name(apple_common.platform.watchos_simulator): "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_platform_starlark_name(apple_common.platform.ios_device): "", + _apple_platform_starlark_name(apple_common.platform.ios_simulator): "-simulator", + _apple_platform_starlark_name(apple_common.platform.macos): "", + _apple_platform_starlark_name(apple_common.platform.tvos_device): "", + _apple_platform_starlark_name(apple_common.platform.tvos_simulator): "-simulator", + _apple_platform_starlark_name(apple_common.platform.visionos_device): "", + _apple_platform_starlark_name(apple_common.platform.visionos_simulator): "-simulator", + _apple_platform_starlark_name(apple_common.platform.watchos_device): "", + _apple_platform_starlark_name(apple_common.platform.watchos_simulator): "-simulator", } +def _apple_platform_to_platform_name(apple_platform): + """Returns the name of a platform. + + Args: + apple_platform: A value from `apple_common.platform`. + """ + return _PLATFORM_NAME[_apple_platform_starlark_name(apple_platform)] + def _collect_platform(*, ctx): """Collects information about a target's platform. @@ -112,7 +129,7 @@ def _platform_to_dto(platform): dto = { "a": platform.arch, "m": platform.os_version, - "v": PLATFORM_NAME[platform.apple_platform], + "v": _apple_platform_to_platform_name(platform.apple_platform), } return dto @@ -123,7 +140,8 @@ def _platform_to_swift_triple(platform): Args: platform: A value from `platforms.collect`. """ - apple_platform = platform.apple_platform + apple_platform = _apple_platform_starlark_name(platform.apple_platform) + return "{arch}-apple-{triple_prefix}{triple_suffix}".format( arch = platform.arch, triple_prefix = _SWIFT_TRIPLE_PREFIX[apple_platform], @@ -136,7 +154,8 @@ def _platform_to_lldb_context_triple(platform): Args: platform: A value from `platforms.collect`. """ - apple_platform = platform.apple_platform + apple_platform = _apple_platform_starlark_name(platform.apple_platform) + return "{arch}-apple-{triple_prefix}{triple_suffix}".format( arch = platform.arch, triple_prefix = _LLDB_TRIPLE_PREFIX[apple_platform], @@ -144,6 +163,7 @@ def _platform_to_lldb_context_triple(platform): ) platforms = struct( + apple_platform_to_platform_name = _apple_platform_to_platform_name, collect = _collect_platform, is_not_macos = _is_not_macos, is_platform_type = _is_platform_type, diff --git a/xcodeproj/internal/product.bzl b/xcodeproj/internal/product.bzl index 32d2b57f37..4652ca9fda 100644 --- a/xcodeproj/internal/product.bzl +++ b/xcodeproj/internal/product.bzl @@ -5,6 +5,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load( "@build_bazel_rules_apple//apple:providers.bzl", "AppleDynamicFrameworkInfo", + "AppleExecutableBinaryInfo", ) load("//xcodeproj/internal/files:linker_input_files.bzl", "linker_input_files") load(":memory_efficiency.bzl", "EMPTY_DEPSET") @@ -47,6 +48,13 @@ _ARCHIVE_EXTENSIONS = { "zip": None, } +# TODO: Remove when we drop 7.x +_AppleExecutableBinaryInfo = getattr( + apple_common, + "AppleExecutableBinary", + AppleExecutableBinaryInfo, +) + # TODO: Remove when we drop 7.x _AppleDynamicFrameworkInfo = getattr( apple_common, @@ -253,8 +261,8 @@ def process_product( 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