Skip to content

Commit a6b7699

Browse files
committed
Improve the documentation for building master
1 parent 5355c79 commit a6b7699

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
@@ -52,37 +52,55 @@ Then, import `SwiftSyntax` in your Swift code.
5252
## Contributing
5353

5454
### Building SwiftSyntax from `master`
55+
5556
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.
5657

57-
To build the `master` version of SwiftSyntax, check `swift-syntax` and `swift` out side by side
58+
To build the `master` version of SwiftSyntax, follow the following instructions:
59+
60+
1. Check `swift-syntax` and `swift` out side by side:
61+
5862
```
5963
- (enclosing directory)
6064
- swift
6165
- swift-syntax
6266
```
6367

64-
And run `swift-syntax/build-script.py`. SwiftSyntax is now being built with the Swift compiler installed on the system.
68+
2. Make sure you have a recent [master Swift toolchain](https://swift.org/download/#snapshots) installed.
69+
3. Define the `TOOLCHAINS` environment variable as below to have the `swift` command point inside the toolchain:
70+
71+
```
72+
$ export TOOLCHAINS=swift
73+
```
74+
75+
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.
76+
5. Run `swift-syntax/build-script.py`.
77+
78+
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:
79+
80+
```
81+
$ swift/utils/build-script --swiftsyntax --swiftpm --llbuild
82+
```
6583

66-
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.
84+
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.
6785

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

70-
If you also want to run tests locally, read the section below as testing has additional requirements.
88+
If you also want to run tests locally, read the section below as testing has additional requirements.
7189

7290
### Local Testing
73-
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.
91+
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.
7492

75-
SwiftSyntax can then be tested using the build script in `apple/swift` by running
93+
SwiftSyntax can then be tested using the build script in `apple/swift` by running
7694
```
7795
swift/utils/build-script --swiftsyntax --swiftpm --llbuild -t --skip-test-cmark --skip-test-swift --skip-test-llbuild --skip-test-swiftpm
7896
```
79-
This command will build SwiftSyntax and all its dependencies, tell the build script to run tests, but skip all tests but the SwiftSyntax tests.
97+
This command will build SwiftSyntax and all its dependencies, tell the build script to run tests, but skip all tests but the SwiftSyntax tests.
8098

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

83101
### CI Testing
84102

85-
Running `@swift-ci Please test` on the main Swift repository will also test the most recent version of SwiftSyntax.
103+
Running `@swift-ci Please test` on the main Swift repository will also test the most recent version of SwiftSyntax.
86104

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

0 commit comments

Comments
 (0)