Skip to content

Commit 98f7682

Browse files
authored
Merge pull request #87 from hartbit/build-doc
Improve the documentation for building master
2 parents 08bbf70 + a6b7699 commit 98f7682

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,37 +89,55 @@ the Swift compiler source because we always push gyb-generated files to a tag.
8989
## Contributing
9090

9191
### Building SwiftSyntax from `master`
92+
9293
Since SwiftSyntax relies on definitions in the main Swift repository to generate the layout of the syntax tree using `gyb`, a checkout of [apple/swift](https://github.com/apple/swift) is still required to build `master` of SwiftSyntax.
9394

94-
To build the `master` version of SwiftSyntax, check `swift-syntax` and `swift` out side by side
95+
To build the `master` version of SwiftSyntax, follow the following instructions:
96+
97+
1. Check `swift-syntax` and `swift` out side by side:
98+
9599
```
96100
- (enclosing directory)
97101
- swift
98102
- swift-syntax
99103
```
100104

101-
And run `swift-syntax/build-script.py`. SwiftSyntax is now being built with the Swift compiler installed on the system.
105+
2. Make sure you have a recent [master Swift toolchain](https://swift.org/download/#snapshots) installed.
106+
3. Define the `TOOLCHAINS` environment variable as below to have the `swift` command point inside the toolchain:
107+
108+
```
109+
$ export TOOLCHAINS=swift
110+
```
111+
112+
4. To make sure everything is setup correctly, check the return statement of `xcrun --find swift`. It should point inside the latest installed master toolchain. If it points inside an Xcode toolchain, check that you exported the `TOOLCHAINS` environment variable correctly. If it points inside a version specific toolchain (like Swift 5.0-dev), you'll need to remove that toolchain.
113+
5. Run `swift-syntax/build-script.py`.
114+
115+
If, despite following those instructions, you get compiler errors, the Swift toolchain might be too old to contain recent changes in Swift's SwiftSyntaxParser C library. In that case, you'll have to build the compiler and SwiftSyntax together with the following command:
116+
117+
```
118+
$ swift/utils/build-script --swiftsyntax --swiftpm --llbuild
119+
```
102120

103-
Swift-CI will automatically run the code generation step whenever a new toolchain (development snapshot or release) is published. It should thus almost never be necessary to perform the above build yourself.
121+
Swift-CI will automatically run the code generation step whenever a new toolchain (development snapshot or release) is published. It should thus almost never be necessary to perform the above build yourself.
104122

105123
Afterwards, SwiftPM can also generate an Xcode project to develop SwiftSyntax by running `swift package generate-xcodeproj`.
106124

107-
If you also want to run tests locally, read the section below as testing has additional requirements.
125+
If you also want to run tests locally, read the section below as testing has additional requirements.
108126

109127
### Local Testing
110-
SwiftSyntax uses some test utilities that need to be built as part of the Swift compiler project. To build the most recent version of SwiftSyntax and test it, follow the steps in [swift/README.md](https://github.com/apple/swift/blob/master/README.md) and pass `--llbuild --swiftpm --swiftsyntax` to the build script invocation to build SwiftSyntax and all its dependencies using the current `master` compiler.
128+
SwiftSyntax uses some test utilities that need to be built as part of the Swift compiler project. To build the most recent version of SwiftSyntax and test it, follow the steps in [swift/README.md](https://github.com/apple/swift/blob/master/README.md) and pass `--llbuild --swiftpm --swiftsyntax` to the build script invocation to build SwiftSyntax and all its dependencies using the current `master` compiler.
111129

112-
SwiftSyntax can then be tested using the build script in `apple/swift` by running
130+
SwiftSyntax can then be tested using the build script in `apple/swift` by running
113131
```
114132
swift/utils/build-script --swiftsyntax --swiftpm --llbuild -t --skip-test-cmark --skip-test-swift --skip-test-llbuild --skip-test-swiftpm
115133
```
116-
This command will build SwiftSyntax and all its dependencies, tell the build script to run tests, but skip all tests but the SwiftSyntax tests.
134+
This command will build SwiftSyntax and all its dependencies, tell the build script to run tests, but skip all tests but the SwiftSyntax tests.
117135

118136
Note that it is not currently supported to SwiftSyntax while building the Swift compiler using Xcode.
119137

120138
### CI Testing
121139

122-
Running `@swift-ci Please test` on the main Swift repository will also test the most recent version of SwiftSyntax.
140+
Running `@swift-ci Please test` on the main Swift repository will also test the most recent version of SwiftSyntax.
123141

124142
Testing SwiftSyntax from its own repository is now available by commenting `@swift-ci Please test macOS platform`.
125143

0 commit comments

Comments
 (0)