Skip to content

Commit 7158d5f

Browse files
committed
1 parent f726321 commit 7158d5f

4 files changed

Lines changed: 58 additions & 1 deletion

File tree

runtime/bin/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ source_set("embedded_dart_io") {
208208
"builtin.cc",
209209
"builtin_gen_snapshot.cc",
210210
]
211-
if (!is_mac) {
211+
if (!is_mac && !is_ios) {
212212
# Dart tree uses *_macos.* instead of *_mac.*
213213
custom_sources_filter += [
214214
"*_macos.h",

runtime/bin/file_system_watcher_macos.cc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include "bin/file_system_watcher.h"
99

10+
#if !defined(TARGET_OS_IOS)
11+
1012
#include <errno.h> // NOLINT
1113
#include <fcntl.h> // NOLINT
1214
#include <unistd.h> // NOLINT
@@ -392,4 +394,44 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
392394
} // namespace bin
393395
} // namespace dart
394396

397+
#else // !defined(TARGET_OS_IOS)
398+
399+
namespace dart {
400+
namespace bin {
401+
402+
// FSEvents are unavailable on iOS. Stub out related methods
403+
Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
404+
return DartUtils::NewDartOSError();
405+
}
406+
407+
intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) {
408+
return -1;
409+
}
410+
411+
bool FileSystemWatcher::IsSupported() {
412+
return false;
413+
}
414+
415+
void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) {
416+
}
417+
418+
intptr_t FileSystemWatcher::Init() {
419+
return -1;
420+
}
421+
422+
void FileSystemWatcher::Close(intptr_t id) {
423+
}
424+
425+
intptr_t FileSystemWatcher::WatchPath(intptr_t id,
426+
const char* path,
427+
int events,
428+
bool recursive) {
429+
return -1;
430+
}
431+
432+
} // namespace bin
433+
} // namespace dart
434+
435+
#endif // !defined(TARGET_OS_IOS)
436+
395437
#endif // defined(TARGET_OS_MACOS)

runtime/bin/platform_macos.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) {
5757

5858

5959
char** Platform::Environment(intptr_t* count) {
60+
#if defined(TARGET_OS_IOS)
61+
// TODO(iposva): On Mac (desktop), _NSGetEnviron() is used to access the
62+
// environ from shared libraries or bundles. This is present in crt_externs.h
63+
// which is unavailable on iOS. On iOS, everything is statically linked for
64+
// now. So arguably, accessing the environ directly with a "extern char
65+
// **environ" will work. But this approach is brittle as the target with this
66+
// CU could be a dynamic framework (introduced in iOS 8). A more elegant
67+
// approach needs to be devised.
68+
return NULL;
69+
#else
6070
// Using environ directly is only safe as long as we do not
6171
// provide access to modifying environment variables.
6272
// On MacOS you have to do a bit of magic to get to the
@@ -71,6 +81,7 @@ char** Platform::Environment(intptr_t* count) {
7181
result[current] = environ[current];
7282
}
7383
return result;
84+
#endif
7485
}
7586

7687

runtime/bin/process_macos.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
#include "bin/process.h"
99

10+
#if !defined(TARGET_OS_IOS)
1011
#include <crt_externs.h> // NOLINT
12+
#endif
1113
#include <errno.h> // NOLINT
1214
#include <fcntl.h> // NOLINT
1315
#include <poll.h> // NOLINT
@@ -451,12 +453,14 @@ class ProcessStarter {
451453
ReportChildError();
452454
}
453455

456+
#if !defined(TARGET_OS_IOS)
454457
if (program_environment_ != NULL) {
455458
// On MacOS you have to do a bit of magic to get to the
456459
// environment strings.
457460
char*** environ = _NSGetEnviron();
458461
*environ = program_environment_;
459462
}
463+
#endif
460464

461465
VOID_TEMP_FAILURE_RETRY(
462466
execvp(path_, const_cast<char* const*>(program_arguments_)));

0 commit comments

Comments
 (0)