Skip to content

Commit 55f6ece

Browse files
authored
Infer tvOS/watchOS archs from the CPU parameters, similarly to iOS (#2707)
iOS currently has some special logic in `transition_support.bzl` that defaults the architecture to the value of `//command_line_option:cpu` if the value is iOS related (or a arm64 mac), but the same was not being done for other platforms. This was causing some confusion on our team as although on one end the regular iOS builds were being automatically resolved to arm64 simulator builds, on the other end everything else was resolving to x86_64 despite no changes in the environment. This PR adds this same special logic to tvOS/watchOS for make them consistent with iOS. So in my case, building tvOS from a arm64 mac would now result in a tvOS arm64 simulator build. It's unclear to me if the iOS case was done just to support some legacy use-case (meaning we should probably not do this for the other platforms), so if that's the case, let me know how to best solve this!
1 parent 46d6c2a commit 55f6ece

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

apple/internal/transition_support.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,23 @@ def _cpu_string(*, environment_arch, platform_type, settings = {}):
245245
tvos_cpus = settings["//command_line_option:tvos_cpus"]
246246
if tvos_cpus:
247247
return "tvos_{}".format(tvos_cpus[0])
248+
cpu_value = settings["//command_line_option:cpu"]
249+
if cpu_value.startswith("tvos_"):
250+
return cpu_value
251+
if cpu_value == "darwin_arm64":
252+
return "tvos_sim_arm64"
248253
return "tvos_x86_64"
249254
if platform_type == "watchos":
250255
if environment_arch:
251256
return "watchos_{}".format(environment_arch)
252257
watchos_cpus = settings["//command_line_option:watchos_cpus"]
253258
if watchos_cpus:
254259
return "watchos_{}".format(watchos_cpus[0])
260+
cpu_value = settings["//command_line_option:cpu"]
261+
if cpu_value.startswith("watchos_"):
262+
return cpu_value
263+
if cpu_value == "darwin_arm64":
264+
return "watchos_arm64"
255265
return "watchos_x86_64"
256266

257267
fail("ERROR: Unknown platform type: {}".format(platform_type))

0 commit comments

Comments
 (0)