Skip to content

Commit

Permalink
Add watchos_device_arm64(e) CPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
keith committed Feb 16, 2024
1 parent b791ee3 commit 6a6722b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
14 changes: 14 additions & 0 deletions configs/platforms.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
}
8 changes: 8 additions & 0 deletions crosstool/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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"):
Expand Down Expand Up @@ -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"):
Expand Down
15 changes: 15 additions & 0 deletions platform_mappings
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
20 changes: 20 additions & 0 deletions test/binary_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
1 change: 1 addition & 0 deletions test/shell/verify_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a6722b

Please sign in to comment.