@@ -50,14 +50,9 @@ To learn more about the programming language, visit [swift.org](https://swift.or
50
50
51
51
- [ Contributing to Swift] ( #contributing-to-swift )
52
52
- [ Getting Started] ( #getting-started )
53
- - [ System Requirements] ( #system-requirements )
54
- - [ Getting Sources for Swift and Related Projects] ( #getting-sources-for-swift-and-related-projects )
55
- - [ Building Swift] ( #building-swift )
56
53
- [ Swift Toolchains] ( #swift-toolchains )
57
54
- [ Build Failures] ( #build-failures )
58
- - [ Testing Swift] ( #testing-swift )
59
55
- [ Learning More] ( #learning-more )
60
- - [ Build Dependencies] ( #build-dependencies )
61
56
62
57
## Contributing to Swift
63
58
@@ -77,206 +72,15 @@ well. For more, see the [Code of Conduct](https://swift.org/community/#code-of-c
77
72
78
73
## Getting Started
79
74
80
- These instructions give the most direct path to a working Swift development
81
- environment. To build from source you will need about 2 GB of disk space for the
82
- source code and up to 70 GB of disk space for the build artifacts with full
83
- debugging. Depending on your machine, a clean build can take a few minutes to
84
- several hours. Naturally, incremental builds are much faster.
75
+ If you are interested in:
76
+ - Contributing fixes and features to the compiler: See our
77
+ [ How to Submit Your First Pull Request guide] ( /docs/HowToGuides/FirstPullRequest.md ) .
78
+ - Building the compiler as a one-off: See our [ Getting Started guide] [ ] .
79
+ - Building a toolchain as a one-off: Follow the [ Getting Started guide] [ ]
80
+ up until the "Building the project" section. After that, follow the
81
+ instructions in the [ Swift Toolchains] ( #swift-toolchains ) section below.
85
82
86
- Once you are able to build things successfully and have a compile-test-debug
87
- loop going, check out the [ development tips] ( docs/DevelopmentTips.md ) for
88
- better productivity while working on the compiler.
89
-
90
- You can also skim [ docs/README.md] ( /docs/README.md ) to understand what
91
- high-level documentation is available.
92
-
93
- ### System Requirements
94
-
95
- macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are currently
96
- supported as host development operating systems.
97
-
98
- Please make sure you use Python 2.x. Python 3.x is not supported currently.
99
-
100
- #### macOS
101
-
102
- To build for macOS, you need [ Xcode 12 beta 3] ( https://developer.apple.com/xcode/resources/ ) .
103
- The required version of Xcode changes frequently, and is often a beta release.
104
- Check this document or the host information on < https://ci.swift.org > for the
105
- current required version.
106
-
107
- Swift's build tooling is meant to support spaces in the paths passed to them,
108
- but using spaces sometimes tickles bugs in Swift's build scripts or the tools
109
- they rely on. For example, [ SR-13441] ( https://bugs.swift.org/browse/SR-13441 )
110
- is caused by a space in the Xcode path used on macOS. If you see Swift's build
111
- tooling misbehave due to a space in a path, please
112
- [ report the bug on the Swift bug tracker] ( https://swift.org/contributing/#reporting-bugs )
113
- and then change the path to work around it.
114
-
115
- You will also need [ CMake] ( https://cmake.org ) and [ Ninja] ( https://ninja-build.org ) ,
116
- which can be installed via a package manager:
117
-
118
- ** [ Homebrew] ( https://brew.sh/ ) **
119
-
120
- brew install cmake ninja
121
-
122
- You can also use [ homebrew-bundle] ( https://github.com/Homebrew/homebrew-bundle )
123
- from the root of this repository's working directory to install all of these
124
- dependencies:
125
-
126
- brew bundle
127
-
128
- ** [ MacPorts] ( https://macports.org ) **
129
-
130
- sudo port install cmake ninja
131
-
132
- Instructions for installing CMake and Ninja directly can be found [ below] ( #build-dependencies ) .
133
-
134
- #### Linux
135
-
136
- For Ubuntu, you'll need the following development dependencies:
137
-
138
- ```
139
- sudo apt-get install \
140
- clang \
141
- cmake \
142
- git \
143
- icu-devtools \
144
- libcurl4-openssl-dev \
145
- libedit-dev \
146
- libicu-dev \
147
- libncurses5-dev \
148
- libpython-dev \
149
- libsqlite3-dev \
150
- libxml2-dev \
151
- ninja-build \
152
- pkg-config \
153
- python \
154
- python-six \
155
- rsync \
156
- swig \
157
- systemtap-sdt-dev \
158
- tzdata \
159
- uuid-dev
160
- ```
161
-
162
- ** Note:** LLDB currently requires at least ` swig-1.3.40 ` but will successfully build
163
- with version 2 shipped with Ubuntu.
164
-
165
- ** Note:** For Ubuntu 20.04, use ` libpython2-dev ` in place of the libpython-dev package above.
166
-
167
- ### Getting Sources for Swift and Related Projects
168
-
169
- First create a directory for all of the Swift sources:
170
-
171
- mkdir swift-source
172
- cd swift-source
173
-
174
- ** Note:** This is important since update-checkout (see below) checks out
175
- repositories next to the Swift source directory. This means that if one clones
176
- Swift and has other unrelated repositories, update-checkout may not clone those
177
- repositories and will update them instead. Be aware that ` update-checkout `
178
- currently does not support paths with non-ASCII characters. If such characters
179
- are present in the path to ` swift-source ` , ` update-checkout ` will fail.
180
-
181
- ** Via HTTPS** For those checking out sources as read-only, HTTPS works best:
182
-
183
- git clone https://github.com/apple/swift.git
184
- ./swift/utils/update-checkout --clone
185
-
186
- ** Via SSH** For those who plan on regularly making direct commits,
187
- cloning over SSH may provide a better experience (which requires
188
- [ uploading SSH keys to GitHub] ( https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/ ) ):
189
-
190
- git clone [email protected] :apple/swift.git
191
- ./swift/utils/update-checkout --clone-with-ssh
192
-
193
- ### Building Swift
194
-
195
- The ` build-script ` is a high-level build automation script that supports basic
196
- options such as building a Swift-compatible LLDB, building the Swift Package
197
- Manager, building for various platforms, running tests after builds, and more.
198
-
199
- There are two primary build systems to use: Xcode and Ninja. The Xcode build
200
- system allows you to work in Xcode, but Ninja is a bit faster and supports
201
- more environments.
202
-
203
- First, make sure that you're in the swift directory:
204
-
205
- cd swift
206
-
207
- To build using Ninja, run:
208
-
209
- utils/build-script --release-debuginfo
210
-
211
- When developing Swift, it helps to build what you're working on in a debug
212
- configuration while building the rest of the project with optimizations. Below
213
- are some examples of using debug variants:
214
-
215
- utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debug
216
- utils/build-script --release-debuginfo --debug-swift-stdlib # Standard library built in debug
217
- utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
218
-
219
- Limiting the amount of debug code in the compiler has a very large impact on
220
- Swift compile times, and in turn the test execution time. If you want to build
221
- the entire project in debug, you can run:
222
-
223
- utils/build-script --debug
224
-
225
- For documentation of all available arguments, as well as additional usage
226
- information, see the inline help:
227
-
228
- utils/build-script -h
229
-
230
- #### Xcode
231
-
232
- To build using Xcode, specify the ` --xcode ` argument on any of the above commands.
233
- Xcode can be used to edit the Swift source code, but it is not currently
234
- fully supported as a build environment for SDKs other than macOS. The generated
235
- Xcode project does not integrate with the test runner, but the tests can be run
236
- with the 'check-swift' target.
237
-
238
- #### Build Products
239
-
240
- All of the build products are placed in ` swift-source/build/${TOOL}-${MODE}/${PRODUCT}-${PLATFORM}/ ` .
241
- If macOS Swift with Ninja in DebugAssert mode was built, all of the products
242
- would be in ` swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/ ` . It
243
- helps to save this directory as an environment variable for future use.
244
-
245
- export SWIFT_BUILD_DIR="~/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64"
246
-
247
- #### Ninja
248
-
249
- Once the first build has completed, Ninja can perform fast incremental builds of
250
- various products. These incremental builds are a big timesaver when developing
251
- and debugging.
252
-
253
- cd ${SWIFT_BUILD_DIR}
254
- ninja swift-frontend
255
-
256
- This will build the Swift compiler, but will not rebuild the standard library or
257
- any other target. Building the ` swift-stdlib ` target as an additional layer of
258
- testing from time to time is also a good idea. To build just the standard
259
- library, run:
260
-
261
- ninja swift-stdlib
262
-
263
- It is always a good idea to do a full build after using ` update-checkout ` .
264
-
265
- #### Using Xcode
266
-
267
- To open the Swift project in Xcode, open ` ${SWIFT_BUILD_DIR}/Swift.xcodeproj ` .
268
- It will auto-create a * lot* of schemes for all of the available targets. A
269
- common debug flow would involve:
270
-
271
- - Select the 'swift-frontend' scheme.
272
- - Pull up the scheme editor (⌘⇧<).
273
- - Select the 'Arguments' tab and click the '+'.
274
- - Add the command line options.
275
- - Close the scheme editor.
276
- - Build and run.
277
-
278
- Another option is to change the scheme to "Wait for executable to be launched",
279
- then run the build product in Terminal.
83
+ [ Getting Started guide ] : /docs/HowToGuides/GettingStarted.md
280
84
281
85
### Swift Toolchains
282
86
@@ -335,26 +139,24 @@ compiler crashes.
335
139
336
140
### Build Failures
337
141
338
- Make sure you are using the [ correct release] ( #macos ) of Xcode.
142
+ Try the suggestions in
143
+ [ Troubleshooting build issues] ( /docs/HowToGuides/GettingStarted.md#troubleshooting-build-issues ) .
144
+
145
+ Make sure you are using the
146
+ [ correct release] ( /docs/HowToGuides/GettingStared.md#installing-dependencies )
147
+ of Xcode.
339
148
340
149
If you have changed Xcode versions but still encounter errors that appear to
341
150
be related to the Xcode version, try passing ` --clean ` to ` build-script ` .
342
151
343
152
When a new version of Xcode is released, you can update your build without
344
153
recompiling the entire project by passing the ` --reconfigure ` option.
345
154
346
- Make sure all repositories are up to date with the ` update-checkout ` command
347
- described above.
348
-
349
- ## Testing Swift
350
-
351
- See [ docs/Testing.md] ( docs/Testing.md ) , in particular the section on [ lit.py] ( docs/Testing.md#using-litpy ) .
352
-
353
155
## Learning More
354
156
355
- Be sure to look through the [ docs ] ( https://github.com/apple/swift/tree/master/docs )
356
- directory for more information about the compiler . In particular, the documents
357
- titled [ Debugging the Swift Compiler] ( docs/DebuggingTheCompiler.md ) and
157
+ Be sure to look at the [ documentation index ] ( /docs/README.md ) for a bird's eye
158
+ view of the available documentation . In particular, the documents titled
159
+ [ Debugging the Swift Compiler] ( docs/DebuggingTheCompiler.md ) and
358
160
[ Continuous Integration for Swift] ( docs/ContinuousIntegration.md ) are very
359
161
helpful to understand before submitting your first PR.
360
162
@@ -378,41 +180,3 @@ Another source of documentation is the standard library itself, located in
378
180
` stdlib ` . Much of the language is actually implemented in the library
379
181
(including ` Int ` ), and the standard library gives some examples of what can be
380
182
expressed today.
381
-
382
- ## Build Dependencies
383
-
384
- ### CMake
385
- [ CMake] ( https://cmake.org ) is the core infrastructure used to configure builds of
386
- Swift and its companion projects; at least version 3.16.5 is required.
387
-
388
- On macOS, you can download the [ CMake Binary Distribution] ( https://cmake.org/download ) ,
389
- bundled as an application, copy it to ` /Applications ` , and add the embedded
390
- command line tools to your ` PATH ` :
391
-
392
- export PATH=/Applications/CMake.app/Contents/bin:$PATH
393
-
394
- On Linux, if you have not already installed Swift's [ development
395
- dependencies] ( #linux ) , you can download and install the CMake
396
- package separately using the following command:
397
-
398
- sudo apt-get install cmake
399
-
400
-
401
- ### Ninja
402
- [ Ninja] ( https://ninja-build.org ) is the current recommended build system
403
- for building Swift and is the default configuration generated by CMake. [ Pre-built
404
- packages] ( https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages )
405
- are available for macOS and Linux distributions. You can also clone Ninja
406
- next to the other projects and it will be bootstrapped automatically:
407
-
408
- ** Via HTTPS**
409
-
410
- git clone https://github.com/ninja-build/ninja.git && cd ninja
411
- git checkout release
412
- cat README
413
-
414
- ** Via SSH**
415
-
416
- git clone [email protected] :ninja-build/ninja.git && cd ninja
417
- git checkout release
418
- cat README
0 commit comments