Skip to content

Move usage of plugins from dependencies to plugins parameter to align with SE-0303 #3312

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
Feb 26, 2021

Conversation

abertelrud
Copy link
Contributor

@abertelrud abertelrud commented Feb 26, 2021

Move the usage of plugins from the dependencies parameter of targets in the package manifest to instead be in a separate plugins parameter.

Despite their similarity to dependencies we want users to consider them differently. This also leaves room to grow in the future, when plugin usage might support parameters, etc. We encode them separately in the manifest JSON, but merge them into regular dependencies to avoid duplicated implementation on the SwiftPM side. This can be changed later without affecting clients. For now it would just mean duplicate code.

Modifications:

  • change PackageDescription API in accordance with proposal (involving the usual unfortunate duplicate of declarations with deprecation of older ones)
  • add PluginUsage type, and plumb it through
  • in PackageBuilder, infer dependencies from plugin usage, and pass through for the remainder of the existing logic
  • for the moment we have a type alias from Target.PackageUsage to Target.Dependency on the internal side (not in the PackageDescription API)

rdar://74663667

@abertelrud abertelrud changed the title Move usage of plugins from dependencies to plugins parameter to align with SE-0303 WIP: Move usage of plugins from dependencies to plugins parameter to align with SE-0303 Feb 26, 2021
@abertelrud abertelrud self-assigned this Feb 26, 2021
@abertelrud abertelrud marked this pull request as draft February 26, 2021 03:08
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud changed the title WIP: Move usage of plugins from dependencies to plugins parameter to align with SE-0303 Move usage of plugins from dependencies to plugins parameter to align with SE-0303 Feb 26, 2021
Move the usage of plugins from the `dependencies` parameter of targets in the package manifest to instead be in a separate `plugins` parameter.

Despite their similarity to dependencies we want users to consider them differently.  This also leaves room to grow in the future, when plugin usage might support parameters, etc.  We encode them separately in the manifest JSON, but merge them into regular dependencies to avoid duplicated implementation on the SwiftPM side.  This can be changed later without affecting clients.  For now it would just mean duplicate code.

rdar://74663667
@abertelrud abertelrud force-pushed the extension-usage-spelling branch from 98eeb00 to 31dba14 Compare February 26, 2021 07:33
@abertelrud abertelrud marked this pull request as ready for review February 26, 2021 07:34
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Feb 26, 2021
successors += pluginUsages.compactMap({
switch $0 {
case .plugin(let name, let package):
return (package == nil) ? potentialModuleMap[name] : nil
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be case-sensitive or case-insensitive?

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 good question — I did the same thing as what's being done earlier for the regular dependencies, so if we make it case-insensitive here, we should change it for regular dependencies too. So that would be a semantic change that I don't think we should make in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should consider such change, but I agree a separate PR makes sense

Copy link
Contributor Author

@abertelrud abertelrud Feb 26, 2021

Choose a reason for hiding this comment

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

Right, making target dependencies case-insensitive seems like a different consideration that should probably be tied to tools version. Regardless, I think that dependencies and plugin usages should be consistent. We can file a tracking JIRA on the case sensitivity.

return .product(Target.ProductReference(name: name, package: package), conditions: [])
}
else {
guard let target = targets[name] else { return nil }
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be case-sensitive or case-insensitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment as the other one.

@abertelrud abertelrud merged commit f73c0c7 into swiftlang:main Feb 26, 2021
@abertelrud abertelrud deleted the extension-usage-spelling branch March 8, 2021 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants