Skip to content

Commit 4ed581b

Browse files
committed
[WindowsBuild] Restructure preparation steps
1 parent 7b2bfbc commit 4ed581b

File tree

1 file changed

+35
-39
lines changed

1 file changed

+35
-39
lines changed

docs/WindowsBuild.md

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
Visual Studio 2017 or newer is needed to build Swift on Windows, while VS2019 is recommended and currently used for CI. The free Community edition is sufficient to build Swift, and we're assuming host and target to be both x64.
44

5-
The commands below (with the exception of installing Visual Studio) must be entered in the **x64 Native Tools Command Prompt for VS2019** (or VS2017, VS2022 depending on the Visual Studio that you are using) in the Start Menu. This sets environment variables to select the correct target platform.
5+
The commands below (with the exception of installing Visual Studio) must be entered in the **x64 Native Tools Command Prompt for VS2019** (or VS2017, VS2022 depending on the Visual Studio that you are using) in the Start Menu. This sets environment variables to locate tools and resources for the correct target platform.
66

77
> **NOTE:** This guide is intended for toolchain developers who wants to develop or build Swift on their own machine. For building and packaging a standard toolchain, please refer to [`build-windows-toolchain.bat`](../utils/build-windows-toolchain.bat).
88
9-
## Install dependencies
9+
## Enable Developer Mode
1010

11-
### Visual Studio
11+
From **Settings** app, go to *Update & Security*. In the *For developers* tab, set *Install apps from any source, including loose files* to On. This is required to enable the creation of symbolic links.
1212

13-
An easy way to get most of the tools to build Swift is using the [Visual Studio installer](https://www.visualstudio.com/downloads/). This command installs all needed Visual Studio components as well as Python, Git, CMake and Ninja:
13+
## Install build tools and SDK
1414

15-
```
15+
An easy way to get the tools to build Swift is using the [Visual Studio installer](https://www.visualstudio.com/downloads/). The following command installs all needed Visual Studio components as well as Python, Git, CMake and Ninja:
16+
17+
```cmd
1618
curl.exe -sOL https://aka.ms/vs/16/release/vs_community.exe
1719
vs_community ^
1820
--add Component.CPython3.x64 ^
@@ -28,13 +30,9 @@ del /q vs_community.exe
2830
> - replace `https://aka.ms/vs/16/release/vs_community.exe` with `https://aka.ms/vs/17/release/vs_community.exe`
2931
> - replace `Component.CPython3.x64` with `Component.CPython39.x64`
3032
31-
If you prefer you can install everything by hand, but make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The components listed above are required.
33+
> **NOTE:** The following [link](https://docs.microsoft.com/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019) helps in finding the component name given its ID for Visual Studio 2019. For anyone using VS installer in GUI, please check it out.
3234
33-
The following [link](https://docs.microsoft.com/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019) helps in finding the component name given its ID for Visual Studio 2019.
34-
35-
### Python
36-
37-
The command above already installs Python 3. Alternatively, in the Visual Studio installation program, under *Individual Components*, install *Python 3 64 bits (3.x.x)*.
35+
### Configure Python
3836

3937
If you are building a debug version of Swift, you should also install the Python debug binaries.
4038

@@ -44,45 +42,43 @@ If you are building a debug version of Swift, you should also install the Python
4442
4. Select *Download debug binaries (requires VS 2015 or later)*
4543
5. Click *Install*
4644

47-
## Enable Developer Mode
48-
49-
From the settings application, go to *Update & Security*. In the *For developers* tab, select *Developer Mode* for *Use Developer Features*. This is required to enable the creation of symbolic links.
45+
### Set up `vcpkg`
5046

51-
## Clone the repositories
52-
53-
> **NOTE:** This guide assumes your sources live at the root of `S:`. If your sources live elsewhere, you can create a substitution for this:
54-
>
55-
> subst S: <path to sources>
47+
This guide uses `vcpkg` for pulling in external dependencies, including ICU, libcurl, libxml2, SQLite 3 and zlib.
5648

57-
First, clone `apple/swift` (this repository) with Git:
49+
All you have to do is to clone and bootstrap `vcpkg`:
5850

5951
```cmd
60-
git clone -c core.autocrlf=input -c core.symlinks=true https://github.com/apple/swift S:\swift
52+
git clone https://github.com/microsoft/vcpkg S:\vcpkg
53+
S:\vcpkg\bootstrap-vcpkg.bat
6154
```
6255

63-
You'll be able to clone and check out the rest of Swift source repositories with `update-checkout` tool:
56+
> **NOTE:** By default, the dependencies will be downloaded and built on demand. Optionally, you can pre-build the dependencies to speed up configuration:
57+
>
58+
> S:\vcpkg\vcpkg install curl icu libxml2 sqlite3 zlib --triplet=x64-windows
6459
65-
```cmd
66-
S:\swift\utils\update-checkout.cmd --clone
67-
```
60+
## Clone the source repositories
6861

69-
## Set up `vcpkg`
62+
This guide assumes your sources live at the root of `S:`. As long as drive letter `S:` is not assigned, you can create a substitution to map your source directory:
7063

71-
This guide uses `vcpkg` for pulling in external dependencies, including ICU, libcurl, libxml2, SQLite 3 and zlib.
64+
```cmd
65+
subst S: <path to source root>
66+
```
7267

73-
All you have to do is to clone and bootstrap `vcpkg`:
68+
First, clone `apple/swift` (this repository) with Git:
7469

7570
```cmd
76-
git clone https://github.com/microsoft/vcpkg S:\vcpkg
77-
S:\vcpkg\bootstrap-vcpkg.bat
71+
git clone -c core.autocrlf=input -c core.symlinks=true https://github.com/apple/swift S:\swift
7872
```
7973

80-
By default, the dependencies will be downloaded and built on demand. Optionally, you can prebuild the dependencies in advance:
74+
You'll be able to clone and check out the rest of Swift source repositories with `update-checkout` tool:
8175

8276
```cmd
83-
S:\vcpkg\vcpkg install curl icu libxml2 sqlite3 zlib --triplet=x64-windows
77+
S:\swift\utils\update-checkout.cmd --clone --skip-repository swift
8478
```
8579

80+
> **NOTE:** You can use forked versions of Swift source repositories by manually placing them into `S:\<repo-name>` and appending their names to the `--skip-repository` option of `update-checkout`. Don't forget to clone them with `-c core.autocrlf=input -c core.symlinks=true` and the correct repository name.
81+
8682
## Set up Visual Studio integration (re-run on Visual Studio upgrades)
8783

8884
Set up the `ucrt`, `visualc`, and `WinSDK` modules by:
@@ -113,9 +109,9 @@ cmake -B S:\b\1 ^
113109
-C S:\swift\cmake\caches\Windows-x86_64.cmake ^
114110
-D CMAKE_BUILD_TYPE=Release ^
115111
-D CMAKE_INSTALL_PREFIX=C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr ^
116-
-D CMAKE_C_COMPILER=cl ^
112+
-D CMAKE_C_COMPILER=cl.exe ^
117113
-D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy /source-charset:utf-8 /execution-charset:utf-8" ^
118-
-D CMAKE_CXX_COMPILER=cl ^
114+
-D CMAKE_CXX_COMPILER=cl.exe ^
119115
-D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy /utf-8" ^
120116
-D CMAKE_MT=mt ^
121117
-D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^
@@ -132,7 +128,7 @@ cmake --build S:\b\1
132128
cmake --build S:\b\1 --target install
133129
```
134130

135-
## Build a complete toolchain for development
131+
## Build for development
136132

137133
The following guide will get you through the building process of a complete Swift debug toolchain.
138134

@@ -152,9 +148,9 @@ cmake -B S:\b\1 ^
152148
-D CMAKE_BUILD_TYPE=Release ^
153149
-D CMAKE_INSTALL_PREFIX=S:\b\toolchain\usr ^
154150
155-
-D CMAKE_C_COMPILER=cl ^
151+
-D CMAKE_C_COMPILER=cl.exe ^
156152
-D CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy /source-charset:utf-8 /execution-charset:utf-8" ^
157-
-D CMAKE_CXX_COMPILER=cl ^
153+
-D CMAKE_CXX_COMPILER=cl.exe ^
158154
-D CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy /utf-8" ^
159155
-D CMAKE_MT=mt ^
160156
-D CMAKE_EXE_LINKER_FLAGS="/INCREMENTAL:NO" ^
@@ -192,7 +188,7 @@ path %PATH%;%ProgramFiles%\Git\usr\bin
192188
cmake --build S:\b\1 --target check-swift
193189
```
194190

195-
### Swift Standard Library
191+
### Swift runtime libraries
196192

197193
```cmd
198194
cmake -B S:\b\2 ^
@@ -225,7 +221,7 @@ cmake -B S:\b\2 ^
225221
cmake --build S:\b\2
226222
```
227223

228-
> **NOTE:** Swift Standard Library is also built along with the compiler. This step extracts it into a portable SDK where we will install other runtime libraries.
224+
> **NOTE:** Swift runtime libraries are also built along with the compiler. This step extracts them into a portable SDK where we will install core libraries alongside.
229225
230226
### libdispatch
231227

0 commit comments

Comments
 (0)