Skip to content
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

Porting to Cygwin #381

Merged
merged 1 commit into from Oct 6, 2016
Merged

Conversation

tinysun212
Copy link
Contributor

@tinysun212 tinysun212 commented May 21, 2016

This is the initial porting.

A simple function like below code is working in Cygwin.

import Foundation
let swifty = NSURLComponents(string: "https://swift.org")!
print("\(swifty.host!)")

Maybe there are many bugs in this port, but it is sufficient us to review and taste the Foundation in Cygwin.

The Swift compiler option "-DCYGWIN" will be added if companion PR #541 is merged.

The macro might be changed to some other macro function like os(Cygwin) later.

#include <unistd.h>
#if !DEPLOYMENT_TARGET_CYGWIN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we avoid the negative-sense deployment target macros. Keeping them consistently positive-sense and using #if/#else instead makes it easier to reason about them (and there are lots).

@parkera
Copy link
Member

parkera commented May 21, 2016

I like the general direction of this, but I wonder if we can simplify the patch a bit by lumping cygwin under linux in general (since it seems to closely related) and then having just a few places where they differ.

Including the Windows SDK (I'm assuming this is the "windows.h" we imported) is a pretty big change though. Is there any compatibility shim provided by cygwin that will allow us to skip that?

@tinysun212
Copy link
Contributor Author

@parkera, Thanks your reviews. I will reply your review or modify the code, as soon as I fix my machine which does not boot from two days ago.

@tinysun212 tinysun212 force-pushed the pr-foundation-cygwin-1 branch 3 times, most recently from 966ce1d to 67f67a1 Compare May 28, 2016 00:22
@tinysun212
Copy link
Contributor Author

@parkera,
I changed the #if !DEPLOYMENT_TARGET_CYGWIN to #if/#else pattern.
The python scripts will be modified in other PR considering Windows.
The #include <windows.h> is moved from CoreFoundation_Prefix.h to CFRunLoop.c.

#define TARGET_OS_CYGWIN 0
#elif __CYGWIN__
#define TARGET_OS_DARWIN 0
#define TARGET_OS_LINUX 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So - how different is cygwin from linux? cygwin's idea is to provide a Linux-like environment for Windows.

I think we should have TARGET_OS_LINUX here set to 1 for cygwin, and also define DEPLOYMENT_TARGET_LINUX when building cygwin.

We can also define TARGET_OS_CYGWIN here (as you have done) and use that in the rare places where cygwin is truly different from Linux. That should dramatically simplify this patch, and also keep us from having to specify that deployment target everywhere (or forgetting to, and breaking the build for Cygwin).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cygwin provides the POSIX system calls and environment, and is similar to Linux because Linux also confirms to POSIX. But some functions like eventfd, epoll, timerfd_create seems to be never implemented in Cygwin because they are not POSIX standard.
Anyway, I agree your method will simplify this patch and I will modify if others has no opposing opinion, although there was similar opposing discussions for compiler. swift #2351

@tinysun212
Copy link
Contributor Author

@parkera, I changed definitions for Cygwin, (DEPLOYMENT_TARGET_CYGWIN, TARGET_OS_CYGWIN) to (DEPLOYMENT_TARGET_LINUX, TARGET_OS_LINUX, TARGET_OS_CYGWIN) as you suggested.

@mominul
Copy link

mominul commented Aug 12, 2016

ping @parkera

@tinysun212
Copy link
Contributor Author

@parkera, I think the requested changes are applied.

@parkera
Copy link
Member

parkera commented Aug 15, 2016

Thanks - we'll take a look at this in the post 3.0 timeframe.

@tinysun212 tinysun212 force-pushed the pr-foundation-cygwin-1 branch 2 times, most recently from 0f7b9e4 to 45d2111 Compare August 19, 2016 19:35
@parkera
Copy link
Member

parkera commented Sep 28, 2016

We should see about merging this now. @tinysun212 can you rebase against master?

This is the initial porting.

IS_CYGWIN might be changed to some other macro function.

A simple function like below code is working in Cygwin.

---
import Foundation
let swifty = NSURLComponents(string: "https://swift.org")!
print("\(swifty.host!)")
---
@tinysun212
Copy link
Contributor Author

@parkera, I rebased and squashed to one commit.

@parkera
Copy link
Member

parkera commented Sep 29, 2016

@swift-ci please test

@parkera
Copy link
Member

parkera commented Oct 6, 2016

@swift-ci please test and merge

@parkera
Copy link
Member

parkera commented Oct 6, 2016

Don't know why the CI won't kick this off, but it passed before so I don't see what the problem would be now. Merging manually.

@parkera parkera merged commit d015466 into apple:master Oct 6, 2016
@tinysun212
Copy link
Contributor Author

Thanks for your review and merging.

dlmarquis added a commit to dlmarquis/Rainbow that referenced this pull request May 16, 2018
kennyaustin7 added a commit to kennyaustin7/Swift-Rainbow-Project that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants