Skip to content

Validation of package products should check that a library product doesn't try to include executable targets #5625

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

Conversation

abertelrud
Copy link
Contributor

Currently a library product that includes an executable target in its targets array only results in a warning. This was the best that could be done before executableTarget was introduced, since further checking was needed to see if a target was a library or executable target. Since we have explicit types now, we should promote this to an error since people are running into it and it's not clear what the problem is.

This check is limited to tools version 5.7 or later. This change includes a new test fixture and unit test.

rdar://95782540

@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud self-assigned this Jun 24, 2022
@@ -56,6 +56,10 @@ extension Basics.Diagnostic {
.error("system library product \(product) shouldn't have a type and contain only one target")
}

static func libraryProductWithExectuableTarget(product: String) -> Self {
.error("library product '\(product)' should not contain an executable target")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the message contain the name(s) of the executable targets? Would make it easier for folks to resolve the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

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 was trying to match the existing style but can add the target names to some of the other messages here that don't have it.

@abertelrud abertelrud added the WIP Work in progress label Jun 24, 2022
…esn't try to include executable targets

Currently a library product that includes an executable target in its `targets` array only results in a warning.  This was the best that could be done before `executableTarget` was introduced, since further checking was needed to see if a `target` was a library or executable target.  Since we have explicit types now, we should promote this to an error since people are running into it and it's not clear what the problem is.

This check is limited to tools version 5.7 or later.  This change includes a new test fixture and unit test.

rdar://95782540
@abertelrud abertelrud force-pushed the eng/95782540-better-executable-checking branch from 1ea317b to 64834c5 Compare June 25, 2022 16:46
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud
Copy link
Contributor Author

Added the target names to this new message. We can go back and add to the existing messages in a separate PR.

@abertelrud abertelrud removed the WIP Work in progress label Jun 25, 2022
@abertelrud abertelrud merged commit 5bd3355 into swiftlang:main Jun 27, 2022
@abertelrud abertelrud deleted the eng/95782540-better-executable-checking branch June 27, 2022 05:35
abertelrud added a commit to abertelrud/swift-package-manager that referenced this pull request Jun 27, 2022
…uct doesn't try to include executable targets (swiftlang#5625)

Currently a library product that includes an executable target in its `targets` array only results in a warning.  This was the best that could be done before `executableTarget` was introduced, since further checking was needed to see if a `target` was a library or executable target.  Since we have explicit types now, we should promote this to an error since people are running into it and it's not clear what the problem is.

This check is limited to tools version 5.7 or later.  This change includes a new test fixture and unit test.

rdar://95782540
(cherry picked from commit 5bd3355)
abertelrud added a commit that referenced this pull request Jun 27, 2022
…uct doesn't try to include executable targets (#5625) (#5629)

Currently a library product that includes an executable target in its `targets` array only results in a warning.  This was the best that could be done before `executableTarget` was introduced, since further checking was needed to see if a `target` was a library or executable target.  Since we have explicit types now, we should promote this to an error since people are running into it and it's not clear what the problem is.

This check is limited to tools version 5.7 or later.  This change includes a new test fixture and unit test.

rdar://95782540
(cherry picked from commit 5bd3355)
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