Skip to content

Windows Port #16

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
May 15, 2019
Merged

Windows Port #16

merged 1 commit into from
May 15, 2019

Conversation

gmittert
Copy link
Contributor

This allows IndexStoreDB to build on Windows.

Once the other PRs go in, this enables compilation on Windows. I have some CMake locally which I've been using to build this, but it should work just as well with SwiftPM when that is ready on Windows.

@gmittert
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

Instead of creating a new header/cpp for this, let's inline these implementations. If we someday need to use them in more places we can expose them, but under more idiomatic API names (e.g. getCanonicalPath, not realpath).

@gmittert gmittert force-pushed the WinBuild branch 2 times, most recently from 784d559 to 7031ee9 Compare May 13, 2019 23:39
@gmittert
Copy link
Contributor Author

I've removed the CrossPlatform.[h/cpp] and instead inlined the changes.

@swift-ci please test

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

I left some comments on the canonical path implementation, but actually: can we just use llvm's sys::fs::real_path?

@gmittert gmittert force-pushed the WinBuild branch 3 times, most recently from 8c0be80 to 07e6fb5 Compare May 14, 2019 01:30
@gmittert
Copy link
Contributor Author

I left some comments on the canonical path implementation, but actually: can we just use llvm's sys::fs::real_path?

Ugh, that was really leaky. I've changed it to use llvm real_path. Like the Unix realpath, if PathBuf is NULL, it'll allocate memory and the target of the stringref would have to be freed. Thoughts on just having it return a std::string? I believe it's only ever used on Path.cpp:86.

@benlangmuir
Copy link
Contributor

Thoughts on just having it return a std::string? I believe it's only ever used on Path.cpp:86.

Ah, I meant why not replace this whole function with a call to llvm::sys::fs::real_path? Instead of passing in a PathBuf char array we can use a SmallString<PATH_MAX>. It will have an extra string copy compared to the current implementation on macOS/Linux, but won't have to heap allocate for any platform.

This allows IndexStoreDB to build on Windows.
@gmittert
Copy link
Contributor Author

Ah, I meant why not replace this whole function with a call to llvm::sys::fs::real_path? Instead of passing in a PathBuf char array we can use a SmallString<PATH_MAX>. It will have an extra string copy compared to the current implementation on macOS/Linux, but won't have to heap allocate for any platform.

Oh I see, yes, that makes much more sense in that context.

@swift-ci please test

@benlangmuir
Copy link
Contributor

Not sure where the PR test status went, but it's still running apparently https://ci.swift.org/job/swift-indexstore-db-PR-macOS/24/ https://ci.swift.org/job/swift-indexstore-db-PR-Linux/25/

@benlangmuir benlangmuir merged commit b3b4bba into swiftlang:master May 15, 2019
@gmittert gmittert deleted the WinBuild branch August 13, 2019 20:41
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.

2 participants