Skip to content

Commit 9d13a2f

Browse files
Ben HillisCopilot
andcommitted
Add setup-dev-env.ps1 to validate development prerequisites
Checks for CMake, Visual Studio components (Clang, ATL, MSBuild), Windows SDK 26100, Developer Mode, and optional tools (WinDbg, Python). Reports missing items with install instructions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fd2375a commit 9d13a2f

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

doc/docs/dev-loop.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Prerequisites
44

5+
You can verify all prerequisites are installed by running `tools\setup-dev-env.ps1`.
6+
57
The following tools are required to build WSL:
68

79
- CMake >= 3.25

tools/setup-dev-env.ps1

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<#
2+
.SYNOPSIS
3+
Checks that all prerequisites for building WSL are installed.
4+
.DESCRIPTION
5+
Validates the development environment and reports missing tools
6+
with installation instructions. Run this before your first build.
7+
.EXAMPLE
8+
.\tools\setup-dev-env.ps1
9+
#>
10+
11+
Set-StrictMode -Version Latest
12+
$ErrorActionPreference = "Stop"
13+
14+
$script:Errors = 0
15+
16+
function Check($Name, $Result, $Fix)
17+
{
18+
if ($Result)
19+
{
20+
Write-Host " [OK] $Name" -ForegroundColor Green
21+
}
22+
else
23+
{
24+
Write-Host " [MISSING] $Name" -ForegroundColor Red
25+
Write-Host " -> $Fix" -ForegroundColor Yellow
26+
$script:Errors++
27+
}
28+
}
29+
30+
Write-Host ""
31+
Write-Host "WSL Development Environment Check" -ForegroundColor Cyan
32+
Write-Host "==================================" -ForegroundColor Cyan
33+
Write-Host ""
34+
35+
# --- CMake ---
36+
Write-Host "Build Tools:" -ForegroundColor White
37+
$cmake = Get-Command "cmake" -ErrorAction SilentlyContinue
38+
$cmakeOk = $false
39+
if ($cmake)
40+
{
41+
$cmakeVersion = [version]((cmake --version | Select-Object -First 1) -replace '[^0-9.]', '')
42+
$cmakeOk = $cmakeVersion -ge [version]"3.25"
43+
}
44+
Check "CMake >= 3.25$(if ($cmakeVersion) { " (found $cmakeVersion)" })" $cmakeOk "winget install Kitware.CMake"
45+
46+
# --- Visual Studio ---
47+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
48+
$vsInstall = $null
49+
if (Test-Path $vswhere)
50+
{
51+
$vsInstall = & $vswhere -latest -property installationPath 2>$null
52+
}
53+
Check "Visual Studio 2022+" ($null -ne $vsInstall) "Install Visual Studio 2022: https://visualstudio.microsoft.com/"
54+
55+
# --- VS Components (only check if VS is found) ---
56+
if ($vsInstall)
57+
{
58+
Write-Host ""
59+
Write-Host "Visual Studio Components:" -ForegroundColor White
60+
61+
$installedComponents = @(& $vswhere -latest -property catalog_productLineVersion 2>$null)
62+
$vsComponents = & $vswhere -latest -format json 2>$null | ConvertFrom-Json
63+
64+
# Check for specific required components via their markers
65+
$clangPath = Join-Path $vsInstall "VC\Tools\Llvm\x64\bin\clang-format.exe"
66+
Check "C++ Clang Compiler for Windows" (Test-Path $clangPath) "VS Installer -> Modify -> Individual Components -> C++ Clang Compiler for Windows"
67+
68+
$atlPath = Get-ChildItem -Path (Join-Path $vsInstall "VC\Tools\MSVC") -Filter "atlbase.h" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
69+
Check "C++ ATL for latest v143 tools" ($null -ne $atlPath) "VS Installer -> Modify -> Individual Components -> C++ ATL for latest v143 build tools"
70+
71+
$msbuild = Get-Command "msbuild" -ErrorAction SilentlyContinue
72+
if (-not $msbuild)
73+
{
74+
$msbuild = Get-ChildItem -Path $vsInstall -Filter "MSBuild.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
75+
}
76+
Check "MSBuild" ($null -ne $msbuild) "VS Installer -> Modify -> Individual Components -> MSBuild"
77+
}
78+
79+
# --- Windows SDK ---
80+
Write-Host ""
81+
Write-Host "Windows SDK:" -ForegroundColor White
82+
$sdkPath = "${env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.26100.0"
83+
Check "Windows SDK 26100" (Test-Path $sdkPath) "VS Installer -> Modify -> Individual Components -> Windows 11 SDK (10.0.26100.0)"
84+
85+
# --- Developer Mode / Symlinks ---
86+
Write-Host ""
87+
Write-Host "System Configuration:" -ForegroundColor White
88+
89+
$devMode = $false
90+
try
91+
{
92+
$devModeReg = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -ErrorAction SilentlyContinue
93+
$devMode = $devModeReg -and $devModeReg.AllowDevelopmentWithoutDevLicense -eq 1
94+
}
95+
catch {}
96+
97+
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
98+
Check "Developer Mode or Admin$(if ($devMode) { ' (Developer Mode)' } elseif ($isAdmin) { ' (Administrator)' })" ($devMode -or $isAdmin) "Settings -> System -> For developers -> Developer Mode"
99+
100+
# --- Optional tools ---
101+
Write-Host ""
102+
Write-Host "Optional Tools:" -ForegroundColor White
103+
104+
$windbg = Get-Command "WinDbgX.exe" -ErrorAction SilentlyContinue
105+
Check "WinDbg (for /attachdebugger)" ($null -ne $windbg) "winget install Microsoft.WinDbg"
106+
107+
$python = Get-Command "python3" -ErrorAction SilentlyContinue
108+
if (-not $python) { $python = Get-Command "python" -ErrorAction SilentlyContinue }
109+
Check "Python 3 (for validation scripts)" ($null -ne $python) "winget install Python.Python.3.13"
110+
111+
# --- Summary ---
112+
Write-Host ""
113+
if ($script:Errors -eq 0)
114+
{
115+
Write-Host "All prerequisites found. Ready to build!" -ForegroundColor Green
116+
Write-Host ""
117+
Write-Host " cmake ."
118+
Write-Host " cmake --build . -- -m"
119+
Write-Host ""
120+
}
121+
else
122+
{
123+
Write-Host "$($script:Errors) prerequisite(s) missing. Install them and re-run this script." -ForegroundColor Red
124+
Write-Host ""
125+
exit 1
126+
}

0 commit comments

Comments
 (0)