Skip to content

Commit 29e33b0

Browse files
iinozemtsevCommit Queue
authored and
Commit Queue
committed
Reland "watchOS target os"
This is a reland of commit 7ae1d75 TEST=manual, no watchOS SDK on bots yet. Original change's description: > watchOS target os > > - add support for --os=watchos | --os=watchos_simulator > - do not depend on perfetto if dart_support_perfetto is false > - change the default value for dart_support_perfetto to !is_watchos > > To minimize changes and to avoid modifying third-party zlib BUILD file, is_watchos implies is_ios for now. > > TEST=manual, no watchOS SDK on bots yet. > > Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-mac-release-arm64-try > Change-Id: If2130068ef546162a07a9ba53f94b11ff25fb565 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415021 > Reviewed-by: Ryan Macnak <[email protected]> > Commit-Queue: Ivan Inozemtsev <[email protected]> Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-mac-release-arm64-try Change-Id: I2b50f7eb4da173627aeb4833b88a08712b278d9f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425523 Commit-Queue: Ivan Inozemtsev <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
1 parent 9188999 commit 29e33b0

File tree

13 files changed

+203
-44
lines changed

13 files changed

+203
-44
lines changed

build/config/BUILDCONFIG.gn

+34-9
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ if (current_os == "win") {
177177
is_mac = false
178178
is_nacl = false
179179
is_posix = false
180+
is_watchos = false
180181
is_win = true
181182
} else if (current_os == "mac") {
182183
is_android = false
@@ -187,6 +188,7 @@ if (current_os == "win") {
187188
is_mac = true
188189
is_nacl = false
189190
is_posix = true
191+
is_watchos = false
190192
is_win = false
191193
} else if (current_os == "android") {
192194
is_android = true
@@ -197,6 +199,7 @@ if (current_os == "win") {
197199
is_mac = false
198200
is_nacl = false
199201
is_posix = true
202+
is_watchos = false
200203
is_win = false
201204
} else if (current_os == "linux") {
202205
is_android = false
@@ -207,6 +210,7 @@ if (current_os == "win") {
207210
is_mac = false
208211
is_nacl = false
209212
is_posix = true
213+
is_watchos = false
210214
is_win = false
211215
} else if (current_os == "fuchsia") {
212216
is_android = false
@@ -217,6 +221,7 @@ if (current_os == "win") {
217221
is_mac = false
218222
is_nacl = false
219223
is_posix = true
224+
is_watchos = false
220225
is_win = false
221226
} else if (current_os == "ios") {
222227
is_android = false
@@ -227,6 +232,23 @@ if (current_os == "win") {
227232
is_mac = false
228233
is_nacl = false
229234
is_posix = true
235+
is_watchos = false
236+
is_win = false
237+
} else if (current_os == "watchos") {
238+
is_android = false
239+
is_chromeos = false
240+
is_fuchsia = false
241+
242+
# watchOS and iOS are similar enough, so almost all codepaths in
243+
# BUILD files are the same for watchOS and iOS. Additionally,
244+
# BUILD.gn zlib file doesn't support `is_watchos`, but works fine
245+
# with `is_ios`.
246+
is_ios = true
247+
is_linux = false
248+
is_mac = false
249+
is_nacl = false
250+
is_posix = true
251+
is_watchos = true
230252
is_win = false
231253
}
232254

@@ -445,17 +467,19 @@ if (is_win) {
445467
host_toolchain = "//build/toolchain/mac:clang_$host_cpu"
446468
set_default_toolchain("//build/toolchain/mac:clang_$current_cpu")
447469
} else if (is_ios) {
448-
import("//build/config/ios/ios_sdk.gni") # For use_ios_simulator
470+
import("//build/config/ios/ios_sdk.gni") # For use_simulator
449471
host_toolchain = "//build/toolchain/mac:clang_$host_cpu"
450-
if (use_ios_simulator) {
451-
if (target_cpu == "arm64") {
452-
set_default_toolchain("//build/toolchain/mac:ios_clang_arm64_sim")
453-
} else {
454-
set_default_toolchain("//build/toolchain/mac:ios_clang_x64_sim")
455-
}
472+
toolchain_target = "clang"
473+
if (is_watchos) {
474+
toolchain_target = "watchos_$toolchain_target"
456475
} else {
457-
set_default_toolchain("//build/toolchain/mac:ios_clang_arm64")
476+
toolchain_target = "ios_$toolchain_target"
477+
}
478+
toolchain_target = "${toolchain_target}_$target_cpu"
479+
if (use_simulator) {
480+
toolchain_target = "${toolchain_target}_sim"
458481
}
482+
set_default_toolchain("//build/toolchain/mac:$toolchain_target")
459483
} else if (is_fuchsia) {
460484
assert(host_cpu == "x64")
461485
if (host_os == "linux") {
@@ -554,7 +578,8 @@ if (!is_shared_library) {
554578

555579
output_prefix = "lib"
556580
if (!defined(output_extension)) {
557-
if (current_os == "mac" || current_os == "ios") {
581+
if (current_os == "mac" || current_os == "ios" ||
582+
current_os == "watchos") {
558583
output_extension = "dylib"
559584
} else if (current_os == "win") {
560585
output_extension = "dll"

build/config/ios/ios_sdk.gni

+51-19
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,41 @@ import("//build/toolchain/rbe.gni")
66

77
declare_args() {
88
# SDK path to use. When empty this will use the default SDK based on the
9-
# value of use_ios_simulator.
9+
# value of use_simulator.
1010
ios_sdk_path = ""
1111

1212
# Set to true when targeting a simulator build on iOS. False means that the
1313
# target is for running on the device. The default value is to use the
1414
# Simulator except when targeting GYP's Xcode builds (for compat with the
1515
# existing GYP build).
16-
use_ios_simulator = false
16+
use_simulator = false
1717

1818
# Minimum supported version of the iOS SDK.
1919
ios_sdk_min = "12.0"
2020

21+
# Minimum supported version of the watchOS SDK.
22+
watchos_sdk_min = "11.0"
23+
2124
# The path to the iOS device SDK.
2225
ios_device_sdk_path = ""
2326

2427
# The path to the iOS simulator SDK.
2528
ios_simulator_sdk_path = ""
2629

30+
# The path to the watchOS device SDK.
31+
watchos_device_sdk_path = ""
32+
33+
# The path to the watchOS simulator SDK.
34+
watchos_simulator_sdk_path = ""
35+
2736
ios_enable_relative_sdk_path = use_rbe
2837
}
2938

3039
if (ios_sdk_path == "") {
40+
if (is_watchos) {
41+
ios_sdk_min = watchos_sdk_min
42+
}
43+
3144
_find_sdk_args = [
3245
"--print_sdk_path",
3346
ios_sdk_min,
@@ -42,25 +55,44 @@ if (ios_sdk_path == "") {
4255
]
4356
}
4457

45-
if (use_ios_simulator && ios_simulator_sdk_path == "") {
46-
_find_sdk_args += [ "--platform=iphone_simulator" ]
47-
_find_sdk_result =
48-
exec_script("//build/mac/find_sdk.py", _find_sdk_args, "list lines")
49-
ios_simulator_sdk_path = _find_sdk_result[0]
58+
platform = "iphone"
59+
if (is_watchos) {
60+
platform = "watch"
5061
}
51-
52-
if (!use_ios_simulator && ios_device_sdk_path == "") {
53-
_find_sdk_args += [ "--platform=iphone" ]
54-
_find_sdk_result =
55-
exec_script("//build/mac/find_sdk.py", _find_sdk_args, "list lines")
56-
ios_device_sdk_path = _find_sdk_result[0]
62+
if (use_simulator) {
63+
platform = "${platform}_simulator"
5764
}
5865

59-
if (use_ios_simulator) {
60-
assert(ios_simulator_sdk_path != "")
61-
ios_sdk_path = ios_simulator_sdk_path
62-
} else {
63-
assert(ios_device_sdk_path != "")
64-
ios_sdk_path = ios_device_sdk_path
66+
_find_sdk_args += [ "--platform=$platform" ]
67+
_find_sdk_result =
68+
exec_script("//build/mac/find_sdk.py", _find_sdk_args, "list lines")
69+
platform_sdk_path = _find_sdk_result[0]
70+
71+
if (use_simulator && is_watchos) {
72+
# watchos_simulator
73+
if (watchos_simulator_sdk_path != "") {
74+
platform_sdk_path = watchos_simulator_sdk_path
75+
}
76+
ios_sdk_path = platform_sdk_path
77+
ios_sdk_min = watchos_sdk_min
78+
} else if (!use_simulator && is_watchos) {
79+
# watchos
80+
if (watchos_device_sdk_path != "") {
81+
platform_sdk_path = watchos_device_sdk_path
82+
}
83+
ios_sdk_path = platform_sdk_path
84+
ios_sdk_min = watchos_sdk_min
85+
} else if (use_simulator && !is_watchos) {
86+
# ios_simulator
87+
if (ios_simulator_sdk_path != "") {
88+
platform_sdk_path = ios_simulator_sdk_path
89+
}
90+
ios_sdk_path = platform_sdk_path
91+
} else if (!use_simulator && !is_watchos) {
92+
# ios
93+
if (ios_device_sdk_path != "") {
94+
platform_sdk_path = ios_device_sdk_path
95+
}
96+
ios_sdk_path = platform_sdk_path
6597
}
6698
}

build/toolchain/mac/BUILD.gn

+49
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,55 @@ mac_toolchain_suite("ios_clang_x64_sim") {
7878
"-isysroot $ios_sdk_path -mios-simulator-version-min=$ios_sdk_min"
7979
}
8080

81+
if (is_watchos) {
82+
# Toolchain used for watchOS device targets.
83+
mac_toolchain_suite("watchos_clang_arm64") {
84+
toolchain_cpu = "arm64"
85+
toolchain_os = "watchos"
86+
prefix = rebased_clang_dir
87+
cc = "${compiler_prefix}${prefix}/clang"
88+
cxx = "${compiler_prefix}${prefix}/clang++"
89+
if (use_rbe) {
90+
cc = "${cc} --target=arm64-apple-darwin"
91+
cxx = "${cxx} --target=arm64-apple-darwin"
92+
}
93+
asm = "${assembler_prefix}${prefix}/clang"
94+
ar = "${prefix}/llvm-ar"
95+
ld = "${link_prefix}${prefix}/clang++"
96+
strip = "${prefix}/llvm-strip"
97+
nm = "${prefix}/llvm-nm"
98+
is_clang = true
99+
if (ios_enable_relative_sdk_path) {
100+
ios_sdk_path = rebase_path(ios_sdk_path, root_build_dir)
101+
}
102+
sysroot_flags = "-isysroot $ios_sdk_path -mwatchos-version-min=$ios_sdk_min"
103+
}
104+
105+
# Toolchain used for watchOS simulator targets (arm64).
106+
mac_toolchain_suite("watchos_clang_arm64_sim") {
107+
toolchain_cpu = "arm64"
108+
toolchain_os = "watchos"
109+
prefix = rebased_clang_dir
110+
cc = "${compiler_prefix}${prefix}/clang"
111+
cxx = "${compiler_prefix}${prefix}/clang++"
112+
if (use_rbe) {
113+
cc = "${cc} --target=arm64-apple-darwin"
114+
cxx = "${cxx} --target=arm64-apple-darwin"
115+
}
116+
asm = "${assembler_prefix}${prefix}/clang"
117+
ar = "${prefix}/llvm-ar"
118+
ld = "${link_prefix}${prefix}/clang++"
119+
strip = "${prefix}/llvm-strip"
120+
nm = "${prefix}/llvm-nm"
121+
is_clang = true
122+
if (ios_enable_relative_sdk_path) {
123+
ios_sdk_path = rebase_path(ios_sdk_path, root_build_dir)
124+
}
125+
sysroot_flags =
126+
"-isysroot $ios_sdk_path -mwatchos-simulator-version-min=$ios_sdk_min"
127+
}
128+
}
129+
81130
mac_toolchain_suite("clang_x64") {
82131
toolchain_cpu = "x64"
83132
toolchain_os = "mac"

runtime/BUILD.gn

+12-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ config("dart_os_config") {
104104
} else if (target_os == "ios") {
105105
defines += [ "DART_TARGET_OS_MACOS" ]
106106
defines += [ "DART_TARGET_OS_MACOS_IOS" ]
107+
} else if (target_os == "watchos") {
108+
defines += [ "DART_TARGET_OS_MACOS" ]
109+
110+
# This doesn't look entirely correct, but so far it looks
111+
# sufficient and allows to add watchOS support with less changes.
112+
# If we need to differentiate iOS and watchOS targets later, we'll
113+
# change this.
114+
defines += [ "DART_TARGET_OS_MACOS_IOS" ]
107115
} else if (target_os == "linux") {
108116
defines += [ "DART_TARGET_OS_LINUX" ]
109117
} else if (target_os == "mac") {
@@ -317,7 +325,10 @@ source_set("dart_api") {
317325

318326
library_for_all_configs("libdart") {
319327
target_type = dart_component_kind
320-
extra_nonproduct_deps = [ "vm:libprotozero" ]
328+
extra_nonproduct_deps = []
329+
if (dart_support_perfetto) {
330+
extra_nonproduct_deps += [ "vm:libprotozero" ]
331+
}
321332
extra_deps = [
322333
":generate_version_cc_file",
323334
"../third_party/double-conversion/src:libdouble_conversion",

runtime/bin/process_macos.cc

+6
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@ int Process::Exec(Namespace* namespc,
903903
const char* working_directory,
904904
char* errmsg,
905905
intptr_t errmsg_len) {
906+
#if defined(DART_HOST_OS_WATCH)
907+
// execvp is not available on watchOS.
908+
Utils::StrError(ENOSYS, errmsg, errmsg_len);
909+
return -1;
910+
#else
906911
if (working_directory != nullptr &&
907912
TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) {
908913
Utils::StrError(errno, errmsg, errmsg_len);
@@ -912,6 +917,7 @@ int Process::Exec(Namespace* namespc,
912917
execvp(const_cast<const char*>(path), const_cast<char* const*>(arguments));
913918
Utils::StrError(errno, errmsg, errmsg_len);
914919
return -1;
920+
#endif
915921
}
916922

917923
static int SignalMap(intptr_t id) {

runtime/platform/globals.h

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@
122122
#if TARGET_OS_IPHONE
123123
#define DART_HOST_OS_IOS 1
124124
#endif
125+
#if TARGET_OS_WATCH
126+
#define DART_HOST_OS_WATCH 1
127+
#endif
125128

126129
#elif defined(_WIN32)
127130

runtime/runtime_args.gni

+8-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ declare_args() {
7272
# Whether the sampling heap profiler should be included in product mode.
7373
dart_include_sampling_heap_profiler = false
7474

75-
# Whether features that depend on Perfetto should be built. We temporarily
76-
# need to define this to allow excluding code that depends on Perfetto from
77-
# being built on platforms which have a problem linking in the Perfetto
78-
# library.
79-
dart_support_perfetto = true
75+
# Whether features that depend on Perfetto should be built. We need
76+
# to define this to allow excluding code that depends on Perfetto
77+
# from being built on platforms which have a problem linking in the
78+
# Perfetto library, e.g. watchOS.
79+
#
80+
# is_watchos may be undefined when Dart SDK is built from the Flutter
81+
# engine tree.
82+
dart_support_perfetto = !defined(is_watchos) || !is_watchos
8083

8184
# Whether to support dynamic loading and interpretation of Dart bytecode.
8285
dart_dynamic_modules = false

runtime/tools/bin_to_assembly.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def Main():
5151
return -1
5252

5353
with open(options.output, "w") as output_file:
54-
if options.target_os in ["mac", "ios"]:
54+
if options.target_os in ["mac", "ios", "watchos"]:
5555
if options.executable:
5656
output_file.write(".text\n")
5757
else:
@@ -106,7 +106,7 @@ def Main():
106106
if incbin:
107107
output_file.write(".incbin \"%s\"\n" % options.input)
108108

109-
if options.target_os not in ["mac", "ios", "win", "win_gnu"]:
109+
if options.target_os not in ["mac", "ios", "watchos", "win", "win_gnu"]:
110110
output_file.write(".size {0}, .-{0}\n".format(options.symbol_name))
111111

112112
if options.size_symbol_name:
@@ -128,7 +128,7 @@ def Main():
128128
else:
129129
output_file.write("dword %d\n" % size)
130130
else:
131-
if options.target_os in ["mac", "ios"]:
131+
if options.target_os in ["mac", "ios", "watchos"]:
132132
output_file.write(
133133
".global _%s\n" % options.size_symbol_name)
134134
output_file.write("_%s:\n" % options.size_symbol_name)

0 commit comments

Comments
 (0)