Skip to content

Commit e69318d

Browse files
authored
Android support (swift-server#799)
This PR adds support for Android, mostly just by importing the Android module when needed.
1 parent 1265185 commit e69318d

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

Sources/AsyncHTTPClient/ConnectionPool.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import NIOSSL
2020
import Darwin.C
2121
#elseif canImport(Musl)
2222
import Musl
23-
#elseif os(Linux) || os(FreeBSD) || os(Android)
23+
#elseif canImport(Android)
24+
import Android
25+
#elseif os(Linux) || os(FreeBSD)
2426
import Glibc
2527
#else
2628
#error("unsupported target operating system")

Sources/AsyncHTTPClient/ConnectionPool/State Machine/HTTPConnectionPool+Backoff.swift

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import NIOCore
1818
import func Darwin.pow
1919
#elseif canImport(Musl)
2020
import func Musl.pow
21+
#elseif canImport(Android)
22+
import func Android.pow
2123
#else
2224
import func Glibc.pow
2325
#endif

Sources/AsyncHTTPClient/HTTPClient+HTTPCookie.swift

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import locale_h
2626
import Darwin
2727
#elseif canImport(Musl)
2828
import Musl
29+
#elseif canImport(Android)
30+
import Android
2931
#elseif canImport(Glibc)
3032
import Glibc
3133
#endif

Sources/CAsyncHTTPClient/CAsyncHTTPClient.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bool swiftahc_cshims_strptime(const char * string, const char * format, struct t
3131

3232
bool swiftahc_cshims_strptime_l(const char * string, const char * format, struct tm * result, void * locale) {
3333
// The pointer cast is fine as long we make sure it really points to a locale_t.
34-
#ifdef __musl__
34+
#if defined(__musl__) || defined(__ANDROID__)
3535
const char * firstNonProcessed = strptime(string, format, result);
3636
#else
3737
const char * firstNonProcessed = strptime_l(string, format, result, (locale_t)locale);

Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import locale_h
3939
import Darwin
4040
#elseif canImport(Musl)
4141
import Musl
42+
#elseif canImport(Android)
43+
import Android
4244
#elseif canImport(Glibc)
4345
import Glibc
4446
#endif

0 commit comments

Comments
 (0)