-
Notifications
You must be signed in to change notification settings - Fork 208
Android: Build Swift SDK for Android supporting API 23 #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,3 +161,32 @@ pushd boringssl >/dev/null 2>&1 | |
| git checkout ${BORINGSSL_VERSION} | ||
| popd >/dev/null 2>&1 | ||
| groupend | ||
|
|
||
| groupstart "Patching Sources" | ||
| pushd swift-project >/dev/null | ||
|
|
||
| # This `git grep` invocation in a trunk test fails in our Docker for some | ||
| # reason, so just turn it into a plain `grep` again. | ||
| perl -pi -e 's:"git",:#:' swift/test/Misc/verify-swift-feature-testing.test-sh | ||
|
|
||
| # Work around swiftlang/swift-driver#1822 for now | ||
| perl -pi -g -we "s#(call rm ... \".\{LIBDISPATCH_BUILD_DIR\}\"\n(\s+)fi\n)#\1\2if [[ -d \"\\\${ANDROID_NDK}\" ]]; then call ln -sf \"\\\${SWIFT_BUILD_PATH}/lib/swift\" \"\\\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib\"; fi#" swift/utils/build-script-impl | ||
|
|
||
| # fix optional result value in backtrace() call | ||
| perl -pi -e 's;.init\(clamping: addresses.count\)\)\);.init\(clamping: addresses.count\)\) ?? 0\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did this cause a problem? We're building fine everywhere without it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got an error when I initially tried it without the optional guard. Regardless, this whole line is being patched out anyway, so it could likely just be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's unusual, as both the official and my CI build fine without this patch. |
||
|
|
||
| # disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport); will be fixed post 6.2 (in which case only the above patch is needed) | ||
| perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift | ||
|
|
||
|
|
||
| # Disable posix_spawnattr_* calls for Android API 23 | ||
| perl -pi -e 's;try _throwIfPosixError\(posix_spawnattr_init;throw NSError\(domain: NSPOSIXErrorDomain, code: .init\(ENOEXEC\), userInfo: [ NSLocalizedFailureReasonErrorKey: "Process unavailable on Android" ]\) //try _throwIfPosixError\(posix_spawnattr_init;g' swift-corelibs-foundation/Sources/Foundation/Process.swift | ||
| perl -pi -e 's;try _throwIfPosixError\(posix_spawnattr_setflags;//try _throwIfPosixError\(posix_spawnattr_setflags;g' swift-corelibs-foundation/Sources/Foundation/Process.swift | ||
| perl -pi -e 's;posix_spawnattr_destroy;//posix_spawnattr_destroy;g' swift-corelibs-foundation/Sources/Foundation/Process.swift | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should stub this out, as it will then change this behavior and fail the associated test when we start running them, even on API 28 and above where it works. Instead, if somebody wants to push this bundle back to API 23, they should add polyfills for these methods too, as there already are for most of the |
||
|
|
||
| # Stub out getgrgid_r and getgrnam_r missing from Android API 23 | ||
| perl -pi -e 's;getgrgid_r|getgrnam_r;{ _, _, _, _, _ in 0 };g' swift-foundation/Sources/FoundationEssentials/Platform.swift | ||
|
|
||
| popd >/dev/null 2>&1 | ||
| groupend | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The android-api is just set in the default in build.sh; we never override it from
build-dockerorbuild-local, so I removed it so where is just a single place where we define the default.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the idea was that people using these scripts could pass in
ANDROID_APIand build the SDK for other API levels too.