Skip to content

Commit

Permalink
Merge pull request #220 from vibe-d/ios_support
Browse files Browse the repository at this point in the history
IOS build support
  • Loading branch information
Geod24 authored Apr 6, 2023
2 parents 5baa964 + dfaee81 commit 47a9ff9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 45 deletions.
44 changes: 19 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Supported drivers and operating systems

Driver | Linux | Windows | macOS | FreeBSD | Android | iOS
---------------------|---------|---------|---------|---------|---------|---------
SelectEventDriver | yes | yes | yes | yes¹ | yes | —
SelectEventDriver | yes | yes | yes | yes¹ | yes | yes
EpollEventDriver | yes | — | — | — | yes | —
WinAPIEventDriver | — | yes | — | — | — | —
KqueueEventDriver | — | — | yes | yes¹ | — | —
KqueueEventDriver | — | — | yes | yes¹ | — | yes
CFRunloopEventDriver | — | — | yes | — | — | yes
LibasyncEventDriver | —¹| —¹| —¹| —¹| — | —

¹ planned, but not currenly implemented
Expand All @@ -30,36 +31,29 @@ Supported compilers

The following compilers are tested and supported:

- DMD 2.087.1
- DMD 2.103.0
- DMD 2.086.1
- DMD 2.085.1
- DMD 2.084.1
- DMD 2.079.0
- LDC 1.17.0
- LDC 1.32.0
- LDC 1.16.0
- LDC 1.15.0
- LDC 1.14.0
- LDC 1.13.0
- LDC 1.9.0


Driver development status
-------------------------

Feature \ EventDriver | Select | Epoll | WinAPI | Kqueue | Libasync
----------------------|--------|-------|---------|---------|----------
TCP Sockets | yes | yes | yes | yes | —
UDP Sockets | yes | yes | yes | yes | —
USDS | yes | yes | — | yes | —
DNS | yes | yes | yes | yes | —
Timers | yes | yes | yes | yes | —
Events | yes | yes | yes | yes | —
Unix Signals | yes² | yes | — | — | —
Files | yes | yes | yes | yes | —
UI Integration | yes¹ | yes¹ | yes | yes¹ | —
File watcher | yes² | yes | yes | yes² | —
Pipes | yes | yes | — | yes | —
Processes | yes | yes | — | yes | —
Feature \ EventDriver | Select | Epoll | WinAPI | Kqueue | CFRunloop | Libasync
----------------------|--------|-------|---------|---------|-----------|----------
TCP Sockets | yes | yes | yes | yes | yes | —
UDP Sockets | yes | yes | yes | yes | yes | —
USDS | yes | yes | — | yes | yes | —
DNS | yes | yes | yes | yes | yes | —
Timers | yes | yes | yes | yes | yes | —
Events | yes | yes | yes | yes | yes | —
Unix Signals | yes² | yes | — | — | — | —
Files | yes | yes | yes | yes | yes | —
UI Integration | yes¹ | yes¹ | yes | yes¹ | yes¹ | —
File watcher | yes² | yes | yes | yes² | yes² | —
Pipes | yes | yes | — | yes | yes | —
Processes | yes | yes | — | yes | yes | —

¹ Manually, by adopting the X11 display connection socket

Expand Down
2 changes: 1 addition & 1 deletion dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ configuration "epoll-gaia" {
}

