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

add Android support #609

Merged
merged 7 commits into from Sep 27, 2018

Conversation

Projects
None yet
5 participants
@albertaleksieiev
Contributor

albertaleksieiev commented Sep 4, 2018

Add Android support

Motivation:

make swift-nio compatible with Android, and pass all test in Android.

Modifications:

  • add missed ifaddrs implementation
  • add missed thread related functions - CNIOLinux_pthread_getname_np, CNIOLinux_pthread_setaffinity_np and CNIOLinux_pthread_getaffinity_np
  • fix types incositency between Linux and Android, e.g. Epoll.swift class
  • make bytes counter explicitely 64bits to avoid overflow on 32bit, in PendingWritesManager.swift and PendingDatagramWritesState.swift
  • fix issue with Unix domain socket, first byte need to be zero in Android
  • several incosistency fixes between Linux and Android api.

Result:

now swift-nio works on Android. All tests passed!

@swift-nio-bot

This comment has been minimized.

swift-nio-bot commented Sep 4, 2018

Can one of the admins verify this patch?

1 similar comment
@swift-nio-bot

This comment has been minimized.

swift-nio-bot commented Sep 4, 2018

Can one of the admins verify this patch?

@weissi

This comment has been minimized.

Contributor

weissi commented Sep 7, 2018

wow thanks so much @albertaleksieiev! I'll have a look over the next week (sorry we were out on a conference and almost out to the next)

@weissi

thanks! This is a great start, a couple of minor comments.

Show resolved Hide resolved Sources/CNIOLinux/ifaddrs-android.c
Show resolved Hide resolved Sources/NIO/SocketAddresses.swift Outdated
Show resolved Hide resolved Sources/NIOChatClient/main.swift Outdated
Show resolved Hide resolved Tests/NIOHTTP1Tests/HTTPServerClientTest.swift
Show resolved Hide resolved Tests/NIOTests/ChannelTests.swift Outdated
Show resolved Hide resolved Tests/NIOTests/ChannelTests.swift Outdated
Show resolved Hide resolved Tests/NIOTests/DatagramChannelTests.swift Outdated
Show resolved Hide resolved Tests/NIOTests/PendingDatagramWritesManagerTests.swift Outdated
Show resolved Hide resolved Tests/NIOTests/TestUtils.swift Outdated
@albertaleksieiev

This comment has been minimized.

Contributor

albertaleksieiev commented Sep 8, 2018

Thanks for your response and review @weissi 👌Unfortunately nearest 2 weeks I will be on vacation, so I can commit changes after vacation. But I will response on your changes in a few days😇

@weissi

This comment has been minimized.

Contributor

weissi commented Sep 10, 2018

@swift-nio-bot test this please

Show resolved Hide resolved Sources/NIO/GetaddrinfoResolver.swift
Show resolved Hide resolved Sources/NIO/Interfaces.swift
Show resolved Hide resolved Sources/NIO/Utilities.swift
@albertaleksieiev

This comment has been minimized.

Contributor

albertaleksieiev commented Sep 24, 2018

@weissi , @Lukasa , @normanmaurer please check my changes

@Lukasa

A few small syscall notes.

Show resolved Hide resolved Sources/CNIOLinux/shim.c Outdated
Show resolved Hide resolved Sources/CNIOLinux/shim.c Outdated
@weissi

This comment has been minimized.

Contributor

weissi commented Sep 25, 2018

thanks @albertaleksieiev this looks great and I'll approve as soon as you resolve @Lukasa 's comments. And then 🛳

@albertaleksieiev

This comment has been minimized.

Contributor

albertaleksieiev commented Sep 26, 2018

Fixed! And also I fix some issues regarding the latest master branch. But unfortunately I pushed force and now all timeline is shifted 😓

@Lukasa

Lukasa approved these changes Sep 26, 2018

OK, I think I'm happy!

@Lukasa Lukasa added this to the 1.10.0 milestone Sep 26, 2018

@weissi

weissi approved these changes Sep 26, 2018

so am I. Thank you very much!

@weissi

This comment has been minimized.

Contributor

weissi commented Sep 26, 2018

@swift-nio-bot test this please

@weissi

This comment has been minimized.

Contributor

weissi commented Sep 26, 2018

@weissi

This comment has been minimized.

Contributor

weissi commented Sep 26, 2018

@albertaleksieiev oh, the PR validation failed. You'll need to add exceptions in scripts/sanity.sh for Sources/CNIOLinux/ifaddrs-android.c. Basically you'll need to add at least

-o -name ifaddrs-android.c

to the exceptions list

exceptions=( -name c_nio_http_parser.c -o -name c_nio_http_parser.h -o -name cpp_magic.h -o -name Package.swift -o -name c_nio_sha1.h -o -name c_nio_sha1.c)

The exception list contains all files that are not covered under the normal NIO license. Those bits of code need to be listed in NOTICE.txt (which you did) and scripts/sanity.sh needs to be told that this is in fact an exception to the normal license. You possibly need to do that for the header file too.

@albertaleksieiev

This comment has been minimized.

Contributor

albertaleksieiev commented Sep 26, 2018

@weissi oh thanks! I added also ifaddrs-android.h, because without it says => Checking license headers... missing headers in file './Sources/CNIOLinux/include/ifaddrs-android.h'!

@weissi

This comment has been minimized.

Contributor

weissi commented Sep 26, 2018

@swift-nio-bot test this please

@weissi

This comment has been minimized.

Contributor

weissi commented Sep 26, 2018

Awesome, all green! @normanmaurer ready to merge when you are

@normanmaurer

Awesome work!

@albertaleksieiev

This comment has been minimized.

Contributor

albertaleksieiev commented Sep 27, 2018

Thanks to everyone! Swift-nio now will be compatible with Android 🤩

@weissi weissi merged commit a59293c into apple:master Sep 27, 2018

3 checks passed

pull request validation (4.0.3) Build finished.
Details
pull request validation (4.1) Build finished.
Details
pull request validation (4.2) Build finished.
Details

@albertaleksieiev albertaleksieiev referenced this pull request Oct 1, 2018

Merged

fix Android support #45

weissi added a commit to apple/swift-nio-ssl that referenced this pull request Oct 5, 2018

fix Android support (#45)
### Android support

**Motivation:**
* fix `swift-nio-ssl` compatible with Android. This is a continuation(apple/swift-nio#609) of porting `Vapor/WebSocket` and all related packages to Android.
* remove unused #if macros for Android
* fix `stat` func with convention(c) attribute for Android

**Modifications:**
fix `FileSystemObject::pathType` and `sysStat` Android API inconsistency

**Result:**
now `swift-nio-ssl` compatible with Android!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment