Skip to content

Commit e7e465d

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 e7e465d

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-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: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
$cmakeVersion = $null
39+
$cmakeOk = $false
40+
if ($cmake)
41+
{
42+
$cmakeVersion = [version]((cmake --version | Select-Object -First 1) -replace '[^0-9.]', '')
43+
$cmakeOk = $cmakeVersion -ge [version]"3.25"
44+
}
45+
Check "CMake >= 3.25$(if ($cmakeVersion) { " (found $cmakeVersion)" })" $cmakeOk "winget install Kitware.CMake"
46+
47+
# --- Visual Studio ---
48+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
49+
$vsInstall = $null
50+
if (Test-Path $vswhere)
51+
{
52+
$vsInstall = & $vswhere -latest -property installationPath 2>$null
53+
}
54+
Check "Visual Studio 2022+" ($null -ne $vsInstall) "Install Visual Studio 2022: https://visualstudio.microsoft.com/"
55+
56+
# --- VS Components (only check if VS is found) ---
57+
if ($vsInstall)
58+
{
59+
Write-Host ""
60+
Write-Host "Visual Studio Components:" -ForegroundColor White
61+
62+
$installedComponents = @(& $vswhere -latest -property catalog_productLineVersion 2>$null)
63+
$vsComponents = & $vswhere -latest -format json 2>$null | ConvertFrom-Json
64+
65+
# Check for specific required components via their markers
66+
$clangPath = Join-Path $vsInstall "VC\Tools\Llvm\x64\bin\clang-format.exe"
67+
Check "C++ Clang Compiler for Windows" (Test-Path $clangPath) "VS Installer -> Modify -> Individual Components -> C++ Clang Compiler for Windows"
68+
69+
$atlPath = Get-ChildItem -Path (Join-Path $vsInstall "VC\Tools\MSVC") -Filter "atlbase.h" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
70+
Check "C++ ATL for latest v143 tools" ($null -ne $atlPath) "VS Installer -> Modify -> Individual Components -> C++ ATL for latest v143 build tools"
71+
72+
$msbuild = Get-Command "msbuild" -ErrorAction SilentlyContinue
73+
if (-not $msbuild)
74+
{
75+
$msbuild = Get-ChildItem -Path $vsInstall -Filter "MSBuild.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
76+
}
77+
Check "MSBuild" ($null -ne $msbuild) "VS Installer -> Modify -> Individual Components -> MSBuild"
78+
}
79+
80+
# --- Windows SDK ---
81+
Write-Host ""
82+
Write-Host "Windows SDK:" -ForegroundColor White
83+
$sdkPath = "${env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.26100.0"
84+
Check "Windows SDK 26100" (Test-Path $sdkPath) "VS Installer -> Modify -> Individual Components -> Windows 11 SDK (10.0.26100.0)"
85+
86+
# --- Developer Mode / Symlinks ---
87+
Write-Host ""
88+
Write-Host "System Configuration:" -ForegroundColor White
89+
90+
$devMode = $false
91+
try
92+
{
93+
$devModeReg = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -ErrorAction SilentlyContinue
94+
$devMode = $devModeReg -and $devModeReg.AllowDevelopmentWithoutDevLicense -eq 1
95+
}
96+
catch {}
97+
98+
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
99+
Check "Developer Mode or Admin$(if ($devMode) { ' (Developer Mode)' } elseif ($isAdmin) { ' (Administrator)' })" ($devMode -or $isAdmin) "Settings -> System -> For developers -> Developer Mode"
100+
101+
# --- Optional tools ---
102+
Write-Host ""
103+
Write-Host "Optional Tools:" -ForegroundColor White
104+
105+
$windbg = Get-Command "WinDbgX.exe" -ErrorAction SilentlyContinue
106+
Check "WinDbg (for /attachdebugger)" ($null -ne $windbg) "winget install Microsoft.WinDbg"
107+
108+
$python = Get-Command "python3" -ErrorAction SilentlyContinue
109+
if (-not $python) { $python = Get-Command "python" -ErrorAction SilentlyContinue }
110+
Check "Python 3 (for validation scripts)" ($null -ne $python) "winget install Python.Python.3.13"
111+
112+
# --- Summary ---
113+
Write-Host ""
114+
if ($script:Errors -eq 0)
115+
{
116+
Write-Host "All prerequisites found. Ready to build!" -ForegroundColor Green
117+
Write-Host ""
118+
Write-Host " cmake ."
119+
Write-Host " cmake --build . -- -m"
120+
Write-Host ""
121+
}
122+
else
123+
{
124+
Write-Host "$($script:Errors) prerequisite(s) missing. Install them and re-run this script." -ForegroundColor Red
125+
Write-Host ""
126+
exit 1
127+
}

0 commit comments

Comments
 (0)