Skip to content

Commit 3d53f9d

Browse files
authored
Merge pull request #1546 from kimdv/kimdv/use-local-git-repo-for-code-gen
Use local git package for code gen
2 parents 7f1f40f + 8f6eb73 commit 3d53f9d

File tree

10 files changed

+348
-336
lines changed

10 files changed

+348
-336
lines changed

CodeGeneration/Package.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// swift-tools-version:5.7
22

33
import PackageDescription
4+
import Foundation
45

56
let package = Package(
67
name: "CodeGeneration",
@@ -11,8 +12,7 @@ let package = Package(
1112
.executable(name: "generate-swiftsyntax", targets: ["generate-swiftsyntax"])
1213
],
1314
dependencies: [
14-
.package(url: "https://github.com/apple/swift-syntax.git", revision: "c7087adb193b26f02b59d21cd06d17ec202d1bf5"),
15-
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2"),
15+
.package(url: "..", revision: "HEAD")
1616
],
1717
targets: [
1818
.executableTarget(
@@ -41,3 +41,14 @@ let package = Package(
4141
),
4242
]
4343
)
44+
45+
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
46+
// Building standalone.
47+
package.dependencies += [
48+
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.2")
49+
]
50+
} else {
51+
package.dependencies += [
52+
.package(path: "../../swift-argument-parser")
53+
]
54+
}

CodeGeneration/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ 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 a pinned version of SwiftSyntaxBuilder. It is thus NOT using SwiftSyntaxBuilder of the parent directory. This guarantees that when `generate-swiftsyntax` is run, it can't break its own build.
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.
89

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

Sources/SwiftSyntax/generated/SyntaxCollections.swift

Lines changed: 141 additions & 141 deletions
Large diffs are not rendered by default.

Sources/SwiftSyntax/generated/SyntaxRewriter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6904,8 +6904,8 @@ open class SyntaxRewriter {
69046904
var childIndex = 0
69056905
for (raw, info) in RawSyntaxChildren(syntaxNode) {
69066906
defer {
6907-
childIndex += 1
6908-
}
6907+
childIndex += 1
6908+
}
69096909
guard let child = raw else {
69106910
// Node does not exist. If we are collecting rewritten nodes, we need to
69116911
// collect this one as well, otherwise we can ignore it.

0 commit comments

Comments
 (0)