Skip to content

Commit 201f43b

Browse files
authored
Merge pull request #29 from jakepetroules/android-support
Add support for building on Android
2 parents c6dc97f + 4c87072 commit 201f43b

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

Sources/Subprocess/Configuration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#if canImport(Darwin)
1919
import Darwin
20-
#elseif canImport(Bionic)
21-
import Bionic
20+
#elseif canImport(Android)
21+
import Android
2222
#elseif canImport(Glibc)
2323
import Glibc
2424
#elseif canImport(Musl)

Sources/Subprocess/Platforms/Subprocess+Linux.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
#if canImport(Glibc) || canImport(Bionic) || canImport(Musl)
12+
#if canImport(Glibc) || canImport(Android) || canImport(Musl)
1313

1414
#if canImport(System)
1515
@preconcurrency import System
@@ -19,8 +19,8 @@
1919

2020
#if canImport(Glibc)
2121
import Glibc
22-
#elseif canImport(Bionic)
23-
import Bionic
22+
#elseif canImport(Android)
23+
import Android
2424
#elseif canImport(Musl)
2525
import Musl
2626
#endif
@@ -263,6 +263,8 @@ private extension siginfo_t {
263263
return _sifields._sigchld.si_status
264264
#elseif canImport(Musl)
265265
return __si_fields.__si_common.__second.__sigchld.si_status
266+
#elseif canImport(Bionic)
267+
return _sifields._sigchld._status
266268
#endif
267269
}
268270

@@ -271,6 +273,8 @@ private extension siginfo_t {
271273
return _sifields._sigchld.si_pid
272274
#elseif canImport(Musl)
273275
return __si_fields.__si_common.__first.__piduid.si_pid
276+
#elseif canImport(Bionic)
277+
return _sifields._kill._pid
274278
#endif
275279
}
276280
}
@@ -339,4 +343,4 @@ private func _setupMonitorSignalHandler() {
339343
setup
340344
}
341345

342-
#endif // canImport(Glibc) || canImport(Bionic) || canImport(Musl)
346+
#endif // canImport(Glibc) || canImport(Android) || canImport(Musl)

Sources/Subprocess/Platforms/Subprocess+Unix.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
#if canImport(Darwin) || canImport(Glibc) || canImport(Bionic) || canImport(Musl)
12+
#if canImport(Darwin) || canImport(Glibc) || canImport(Android) || canImport(Musl)
1313

1414
#if canImport(System)
1515
@preconcurrency import System
@@ -21,8 +21,8 @@ import _SubprocessCShims
2121

2222
#if canImport(Darwin)
2323
import Darwin
24-
#elseif canImport(Bionic)
25-
import Bionic
24+
#elseif canImport(Android)
25+
import Android
2626
#elseif canImport(Glibc)
2727
import Glibc
2828
#elseif canImport(Musl)
@@ -553,4 +553,4 @@ extension FileDescriptor {
553553

554554
internal typealias PlatformFileDescriptor = FileDescriptor
555555

556-
#endif // canImport(Darwin) || canImport(Glibc) || canImport(Bionic) || canImport(Musl)
556+
#endif // canImport(Darwin) || canImport(Glibc) || canImport(Android) || canImport(Musl)

Sources/_SubprocessCShims/process_shims.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,23 @@ static int _subprocess_addchdir_np(
290290
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29)
291291
// Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting:
292292
// - Amazon Linux 2 (EoL mid-2025)
293-
// noop
293+
return ENOTSUP;
294+
#elif defined(__ANDROID__) && __ANDROID_API__ < 34
295+
// Android versions prior to 14 (API level 34) don't support posix_spawn_file_actions_addchdir_np
296+
return ENOTSUP;
294297
#elif defined(__OpenBSD__) || defined(__QNX__)
295298
// Currently missing as of:
296299
// - OpenBSD 7.5 (April 2024)
297300
// - QNX 8 (December 2023)
298-
// noop
299-
#elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || (defined(__ANDROID__) && __ANDROID_API__ >= 34) || defined(__musl__)
301+
return ENOTSUP;
302+
#elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__musl__)
300303
// Pre-standard posix_spawn_file_actions_addchdir_np version available in:
301304
// - Solaris 11.3 (October 2015)
302305
// - Glibc 2.29 (February 2019)
303306
// - macOS 10.15 (October 2019)
304307
// - musl 1.1.24 (October 2019)
305308
// - FreeBSD 13.1 (May 2022)
306-
// - Android 14 (October 2023)
309+
// - Android 14 (API level 34) (October 2023)
307310
return posix_spawn_file_actions_addchdir_np(file_actions, path);
308311
#else
309312
// Standardized posix_spawn_file_actions_addchdir version (POSIX.1-2024, June 2024) available in:

0 commit comments

Comments
 (0)