Skip to content

various hacks for paths on Windows #114

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

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

compnerd
Copy link
Member

This is sufficient for bootstrapping s-p-m on Windows, although the long
term maintainable solution is to migrate towards Swift System.

@compnerd compnerd marked this pull request as draft August 20, 2020 01:51
@compnerd
Copy link
Member Author

CC: @egorzhdan

Copy link
Contributor

@abertelrud abertelrud left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me as short-term workarounds until we can get path support from another package. I am not familiar with the Windows calls, so have looked at this mostly from the perspective of how it would affect other platforms.

One possible nuance to watch out for: storing Windows path separators in the native representation makes sense, but if there's any code that compares the path string to a string it read in from an input file (e.g. manifest) that uses forward separators, that comparison might now fail. In those cases, that code should create two paths and then compare them, so I don't think this change is wrong, but it's just something to keep in mind if there turns out to be fallout on Windows.

@compnerd compnerd marked this pull request as ready for review August 20, 2020 20:00
@compnerd
Copy link
Member Author

@swift-ci please test

}

// FIXME: We should investigate if it would be more efficient to instead
// return a path component iterator that does all its work lazily, moving
// from one path separator to the next on-demand.
//
var components: [String] {
#if os(Windows)
return string.components(separatedBy: "\\").filter { !$0.isEmpty }
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically, this should use PathSkipRootW and then split on \ and /.

This is sufficient for bootstrapping s-p-m on Windows, although the long
term maintainable solution is to migrate towards Swift System.
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Aug 20, 2020

I still dislike this, but this should hopefully unblock the work necessary to support Windows. Discussed offline with @abertelrud and @neonichu about using this as a crutch for the time being to enable us to more rapidly support Windows.

@compnerd compnerd merged commit 2ecf988 into swiftlang:master Aug 20, 2020
@compnerd compnerd deleted the windows-bootstrap branch August 20, 2020 22:46
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.

3 participants