Skip to content

Commit 9cab487

Browse files
authored
Merge pull request #1897 from ahoppen/ahoppen/path-reference
Reference swift-syntax from CodeGeneration using path instead of HEAD checkout
2 parents 69c9c53 + d9f2f3a commit 9cab487

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

CodeGeneration/Package.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ let package = Package(
1212
.executable(name: "generate-swiftsyntax", targets: ["generate-swiftsyntax"])
1313
],
1414
dependencies: [
15-
.package(url: "..", revision: "HEAD")
15+
// This directory is a standalone package that uses swift-syntax from the
16+
// outer directory.
17+
// If you are making significant changs to `CodeGeneration` locally and want
18+
// to avoid breaking the build of `CodeGeneration` itself by generating new
19+
// files in the parent swift-syntax package, it is encouraged to change the
20+
// dependency to the following. That way `CodeGeneration` has its own
21+
// checkout of swift-syntax that is unaffected by the newly generated files.
22+
// Be sure to revert the change before committing your changes.
23+
//
24+
// .package(url: "https://github.com/apple/swift-syntax", branch: "main")
25+
.package(path: "..")
1626
],
1727
targets: [
1828
.executableTarget(

CodeGeneration/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ This directory contains file to generate source code that is part of the SwiftSy
44

55
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.
66

7-
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.
8-
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.
7+
This directory is a standalone package that uses swift-syntax from the outer directory.
8+
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
9+
```swift
10+
.package(path: "..")
11+
```
12+
to
13+
```swift
14+
.package(url: "https://github.com/apple/swift-syntax", branch: "main")
15+
```
16+
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.
917

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

0 commit comments

Comments
 (0)