Skip to content

Commit 8c2854f

Browse files
yostanecompnerd
authored andcommitted
Added more details to "Building Swift on Windows" (#28496)
* Added more details to "Building Swift on Windows"
1 parent b770650 commit 8c2854f

File tree

2 files changed

+38
-15
lines changed

2 files changed

+38
-15
lines changed

docs/WindowsBuild.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
# Building Swift on Windows
22

3-
Visual Studio 2017 or newer is needed to build swift on Windows. The following must take place in the developer command prompt (provided by Visual Studio). This shows up as "x64 Native Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu.
3+
Visual Studio 2017 or newer is needed to build swift on Windows.
4+
5+
The following must take place in the **developer command prompt** (provided by Visual Studio). This shows up as "x64 Native Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu.
46

57
## Install dependencies
8+
69
- Install the latest version of [Visual Studio](https://www.visualstudio.com/downloads/)
7-
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The following components are required:
10+
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The following components are required:
811

912
1. Microsoft.VisualStudio.Component.Windows10SDK
10-
1. Microsoft.VisualStudio.Component.Windows10SDK.17763
11-
1. Microsoft.VisualStudio.Component.VC.Tools.x86.x64
13+
2. Microsoft.VisualStudio.Component.Windows10SDK.17763
14+
3. Microsoft.VisualStudio.Component.VC.Tools.x86.x64
15+
16+
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.
1217

1318
## Clone the repositories
19+
1420
1. Clone `apple/llvm-project` into a directory for the toolchain
15-
1. Clone `apple/swift-cmark`, `apple/swift`, `apple/swift-corelibs-libdispatch`, `apple/swift-corelibs-foundation`, `apple/swift-corelibs-xctest`, `apple/swift-llbuild`, `apple/swift-package-manager` into the toolchain directory
16-
1. Clone `compnerd/windows-swift` as a peer of the toolchain directory
21+
2. Clone `apple/swift-cmark`, `apple/swift`, `apple/swift-corelibs-libdispatch`, `apple/swift-corelibs-foundation`, `apple/swift-corelibs-xctest`, `apple/swift-llbuild`, `apple/swift-package-manager` into the toolchain directory
22+
3. Clone `compnerd/windows-swift` as a peer of the toolchain directory
1723

1824
- Currently, other repositories in the Swift project have not been tested and may not be supported.
1925

@@ -37,8 +43,17 @@ git clone -c core.autocrlf=input https://github.com/apple/swift-package-manager
3743
git clone https://github.com/compnerd/windows-swift windows-swift
3844
```
3945

40-
## Acquire ICU, SQLite3, curl, libxml2, zlib
41-
1. Go to https://dev.azure.com/compnerd/windows-swift and scroll down to "Dependencies" where you'll see bots (hopefully green) for icu, SQLite, curl, and libxml2. Download each of the zip files and copy their contents into S:/Library. The directory structure should resemble:
46+
## Acquire ICU, SQLite3, curl, libxml2 and zlib
47+
48+
Go to [compnerd's windows-swift azure page](https://dev.azure.com/compnerd/windows-swift/_build) and open [Pipelines](https://dev.azure.com/compnerd/windows-swift/_build) where you'll see bots (hopefully green) for:
49+
50+
- [ICU](https://dev.azure.com/compnerd/windows-swift/_build?definitionId=9)
51+
- [SQLite](https://dev.azure.com/compnerd/windows-swift/_build?definitionId=12&_a=summary)
52+
- [curl](https://dev.azure.com/compnerd/windows-swift/_build?definitionId=11&_a=summary)
53+
- [libxml2](https://dev.azure.com/compnerd/windows-swift/_build?definitionId=10&_a=summary)
54+
- [zlib](https://dev.azure.com/compnerd/windows-swift/_build?definitionId=16&_a=summary)
55+
56+
Download each of the zip files and copy their contents into S:/Library. The directory structure should resemble:
4257

4358
```
4459
/Library
@@ -55,9 +70,14 @@ git clone https://github.com/compnerd/windows-swift windows-swift
5570
```
5671

5772
## One-time Setup (re-run on Visual Studio upgrades)
58-
- Set up the `ucrt`, `visualc`, and `WinSDK` modules by copying `ucrt.modulemap` located at
59-
`swift/stdlib/public/Platform/ucrt.modulemap` into
60-
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt` as `module.modulemap`, copying `visualc.modulemap` located at `swift/stdlib/public/Platform/visualc.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`, and copying `winsdk.modulemap` located at `swift/stdlib/public/Platform/winsdk.modulemap` into `${UniversalCRTSdkDir}/Include/${UCRTVersion}/um` and setup the `visualc.apinotes` located at `swift/stdlib/public/Platform/visualc.apinotes` into `${VCToolsInstallDir}/include` as `visualc.apinotes`
73+
74+
Set up the `ucrt`, `visualc`, and `WinSDK` modules by:
75+
76+
- copying `ucrt.modulemap` located at `swift/stdlib/public/Platform/ucrt.modulemap` into
77+
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt` as `module.modulemap`
78+
- copying `visualc.modulemap` located at `swift/stdlib/public/Platform/visualc.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`
79+
- copying `winsdk.modulemap` located at `swift/stdlib/public/Platform/winsdk.modulemap` into `${UniversalCRTSdkDir}/Include/${UCRTVersion}/um`
80+
- and setup the `visualc.apinotes` located at `swift/stdlib/public/Platform/visualc.apinotes` into `${VCToolsInstallDir}/include` as `visualc.apinotes`
6181

6282
```cmd
6383
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" S:\toolchain\swift\stdlib\public\Platform\ucrt.modulemap
@@ -104,6 +124,7 @@ ninja -C S:\b\foundation
104124
```
105125

106126
- Add Foundation to your path:
127+
107128
```cmd
108129
path S:\b\foundation\Foundation;%PATH%
109130
```
@@ -116,6 +137,7 @@ ninja -C S:\b\xctest
116137
```
117138

118139
- Add XCTest to your path:
140+
119141
```cmd
120142
path S:\b\xctest;%PATH%
121143
```
@@ -137,7 +159,7 @@ ninja -C S:\b\foundation
137159

138160
```cmd
139161
cmake --build S:\b\foundation
140-
ninja -C S:\b\foundation test
162+
ninja -C S:\b\foundation test
141163
```
142164

143165
## Build llbuild
@@ -148,7 +170,8 @@ cmake -B S:\b\llbuild -G Ninja -S S:\toolchain\llbuild -DCMAKE_BUILD_TYPE=RelWit
148170
ninja -C S:\b\llbuild
149171
```
150172

151-
- Add llbuild to your path:
173+
- Add llbuild to your path:
174+
152175
```cmd
153176
path S:\b\llbuild\bin;%PATH%
154177
```
@@ -171,8 +194,8 @@ ninja -C S:\b\spm
171194

172195
- Run ninja install:
173196

174-
```cmd
197+
```cmd
175198
ninja -C S:\b\toolchain install
176199
```
177200

178-
- Add the Swift on Windows binaries path (`C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin`) to the `PATH` environment variable.
201+
- Add the Swift on Windows binaries path (`C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin`) to the `PATH` environment variable.

docs/visual-studio-cmd.png

62.3 KB
Loading

0 commit comments

Comments
 (0)