Skip to content

Fix a SwiftPM 5.2 regression that cause it to try to compile unknown files in pre-5.3 manifests #2708

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

Conversation

abertelrud
Copy link
Contributor

SwiftPM 5.2 introduced a regression that caused a semantic change in how package manifests declaring a tools version earlier than 5.3 were parsed. Specifically, files with an unknown source type are not ignored, as they were in SwiftPM 5.1.x and earlier. This leads to issues such as the one reported here: https://swiftpm.slack.com/archives/C14QU6CUU/p1587442104122300

…how package manifests declaring a tools version earlier than 5.3 were parsed. Specifically, files with an unknown source type are not ignored, as they were in SwiftPM 5.1.x and earlier. This leads to issues such as the one reported here: https://swiftpm.slack.com/archives/C14QU6CUU/p1587442104122300
@abertelrud
Copy link
Contributor Author

@swift-ci smoke test

@@ -1659,6 +1659,30 @@ class PackageBuilderTests: XCTestCase {
}
}

func testUnknownSourceFilesUnderDeclaredSourcesIgnoredInV5_2Manifest() throws {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also write a unit test for 5.3 or do we already cover that using some other test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's already covered, but maybe a more targeted one is a good idea.

Copy link
Contributor Author

@abertelrud abertelrud Apr 23, 2020

Choose a reason for hiding this comment

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

I've added a more targeted test. I'm not sure that SwiftPM is doing the right thing in the case of missing rules for a 5.3 manifest, though... it doesn't seem logical to try to compile files with unknown suffixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a separate issue, and shouldn't block this fix, but something to discuss.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that does seem to be the intentional 5.3 semantics in the source code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is discussed in the "Rules for determining resource files" section of the proposal, but perhaps not in sufficient detail. There were many iterations on the proposed semantics, but I thought where we ended up is that, while unambiguous types of files such as .metal, .storyboard, .xcassets, etc should be treated as resources, any other types would need to be specified as resources. So this should result in an error requiring the user to either specify it as excluded or as a resource.

It sounds as if this needs to be clarified in a follow-on proposal, and the whole question of how to select rules for input files is of course related to the question of how to extend those rules for custom types (which is clearly beyond the scope of just clarifying the behavior here).

As things stand, what will happen if you mix in an unknown type with known compilable types (such as .c, .swift, etc) in 5.3 is that you'll get an error saying that multi-language targets aren't supported. That's not ideal, but it's not a silent issue. It's only in the case of an entire target full of unknown types of the same kind that it will try to compile them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we comfortable with the fix for the regression, and taking the question of 5.3 behavior as a follow-up discussion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've been doing some more local testing of this, and will merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you file a JIRA for tracking the issue for 5.3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

…le in 5.3 manifests (there would still be a later error about mismatched languages in a single target.
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud requested a review from hartbit April 23, 2020 04:16
@abertelrud abertelrud merged commit 3f63a2d into swiftlang:master Apr 23, 2020
@abertelrud abertelrud deleted the 61061140-unknown-files-under-declared-source-directories-are-not-ignored-in-pre-5.3-manifests branch April 23, 2020 18:55
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