Skip to content

Reference swift-syntax from CodeGeneration using path instead of HEAD checkout #1897

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
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CodeGeneration/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ let package = Package(
.executable(name: "generate-swiftsyntax", targets: ["generate-swiftsyntax"])
],
dependencies: [
.package(url: "..", revision: "HEAD")
// This directory is a standalone package that uses swift-syntax from the
// outer directory.
// If you are making significant changs to `CodeGeneration` locally and want
// to avoid breaking the build of `CodeGeneration` itself by generating new
// files in the parent swift-syntax package, it is encouraged to change the
// dependency to the following. That way `CodeGeneration` has its own
// checkout of swift-syntax that is unaffected by the newly generated files.
// Be sure to revert the change before committing your changes.
//
// .package(url: "https://github.com/apple/swift-syntax", branch: "main")
.package(path: "..")
],
targets: [
.executableTarget(
Expand Down
12 changes: 10 additions & 2 deletions CodeGeneration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ This directory contains file to generate source code that is part of the SwiftSy

Some source code inside SwiftSyntax is generated using [SwiftSyntaxBuilder](../Sources/SwiftSyntaxBuilder), a Swift library whose purpose is to generate Swift code using Swift itself. This kind of code generation is performed by the Swift package defined in this directory.

This directory is a standalone package that uses HEAD of the current branch. This guarantees that when `generate-swiftsyntax` is run, it can't break its own build when run multiple times without committing.
This means that `CodeGeneration` will build against your latest local commit of SwiftSyntax. If you are making changes to `SwiftSyntax` that affect how code is being generated, commit your SwiftSyntax changes (pushing is not necessary) and re-generate files afterwards.
This directory is a standalone package that uses swift-syntax from the outer directory.
If you are making significant changs to `CodeGeneration` locally and want to avoid breaking the build of `CodeGeneration` itself by generating new files in the parent swift-syntax package, it is encouraged to change the dependency from
```swift
.package(path: "..")
```
to
```swift
.package(url: "https://github.com/apple/swift-syntax", branch: "main")
```
That way `CodeGeneration` has its own checkout of swift-syntax that is unaffected by the newly generated files. Be sure to revert the change before committing your changes.

To re-generate the files after changing `CodeGeneration` run the `generate-swiftsyntax`
target of `CodeGeneration` and pass `path/to/swift-syntax/Sources` as the argument.
Expand Down