Skip to content
File

Blob: tools/windows/install-deps.bat

3.3 KB
1@echo off
2setlocal enabledelayedexpansion
3 
4rem Check this script is being run from an elevated cmd binary.
5net session > NUL 2>&1
6if %ERRORLEVEL% NEQ 0 (
7 echo This script requires administrator privileges.
8 exit /b 1
9)
10 
11cls
12 
13goto :InstallDependencies
14 
15:AddToUserPathInEnvironment
16rem Function to add an element to the users PATH as defined in HCU\Environment.
17setlocal
18set "PATH_TO_ADD=%~1"
19for /F "usebackq tokens=3 skip=2" %%P IN (`reg query "HKEY_CURRENT_USER\Environment" /v PATH`) do set "USERPATH=%%P"
20setx PATH "%PATH_TO_ADD%;!USERPATH!"
21echo Added %PATH_TO_ADD% to default PATH.
22endlocal
23exit /b 0
24 
25:InstallDependencies
26 
27echo.Workerd dependency installation
28echo.-------------------------------
29echo.
30echo.This script will configure your Windows machine for building workerd with
31echo.bazel on Windows.
32echo.
33echo.Some of the steps will open windows for you to approve.
34echo.
35echo.* Step 1: Enable developer mode features.
36echo.
37rem This is based on https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging
38reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock /v AllowDevelopmentWithoutDevLicense /t REG_DWORD /d 1 /f
39 
40echo.
41echo.* Step 2: Enable 8.3 name support on this machine.
42fsutil 8dot3name set 0
43 
44rem Install Visual Studio Code Community edition with Desktop development with C++ package.
45rem ----------------------------------------------------------------------------------------
46rem
47rem The config in vsconfig.json is the config for "Desktop development with C++".
48rem
49rem The config is determined by first installing Visual Studio Community Edition on your
50rem devbox. Then run `c:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe` and click
51rem `More -> Export Configuration Settings`, select an config file to write, then `Review Details`
52rem and select "Desktop development with C++".
53echo.
54echo.* Step 3: Install Visual Studio Code Community edition with Desktop development with C++ package.
55winget install "Microsoft.VisualStudio.2022.Community" --override "install --config %~dp0\vsconfig.json"
56 
57echo.
58echo.* Step 4: Install Python 3.
59winget install Python3 -v 3.12.1 --override "/passive PrependPath=1"
60@rem bazel requires a python3.exe binary, create a symlink for it.
61mklink "%LOCALAPPDATA%\Programs\Python\Python312\python3.exe" "%LOCALAPPDATA%\Programs\Python\Python312\python.exe"
62 
63echo.
64echo.* Step 5: Install msys2.
65winget install msys2.msys2
66setx BAZEL_SH "C:\msys64\usr\bin\bash.exe"
67 
68echo.
69echo.* Step 6 Install msys2 tools suggested for bazel, from https://bazel.build/install/windows.
70@rem Invoking pacman like this reports an error updating GNU info files, no idea how to fix.
71C:\msys64\usr\bin\bash -c "/usr/bin/pacman -S --noconfirm zip unzip patch diffutils"
72call :AddToUserPathInEnvironment C:\msys64\usr\bin
73 
74echo.
75echo.* Step 7: Install LLVM compiler toolchain.
76@rem The MSVC build frequently breaks in some ways when the LLVM version is updated, we may have to
77@rem manually install a different version again soon.
78@rem winget install "LLVM" --version 19.1.7
79 
80echo.
81echo.* Step 8: Install bazelisk as %LOCALAPPDATA%\Programs\bazelisk\bazel.exe.
82winget install bazelisk -l "%LOCALAPPDATA%\Programs\bazelisk" -r "bazel.exe"
83call :AddToUserPathInEnvironment "%LOCALAPPDATA%\Programs\bazelisk"
84 
85echo.
86echo.* Setup complete.
87set /p GO="Press enter to exit."
88exit 0