|
| 1 | +# Development environment setup |
| 2 | + |
| 3 | +The standard development environment is a Windows PC, with Windows Subsystem for Linux (WSL) used for Linux development. |
| 4 | +After following this guide, you will be able to execute all the local PC development tooling associated with this repository. |
| 5 | + |
| 6 | +> 💡 Development on a Linux or Mac system is also possible, though the setup process is not documented here. |
| 7 | +
|
| 8 | +To run all repository tooling locally, you will need the following prerequisites: |
| 9 | + |
| 10 | +* [Latest version of LLVM](https://github.com/llvm/llvm-project/releases) |
| 11 | + * Select: ☑️ Add LLVM to the system PATH for the current user |
| 12 | +* [Visual Studio Build Tools for C++](https://visualstudio.microsoft.com/visual-cpp-build-tools/) with components: |
| 13 | + * Workload: Desktop development with C++ |
| 14 | +* [Latest version of Visual Studio Code](https://code.visualstudio.com/Download) with extensions: |
| 15 | + * C/C++ (ms-vscode.cpptools) |
| 16 | + * rust-analyzer (rust-lang.rust-analyzer) |
| 17 | + * WSL (ms-vscode-remote.remote-wsl) |
| 18 | + |
| 19 | +> 💡 Using an IDE other than Visual Studio Code is possible, though the setup process is not documented here. |
| 20 | +
|
| 21 | +* [Latest version of Git](https://git-scm.com/downloads/win) with components: |
| 22 | + * Git LFS (Large File Storage) |
| 23 | +* [Latest version of PowerShell 7](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows) |
| 24 | + |
| 25 | +For detailed configuration of the above, use your own judgement - the defaults should work but customization is also generally fine. |
| 26 | + |
| 27 | +This guide assumes a clean Windows PC in other regards. |
| 28 | + |
| 29 | +# Windows environment setup |
| 30 | + |
| 31 | +1. If you had to install any of the above prerequisites, restart your PC to ensure a complete installation. |
| 32 | +1. Install Rust using [Rustup](https://rustup.rs/), with all default settings. |
| 33 | +1. Execute `cargo install just --locked` to install the Just utility (unless already installed). |
| 34 | + |
| 35 | +After installing the Rust toolchain, we setup repository-specific tooling: |
| 36 | + |
| 37 | +1. In a directory of your choosing, clone the `oxidizer` repo: `git clone https://github.com/microsoft/oxidizer.git`. |
| 38 | + |
| 39 | +> 💡 Even though the Windows and Linux development environments are largely independent, they will both use the same working directory (created by the above `git clone` command). This allows you to build and test your changes immediately on both operating systems. |
| 40 | +
|
| 41 | +2. Switch to the `oxidizer` directory: `cd oxidizer`. |
| 42 | +2. Execute `git config --local include.path ./.gitconfig` to attach the repo-specific Git configuration. |
| 43 | +2. Execute `just install-tools` to install all necessary Rust toolchain versions and development tooling. |
| 44 | +2. Open `.vscode/settings.template.jsonc` and save a copy as `.vscode/settings.json` to apply repo-specific settings for Visual Studio Code. Part of this file should be the same for everyone but the rest you can customize - refer to inline comments. |
| 45 | + |
| 46 | +## Validate Windows environment |
| 47 | + |
| 48 | +1. Execute `just build` to build the workspace. Verify that the build is successful. |
| 49 | +1. Execute `just test` to execute all tests in the workspace. Verify that all tests pass. |
| 50 | +1. Validate that debugging works by opening `crates/tick/examples/basic.rs` and pressing the `Debug` link that appears above `main()`. This should successfully launch the example app under the debugger. |
| 51 | + |
| 52 | +# Linux (WSL) environment setup |
| 53 | + |
| 54 | +The Linux distribution we use for development is **Ubuntu 24.04**, running as a WSL virtual machine. |
| 55 | + |
| 56 | +1. Install [Ubuntu 24.04.1 LTS](https://apps.microsoft.com/detail/9NZ3KLHXDJP5?hl=en-us&gl=US&ocid=pdpshare) from the Microsoft Store. |
| 57 | +1. Open an Ubuntu terminal (e.g. from the Microsoft Store page, from the Start menu or in Windows Terminal). |
| 58 | + * If you get an error about a required feature not being installed, try first restarting the PC to complete the feature installation. |
| 59 | +1. You will be asked to create a user account the first time you run Ubuntu. This is a local account unique to the Linux VM and is not related to your account on the host machine. |
| 60 | + |
| 61 | +All commands that follow are to be executed in the Ubuntu terminal. |
| 62 | + |
| 63 | +Next, we upgrade, install and configure development prerequisites: |
| 64 | + |
| 65 | +1. Execute `sudo apt update && sudo apt dist-upgrade -y` to upgrade everything that is already installed. |
| 66 | +1. Execute `sudo apt install -y curl clang llvm libclang-dev gdb perl python3 python3-pip git git-lfs build-essential cmake pkg-config libssl-dev` to ensure that essential packages are installed. |
| 67 | +1. [Install PowerShell 7](https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.5#installation-via-package-repository-the-package-repository). |
| 68 | +1. Execute `git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"` to set the correct Git authentication flow. |
| 69 | +1. Execute `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` and install Rust with all default settings. |
| 70 | +1. Reopen the terminal to apply changes. |
| 71 | +1. Execute `cargo install just --locked` to install the Just utility (unless already installed). |
| 72 | + |
| 73 | +Next, we setup repository-specific tooling on Linux: |
| 74 | + |
| 75 | +1. Switch to the `oxidizer` directory you previously cloned on Windows, using a `/mnt/c` style path to access the Windows filesystem: `cd /mnt/c/Users/username/Desktop/oxidizer` (adjusting the path to match your chosen location). |
| 76 | +1. Execute `just install-tools` to install all necessary Rust toolchain versions and development tooling. |
| 77 | + |
| 78 | +## Optimize Linux build performance |
| 79 | + |
| 80 | +> ⚠️ This chapter may conflict with other repos in the same WSL instance. Skip or undo if you experience problems. |
| 81 | +
|
| 82 | +After installing the Rust toolchains, we setup the build target directory for fast build times: |
| 83 | + |
| 84 | +1. Execute `mkdir ~/target` to create a directory for Linux build outputs. While the repo directory itself is shared between Windows and Linux, we will use a dedicated directory for build outputs on Linux to improve Linux build performance. |
| 85 | +1. Execute `nano ~/.bashrc` to open a text editor on this file. |
| 86 | +1. Add `export CARGO_TARGET_DIR=~/target` near the end of the file. |
| 87 | +1. Save & exit. |
| 88 | +1. Reopen the terminal to apply changes. |
| 89 | + |
| 90 | +## Validate Linux (WSL) environment |
| 91 | + |
| 92 | +1. Execute `just build` to build the workspace. Verify that the build is successful. |
| 93 | +1. Execute `just test` to execute all tests in the workspace. Verify that all tests pass. |
| 94 | + |
| 95 | +## Setup Visual Studio Code integration |
| 96 | + |
| 97 | +Visual Studio Code is also our standard Linux IDE and requires some additional setup to work with the Linux workspace. |
| 98 | + |
| 99 | +> ⚠️ While the IDE runs on the Windows desktop, all tooling runs in the Linux VM, including Visual Studio Code extensions. The below steps will instruct you to install the minimum set of required Visual Studio Code extensions for the Linux environment. |
| 100 | +
|
| 101 | +1. In an Ubuntu terminal, in the `oxidizer` directory, execute `code .` to open the project in Visual Studio Code. |
| 102 | +1. Open the Extensions panel in Visual Studio Code. |
| 103 | +1. Install following extensions by selecting "Install in WSL" for each: |
| 104 | + * C/C++ (ms-vscode.cpptools) |
| 105 | + * rust-analyzer (rust-lang.rust-analyzer) |
| 106 | +1. Close Visual Studio Code and open it again via `code .` to complete extension setup. |
| 107 | + |
| 108 | +Validate the setup by executing the following tasks from the task palette (F1): |
| 109 | + |
| 110 | +1. `Tasks: Run Build Task` |
| 111 | +1. `Tasks: Run Test Task` |
| 112 | + |
| 113 | +Validate that debugging works by opening `crates/tick/examples/basic.rs` and pressing the `Debug` link that appears above `main()`. This should successfully launch the example app under the debugger. |
0 commit comments