-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update docs for Bash on Ubuntu on Windows #5671
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Getting Started with Swift on Windows | ||
|
||
## Windows Subsystem for Linux (WSL) | ||
- Note that all compiled Swift binaries are only executable within Bash on Windows and are Ubunutu, not Windows, executables. | ||
- Make sure to run all commands from Bash, or the project won't compile. | ||
|
||
### 1. Install WSL | ||
Install and run the latest version of [Bash on Ubuntu on Windows](https://msdn.microsoft.com/en-gb/commandline/wsl/about) installed on your PC. | ||
``` | ||
bash | ||
``` | ||
|
||
### 2. Install dependencies | ||
Install the developer dependencies needed to compile the Swift project. These are identical to the Ubuntu dependencies, with the addition of `make` | ||
```bash | ||
sudo apt-get install git make cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev | ||
``` | ||
|
||
### 3. Upgrade clang | ||
Install a version of clang with C++ 14 support - the default version of clang on WSL results in linker errors during compilation. | ||
```bash | ||
sudo apt-get install clang-3.6 | ||
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100 | ||
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100 | ||
``` | ||
|
||
### 4. Upgrade CMake | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like how step three explains why a user needs to upgrade Clang. Could you explain here that the version of CMake included by default on WSL is too old to build Swift, and that at the time of this writing 3.4.3 or greater is required? |
||
```bash | ||
wget http://www.cmake.org/files/v3.5/cmake-3.5.2.tar.gz | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit-pick: I'm curious, why not the latest version of CMake? Is 3.5.2 special in some way? |
||
tar xf cmake-3.5.2.tar.gz | ||
cd cmake-3.5.2 | ||
./configure | ||
make | ||
sudo make install | ||
sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force | ||
cmake --version # This should print 3.5.2 | ||
``` | ||
|
||
### 6. Clone and build the Swift project | ||
```bash | ||
mkdir swift-source | ||
cd swift-source | ||
git clone https://github.com/apple/swift.git | ||
./swift/utils/update-checkout --clone | ||
./swift/utils/build-script -r | ||
``` | ||
### 7. Hello, Windows (Subsystem for Linux) | ||
```bash | ||
cd ./build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64\bin # This path may depend on your build configuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
vim test.swift | ||
print("Hello, Windows"); | ||
:wq | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit-pick: How about |
||
swiftc test.swift | ||
./test # Hello, Windows | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit-pick: Add a period at the end of this sentence?