Skip to content

Relative paths fix, Xcode generation at non-root path fix #193

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
Mar 14, 2016
Merged

Relative paths fix, Xcode generation at non-root path fix #193

merged 1 commit into from
Mar 14, 2016

Conversation

czechboy0
Copy link
Member

Added support for properly creating relative paths even when the pivot isn't a full prefix of the path. Also fixed Xcode project generation at non-root path.

Properly finishes #188, together with #189.

…t isn't a full prefix of the path. Also fixed Xcode project generation at non-root path.
@mxcl
Copy link
Contributor

mxcl commented Mar 13, 2016

Can you describe the bug this fixes?

@czechboy0
Copy link
Member Author

Sure. Previously the paths of source files in the generated projects were described relative to the package root (repo root), meaning they were all e.g. Sources/Build/build.swift. This worked fine assuming your generated Xcode project sits at the package root, as is the default.

With my change in #188, the project can be generated in a custom location, e.g. in ./XcodeProject/MyProject.xcodeproj, however then the path Sources/Build/build.swift doesn't point to an existing file, because there's no folder Sources in ./XcodeProject. So the path now needs to be ../Sources/Build/build.swift, relative path from the project to the source file.

This is why now instead of package.path we're using the Xcode project's path as the new root, because the path of every file in the Xcode project needs to be described relative to that project, not relative to the package root. That's why I'm passing in the Xcode project path and using that as the root.

The fixes in Utility's Path class are necessary to allow for path creation that contains optional .. components. Previously this wasn't supported, so if you tried to get a relative path from /A/B/C to /A/B/D, it didn't work. Now the right thing is generated: ../D.

Does that make sense? I tested generating Xcode projects at custom locations and the files or now properly referenced (they weren't in #188, that's my bad for not properly verifying the project worked).

@mxcl
Copy link
Contributor

mxcl commented Mar 13, 2016

Great, thanks for the thorough explanation.

I was worried because I know we don't handle all the correct situations for relative paths, like for example /b/c relative to "../d", and I worry our code has bugs because of this.

@mxcl
Copy link
Contributor

mxcl commented Mar 13, 2016

@swift-ci Please test

@czechboy0
Copy link
Member Author

Hopefully not. I added tests for this new functionality of the relative path resolution and in separate PRs I'll start adding more tests for the utility classes in general, I feel like we should increase the test coverage there. 👍

@mxcl
Copy link
Contributor

mxcl commented Mar 13, 2016

I feel like we should increase the test coverage there.

Oh, that would be wonderful.

mxcl added a commit that referenced this pull request Mar 14, 2016
Relative paths fix, Xcode generation at non-root path fix
@mxcl mxcl merged commit bd502ab into swiftlang:master Mar 14, 2016
aciidgh pushed a commit to aciidgh/swift-package-manager that referenced this pull request Jan 11, 2019
…cancellation

[Core] Fix a race condition in task cancellation.
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