Repository navigation
Add Android support - #222
Conversation
| internal import Logging | ||
| #elseif canImport(Android) | ||
| import Android | ||
| internal import Logging |
There was a problem hiding this comment.
All these imports were added by a regex substitution, then manually reviewed.
| #if os(Linux) || os(Android) | ||
| #if canImport(Glibc) | ||
| import Glibc | ||
| internal import SwiftNetworkLinuxShim |
There was a problem hiding this comment.
This linux shim works on Android, but I removed it since it's unneeded.
|
Rebased, added Android to CI, and made a formatting change to one file that the CI check wanted. |
|
Looks like we need to fix this CI build error: I'm not familiar with Android, but do you know what's going on? |
|
Oh, didn't notice that you are switching back to the native build system for the nightlies on CI, any reason you still have that? That is causing the above Android error for the 6.4.x nightlies, as the 6.4 release works fine for Android, where that flag is not applied. The trunk build hangs, as do all the other builds using the linux toolchain right now because of the compiler issue I linked. |
Are you saying that nightly-6.4 doesn't work on Android? If that's the case, we can disable it for now in your CI changes. |
No, the issue is that the official GitHub workflows now only expect the Android SDK to be used with the swiftbuild build system, so they only look in that internal build directory for the test runners. I find it strange that you are still using the native build system for the nightlies alone on the CI here, do you know why that is? |
|
I think the --build-system native flag was to work around an issue on 6.5 (maybe). I think it's worth removing it now to see if it's still needed. |
|
OK, will try that here and see. |
|
Hmm, most CI failing in this test that was added yesterday, some subsequent pull broke it? |
It's fixed now. Could you please rebase? |
|
@rpaulo, rebased, please run CI. |
|
The last rebase picked up a new linux/mac-only logging method: added it for Android and checked to make sure this branch builds on Android locally before updating now. |
|
Alright, all non-trunk builds are passing now, including the nightly 6.4.x Android SDK snapshots once I removed the change to the native build system. How about we get the first commit here in for Android support, then I will submit a separate CI-only pull to clean up those workflows for all platforms? |
|
No need to wait on #226, as all trunk builds fail because of the trunk compiler regression anyway. |
|
Simply rebased to pick up changes that should get main CI working too. |
|
OK, now that #228 is merged, would the Android build succeed? If you think so, please rebase so we can try again. |
|
Rebased to pull in those CI config changes, yes, Android with the trunk SDK should work now, since that pull switched it back to the default swiftbuild build system. |
rpaulo
left a comment
There was a problem hiding this comment.
Approved. I don't see the Swift Network tests running on Android yet, but we could try to fix that in another PR.
|
That is a separate issue with the official workflow that will be fixed upstream at some point, swiftlang/github-workflows#277. |
| throw NetworkError.posix(error) | ||
| } | ||
| #if canImport(Android) | ||
| guard let nameBuffer = if_indextoname(index, bufferAddress) else { |
There was a problem hiding this comment.
Our internal review system flagged this as not following Linux which uses System.syscallOptional and retries on EINTR and saves errno correctly. Could we use syscallOptional on Android as well?
There was a problem hiding this comment.
Sure, I threw that out for Android because it was unnecessarily converting the index to Int and then back again to UInt and I didn't see the point to that method, but I suppose I can create UInt overloads for Android.
There was a problem hiding this comment.
Added another commit that uses that method, tested as always by building and running the tests on my Android 16 phone, with this code first built against the Android 7 APIs.
|
Simply rebased to avoid an incorrect API breakage check from subsequently merged pulls |
|
Thanks for the quick review. 👍 @Cartisim, please take a look if you'd like anything else added. |
This package now compiles and all tests passed natively on Android built against API 24 with a Sep. 21 trunk snapshot toolchain and apple/swift-tls#23 applied to that dependency, though with the
-Xswiftc -Oflag added to work around swiftlang/swift#92886.