Skip to content

When adding a macro target to a package, create a dependency on swift-syntax #7476

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

DougGregor
Copy link
Member

When editing a package manifest to add a new macro target, also create a package dependency on swift-syntax and import CompilerPluginSupport. We need both so that the macro will build.

…-syntax

When editing a package manifest to add a new macro target, also
create a package dependency on swift-syntax and import
CompilerPluginSupport. We need both so that the macro will build.
@DougGregor
Copy link
Member Author

@swift-ci please test

}

/// Package dependency on the swift-syntax package.
static var swiftSyntax: PackageDependency {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to get the UserToolchain where you need this? Ideally this would use the installedSwiftPMConfiguration property there, InstalledSwiftPMConfiguration.default.swiftSyntaxVersionForMacroTemplate should disappear. The URL could also be added to that JSON file as well (Utilities/config.json).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I can grab it from the command state and thread it through. I've done so in c66eb4f, thanks for the pointer!

…ation

This allows us to pick up the appropriate swift-syntax version from the
host toolchain, rather than using the hard-coded one.
@DougGregor DougGregor force-pushed the manifest-edit-macro-add-swift-syntax-dependency branch from 23ba109 to c66eb4f Compare April 23, 2024 00:38
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test Windows

@DougGregor DougGregor merged commit d30647a into swiftlang:main Apr 23, 2024
@DougGregor DougGregor deleted the manifest-edit-macro-add-swift-syntax-dependency branch April 23, 2024 03:19
DougGregor added a commit to DougGregor/swift-package-manager that referenced this pull request Apr 24, 2024
DougGregor added a commit that referenced this pull request Apr 25, 2024
#7494)

* **Explanation**: Implement package manifest editing commands (`swift
package add-dependency`, `swift package add-target`, `swift package
add-product`) described in
[SE-0301](https://github.com/apple/swift-evolution/blob/main/proposals/0301-package-editing-commands.md),
using swift-syntax under the hood to perform the edits.
* **Original PR**:
#7467,
#7476,
#7477
* **Risk**: Very low. All new code for new commands.
* **Reviewed by**: @ahoppen , @bnbarham , @owenv , @MaxDesiatov 
* **Testing**: New tests.

---------

Co-authored-by: Rintaro Ishizaki <[email protected]>
Co-authored-by: Saleem Abdulrasool <[email protected]>
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
furby-tm pushed a commit to wabiverse/swift-package-manager that referenced this pull request May 15, 2024
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