From 6a6722b104febe588cccf9a79b1cfaa0a3d0ac2c Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 18 Dec 2023 10:52:08 -0800 Subject: [PATCH] Add watchos_device_arm64(e) CPUs --- configs/platforms.bzl | 14 ++++++++++++++ crosstool/cc_toolchain_config.bzl | 8 ++++++++ platform_mappings | 15 +++++++++++++++ test/binary_tests.bzl | 20 ++++++++++++++++++++ test/shell/verify_binary.sh | 1 + 5 files changed, 58 insertions(+) diff --git a/configs/platforms.bzl b/configs/platforms.bzl index c020d5f..72b4d53 100644 --- a/configs/platforms.bzl +++ b/configs/platforms.bzl @@ -79,6 +79,18 @@ APPLE_PLATFORMS_CONSTRAINTS = { "@build_bazel_apple_support//constraints:apple", "@build_bazel_apple_support//constraints:simulator", ], + "watchos_device_arm64": [ + "@platforms//os:watchos", + "@platforms//cpu:arm64", + "@build_bazel_apple_support//constraints:apple", + "@build_bazel_apple_support//constraints:device", + ], + "watchos_device_arm64e": [ + "@platforms//os:watchos", + "@platforms//cpu:arm64e", + "@build_bazel_apple_support//constraints:apple", + "@build_bazel_apple_support//constraints:device", + ], "watchos_arm64_32": [ "@platforms//os:watchos", "@platforms//cpu:arm64_32", @@ -115,5 +127,7 @@ CPU_TO_DEFAULT_PLATFORM_NAME = { "watchos_arm64": "watchos_arm64", "watchos_arm64_32": "watchos_arm64_32", "watchos_armv7k": "watchos_armv7k", + "watchos_device_arm64": "watchos_device_arm64", + "watchos_device_arm64e": "watchos_device_arm64e", "watchos_x86_64": "watchos_x86_64", } diff --git a/crosstool/cc_toolchain_config.bzl b/crosstool/cc_toolchain_config.bzl index 330185a..b9756ea 100644 --- a/crosstool/cc_toolchain_config.bzl +++ b/crosstool/cc_toolchain_config.bzl @@ -135,6 +135,10 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new elif (ctx.attr.cpu == "watchos_arm64"): target_system_name = "arm64-apple-watchos{}-simulator".format(target_os_version) is_simulator = True + elif (ctx.attr.cpu == "watchos_device_arm64"): + target_system_name = "arm64-apple-watchos{}".format(target_os_version) + elif (ctx.attr.cpu == "watchos_device_arm64e"): + target_system_name = "arm64e-apple-watchos{}".format(target_os_version) elif (ctx.attr.cpu == "darwin_x86_64"): target_system_name = "x86_64-apple-macosx{}".format(target_os_version) elif (ctx.attr.cpu == "darwin_arm64"): @@ -740,6 +744,8 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ctx.attr.cpu == "ios_sim_arm64" or ctx.attr.cpu == "ios_x86_64" or ctx.attr.cpu == "watchos_arm64_32" or + ctx.attr.cpu == "watchos_device_arm64" or + ctx.attr.cpu == "watchos_device_arm64e" or ctx.attr.cpu == "watchos_armv7k" or ctx.attr.cpu == "watchos_x86_64" or ctx.attr.cpu == "watchos_arm64"): @@ -1482,6 +1488,8 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ctx.attr.cpu == "visionos_arm64" or ctx.attr.cpu == "visionos_sim_arm64" or ctx.attr.cpu == "watchos_arm64_32" or + ctx.attr.cpu == "watchos_device_arm64" or + ctx.attr.cpu == "watchos_device_arm64e" or ctx.attr.cpu == "watchos_armv7k" or ctx.attr.cpu == "watchos_x86_64" or ctx.attr.cpu == "watchos_arm64"): diff --git a/platform_mappings b/platform_mappings index a8a9fd9..04de431 100644 --- a/platform_mappings +++ b/platform_mappings @@ -67,6 +67,13 @@ platforms: --apple_platform_type=watchos --cpu=watchos_arm64_32 + //platforms:watchos_device_arm64 + --apple_platform_type=watchos + --cpu=watchos_device_arm64 + + //platforms:watchos_device_arm64e + --apple_platform_type=watchos + --cpu=watchos_device_arm64e flags: --cpu=darwin_x86_64 --apple_platform_type=macos @@ -135,3 +142,11 @@ flags: --cpu=watchos_arm64_32 --apple_platform_type=watchos //platforms:watchos_arm64_32 + + --cpu=watchos_device_arm64 + --apple_platform_type=watchos + //platforms:watchos_device_arm64 + + --cpu=watchos_device_arm64e + --apple_platform_type=watchos + //platforms:watchos_device_arm64e diff --git a/test/binary_tests.bzl b/test/binary_tests.bzl index ba5618a..db5d9b5 100644 --- a/test/binary_tests.bzl +++ b/test/binary_tests.bzl @@ -114,6 +114,26 @@ def binary_test_suite(name): target_under_test = "//test/test_data:watch_binary", ) + apple_verification_test( + name = "{}_watchos_device_arm64_test".format(name), + tags = [name], + build_type = "device", + cpus = {"watchos_cpus": "device_arm64"}, + expected_platform_type = "watchos", + verifier_script = "//test/shell:verify_binary.sh", + target_under_test = "//test/test_data:watch_binary", + ) + + apple_verification_test( + name = "{}_watchos_device_arm64e_test".format(name), + tags = [name], + build_type = "device", + cpus = {"watchos_cpus": "device_arm64e"}, + expected_platform_type = "watchos", + verifier_script = "//test/shell:verify_binary.sh", + target_under_test = "//test/test_data:watch_binary", + ) + apple_verification_test( name = "{}_watchos_simulator_test".format(name), tags = [name], diff --git a/test/shell/verify_binary.sh b/test/shell/verify_binary.sh index f73943a..c2dcd5f 100755 --- a/test/shell/verify_binary.sh +++ b/test/shell/verify_binary.sh @@ -28,6 +28,7 @@ fi lipo_output=$(lipo -info "$binary") expected_cpus=${CPU//,/ } expected_cpus=${expected_cpus//sim_/} +expected_cpus=${expected_cpus//device_/} if ! echo "$lipo_output" | grep -q "$expected_cpus"; then echo "error: binary $binary does not contain CPU $CPU, got: '$lipo_output" exit 1