configuration "cfrunloop" {
platforms "osx"
platforms "osx" "ios" "tvos" "watchos"
versions "EventcoreCFRunLoopDriver"
lflags "-framework" "CoreFoundation"
lflags "-framework" "CoreServices"
Expand Down
9 changes: 4 additions & 5 deletions source/eventcore/drivers/posix/kqueue.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
module eventcore.drivers.posix.kqueue;
@safe: /*@nogc:*/ nothrow:

import eventcore.internal.corefoundation : isAppleOS;

version (FreeBSD) enum have_kqueue = true;
else version (DragonFlyBSD) enum have_kqueue = true;
else version (OSX) enum have_kqueue = true;
else static if (isAppleOS) enum have_kqueue = true;
else enum have_kqueue = false;

static if (have_kqueue):
Expand All @@ -20,15 +22,12 @@ import eventcore.internal.utils;
import core.time : Duration;
import core.sys.posix.sys.time : timespec, time_t;

version (OSX) import core.sys.darwin.sys.event;
static if (isAppleOS) import core.sys.darwin.sys.event;
else version (FreeBSD) import core.sys.freebsd.sys.event;
else version (DragonFlyBSD) import core.sys.dragonflybsd.sys.event;
else static assert(false, "Kqueue not supported on this OS.");


import core.sys.linux.epoll;


alias KqueueEventDriver = PosixEventDriver!KqueueEventLoop;

final class KqueueEventLoop : KqueueEventLoopBase {
Expand Down
16 changes: 5 additions & 11 deletions source/eventcore/drivers/posix/sockets.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module eventcore.drivers.posix.sockets;

import eventcore.driver;
import eventcore.drivers.posix.driver;
import eventcore.internal.corefoundation : isAppleOS;
import eventcore.internal.utils;

import std.algorithm.comparison : among, min, max;
Expand Down Expand Up @@ -37,8 +38,7 @@ version (Posix) {
else version (DragonFlyBSD) enum O_CLOEXEC = 0x0020000;
else version (NetBSD) enum O_CLOEXEC = 0x400000;
else version (OpenBSD) enum O_CLOEXEC = 0x10000;
else version (OSX) enum O_CLOEXEC = 0x1000000;
else version (iOS) enum O_CLOEXEC = 0x1000000;
else static if (isAppleOS) enum O_CLOEXEC = 0x1000000;
}
}
version (linux) {
Expand All @@ -64,11 +64,7 @@ version (linux) {
static if (!is(typeof(TCP_USER_TIMEOUT)))
enum TCP_USER_TIMEOUT = 18;
}
version (OSX) {
import core.sys.darwin.netinet.in_ : IP_ADD_MEMBERSHIP, IP_MULTICAST_LOOP;
static if (!is(typeof(ESHUTDOWN))) enum ESHUTDOWN = 58;
}
version (iOS) {
static if (isAppleOS) {
import core.sys.darwin.netinet.in_ : IP_ADD_MEMBERSHIP, IP_MULTICAST_LOOP;
static if (!is(typeof(ESHUTDOWN))) enum ESHUTDOWN = 58;
}
Expand Down Expand Up @@ -111,9 +107,7 @@ version (Android) {
}

version (Posix) {
version (OSX) {
enum SEND_FLAGS = 0;
} else version (iOS) {
static if (isAppleOS) {
enum SEND_FLAGS = 0;
} else {
enum SEND_FLAGS = MSG_NOSIGNAL;
Expand Down Expand Up @@ -1143,7 +1137,7 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
setSocketNonBlocking(sock, true);

// Prevent SIGPIPE on failed send
version (OSX) {
static if (isAppleOS) {
int val = 1;
() @trusted { setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &val, val.sizeof); } ();
}
Expand Down
3 changes: 2 additions & 1 deletion source/eventcore/drivers/posix/watchers.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module eventcore.drivers.posix.watchers;
import eventcore.driver;
import eventcore.drivers.posix.driver;
import eventcore.internal.utils : mallocT, freeT, nogc_assert;
import eventcore.internal.corefoundation : isAppleOS;


final class InotifyEventDriverWatchers(Events : EventDriverEvents) : EventDriverWatchers
Expand Down Expand Up @@ -200,7 +201,7 @@ final class InotifyEventDriverWatchers(Events : EventDriverEvents) : EventDriver
}
}

version (darwin)
static if (isAppleOS)
final class FSEventsEventDriverWatchers(Events : EventDriverEvents) : EventDriverWatchers {
@safe: /*@nogc:*/ nothrow:
import eventcore.internal.corefoundation;
Expand Down
8 changes: 7 additions & 1 deletion source/eventcore/internal/corefoundation.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module eventcore.internal.corefoundation;

version (darwin):
version (OSX) enum isAppleOS = true;
else version (iOS) enum isAppleOS = true;
else version (TVOS) enum isAppleOS = true;
else version (WatchOS) enum isAppleOS = true;
else enum isAppleOS = false;

static if (isAppleOS):

nothrow extern(C):

Expand Down
2 changes: 1 addition & 1 deletion source/eventcore/internal/coreservices.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module eventcore.internal.coreservices;

import eventcore.internal.corefoundation;

version (darwin):
static if (isAppleOS):

nothrow extern(C):

Expand Down

0 comments on commit 47a9ff9

Please sign in to comment.