|
| 1 | +# Windows port |
| 2 | + |
| 3 | +WebKit had two Windows ports, Apple Windows port and WinCairo port. |
| 4 | +WinCairo port is called Windows port after the Apple Windows port was deprecated. |
| 5 | +It is using [cairo](https://www.cairographics.org/) for the graphics backend, [libcurl](https://curl.se/libcurl/) for the network backend. |
| 6 | +It supports only 64 bit Windows. |
| 7 | + |
| 8 | +## Installing Development Tools |
| 9 | + |
| 10 | +You need CMake, Perl, Python, Ruby, gperf, the latest Windows SDK, and Visual Studio 2022 to build Windows port. |
| 11 | +You can use [Chocolatey](https://chocolatey.org/) to install the tools. |
| 12 | + |
| 13 | +[ActivePerl chocolatey package](https://community.chocolatey.org/packages/ActivePerl) has a problem and no package maintainer now. |
| 14 | +XAMPP includes Perl, and running layout tests needs XAMPP. Install XAMPP instead. |
| 15 | + |
| 16 | +``` |
| 17 | +choco install -y xampp-81 python ruby git cmake gperf |
| 18 | +``` |
| 19 | + |
| 20 | +It supports both CMake Ninja generator and CMake Visual Studio generator. |
| 21 | +Ninja is optional. |
| 22 | + |
| 23 | +``` |
| 24 | +choco install -y ninja |
| 25 | +``` |
| 26 | + |
| 27 | +Windows Git enables `autocrlf` by default. But, some layout tests files have to be checked out as LF line end style. See [Bug 240158](https://bugs.webkit.org/show_bug.cgi?id=240158). |
| 28 | + |
| 29 | +``` |
| 30 | + git config --global core.autocrlf input |
| 31 | +``` |
| 32 | + |
| 33 | +### Using winget |
| 34 | + |
| 35 | +If you prefer [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) to Chocolatey, you can use it. |
| 36 | +Here is the one-liner to install all tools: |
| 37 | + |
| 38 | +``` |
| 39 | +"Git.Git Kitware.CMake Ninja-build.Ninja Python.Python.3.11 RubyInstallerTeam.Ruby.3.1 ApacheFriends.Xampp.8.2 GnuWin32.Gperf" -split " " |% { winget install --scope=machine --id $_ } |
| 40 | +``` |
| 41 | + |
| 42 | +If `--scope=machine` isn't specified, Python is installed under your user profile directory. |
| 43 | + |
| 44 | + |
| 45 | +## WebKit command prompt |
| 46 | + |
| 47 | +To compile, run programs and run tests, you need to set some environment variables. |
| 48 | +For ease of development, it's recommended to create a batch file to set environment variables and open PowerShell. |
| 49 | +Create a batch file with the following content with adjusting it to your PC. |
| 50 | +And put it in the top WebKit source directory. |
| 51 | +And double-click it to open PowerShell. |
| 52 | + |
| 53 | +``` |
| 54 | +@echo off |
| 55 | +cd %~dp0 |
| 56 | +
|
| 57 | +path C:\xampp\apache\bin;%path% |
| 58 | +path C:\xampp\perl\bin;%path% |
| 59 | +path %ProgramFiles%\CMake\bin;%path% |
| 60 | +path %ProgramFiles(x86)%\Microsoft Visual Studio\Installer;%path% |
| 61 | +for /F "usebackq delims=" %%I in (`vswhere.exe -latest -property installationPath`) do set VSPATH=%%I |
| 62 | +
|
| 63 | +set WEBKIT_LIBRARIES=%~dp0WebKitLibraries\win |
| 64 | +set WEBKIT_TESTFONTS=%~dp0Tools\WebKitTestRunner\fonts |
| 65 | +set DUMPRENDERTREE_TEMP=%TEMP% |
| 66 | +
|
| 67 | +rem set http_proxy=http://your-proxy:8080 |
| 68 | +rem set https_proxy=%http_proxy% |
| 69 | +
|
| 70 | +rem set JSC_dumpOptions=1 |
| 71 | +rem set JSC_useJIT=0 |
| 72 | +rem set JSC_useDFGJIT=0 |
| 73 | +rem set JSC_useRegExpJIT=0 |
| 74 | +rem set JSC_useDOMJIT=0 |
| 75 | +
|
| 76 | +rem set WEBKIT_SHOW_FPS=1 |
| 77 | +
|
| 78 | +call "%VSPATH%\VC\Auxiliary\Build\vcvars64.bat" |
| 79 | +cd %~dp0 |
| 80 | +start powershell |
| 81 | +``` |
| 82 | + |
| 83 | +You can replace `powershell` with `cmd` or `wt` (Windows Terminal) if you like. |
| 84 | + |
| 85 | + |
| 86 | +## Building |
| 87 | + |
| 88 | +In the WinKit command prompt, invoke `build-webkit` to start building. |
| 89 | + |
| 90 | +``` |
| 91 | +perl Tools/Scripts/build-webkit --release |
| 92 | +``` |
| 93 | + |
| 94 | +Ensure you don't have GCC in your PATH, otherwise CMake is going to use GCC and builds will fail. |
| 95 | + |
| 96 | +You will get required libraries [WebKitRequirements](https://github.com/WebKitForWindows/WebKitRequirements) downloaded automatically when you perform a `build-webkit`. |
| 97 | +It checks the latest WebKitRequirements every time. |
| 98 | +I'd like to recommend to use `--skip-library-update` for incremental build to speed up for the next time. |
| 99 | + |
| 100 | +``` |
| 101 | +python Tools\Scripts\update-webkit-wincairo-libs.py |
| 102 | +perl Tools\Scripts\build-webkit --release --skip-library-update |
| 103 | +``` |
| 104 | + |
| 105 | +The build succeeded if you got `WebKit is now built` message. Run your `MiniBrowser`. |
| 106 | + |
| 107 | +``` |
| 108 | +WebKitBuild/Release/bin64/MiniBrowser.exe |
| 109 | +``` |
| 110 | + |
| 111 | +You can run programs under a debugger with [this instruction](../../Build & Debug/DebuggingWithVS.html). |
| 112 | + |
| 113 | +### Building from within Visual Studio |
| 114 | + |
| 115 | +In the WinKit command prompt, |
| 116 | + |
| 117 | +``` |
| 118 | +perl Tools/Scripts/build-webkit --release --no-ninja --generate-project-only |
| 119 | +``` |
| 120 | + |
| 121 | +Open the generated solution file by invoking devenv command from a WebKit command prompt. |
| 122 | + |
| 123 | +``` |
| 124 | +devenv WebKitBuild\Release\WebKit.sln |
| 125 | +``` |
| 126 | + |
| 127 | +Build "MiniBrowser" project. |
| 128 | + |
| 129 | + |
| 130 | +## Running the tests |
| 131 | + |
| 132 | +Install XAMPP as described above. |
| 133 | + |
| 134 | +Install required Python and Ruby modules. |
| 135 | + |
| 136 | +``` |
| 137 | +pip install pywin32 |
| 138 | +gem install webrick |
| 139 | +``` |
| 140 | + |
| 141 | +If Apache service is running, stop it. |
| 142 | + |
| 143 | +``` |
| 144 | +net stop apache2.4 |
| 145 | +``` |
| 146 | + |
| 147 | +Some extensions need to be registered as CGI. Modify the following commands for your Perl and Python paths, and run them as administrator. |
| 148 | + |
| 149 | +``` |
| 150 | +reg add HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI\Command /ve /d "c:\xampp\perl\bin\perl.exe -T" |
| 151 | +reg add HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command /ve /d "c:\xampp\perl\bin\perl.exe -T" |
| 152 | +reg add HKEY_CLASSES_ROOT\.py\Shell\ExecCGI\Command /ve /d "c:\Python311\python.exe -X utf8" |
| 153 | +``` |
| 154 | + |
| 155 | +You need openssl.exe in your PATH to run wpt server. |
| 156 | +XAMPP contains openssl.exe in C:\xampp\apache\bin directory. Append the directory to your PATH. |
| 157 | + |
| 158 | +Open the WinKit command prompt as administrator because http tests need to run Apache service. |
| 159 | + |
| 160 | +Invoke `run-webkit-tests`. |
| 161 | + |
| 162 | +``` |
| 163 | +python Tools/Scripts/run-webkit-tests --release |
| 164 | +``` |
| 165 | + |
| 166 | +If you are using Japanese Windows, some layout tests fail due to form control size differences. |
| 167 | +`GetStockObject(DEFAULT_GUI_FONT)` returns `MS UI Gothic` on it. |
| 168 | +Remove `GUIFont.Facename` of `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\GRE_Initialize`. |
| 169 | +And, replace `MS UI Gothic` with `Microsoft Sans Serif` in `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes\MS Shell Dlg`. |
| 170 | + |
| 171 | +If http tests fail as flaky failures due to the socket count limit, increase the user port range. See [Bug 224523](https://bugs.webkit.org/show_bug.cgi?id=224523) |
| 172 | +``` |
| 173 | +netsh int ipv4 set dynamicport tcp start=1025 num=64511 |
| 174 | +``` |
| 175 | + |
| 176 | +### Running the tests in Docker |
| 177 | + |
| 178 | +You can use Docker to run LayoutTests by mounting the host directory. |
| 179 | + |
| 180 | +``` |
| 181 | +docker run -it --rm --cpu-count=8 --memory=16g -v %cd%:c:\repo -w c:\repo webkitdev/msbuild |
| 182 | +``` |
| 183 | + |
| 184 | +## Downloading build artifacts from Buildbot |
| 185 | + |
| 186 | + * Go to [WinCairo-64-bit-WKL-Release-Build Buildbot builder page](https://build.webkit.org/#/builders/27). |
| 187 | + * Click any "Build #" which is green. |
| 188 | + * Click "> stdio" of "transfer-to-s3". |
| 189 | + * You can find "S3 URL" in the console log. |
| 190 | + * Download the zip. |
| 191 | + * Download the corresponding release of [WebKitRequirements](https://github.com/WebKitForWindows/WebKitRequirements/releases). |
| 192 | + * Unpack them, copy all DLL of WebKitRequirements to the directory of MiniBrowser.exe |
| 193 | + * Install the latest [vc_redist.x64.exe](https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist) of Microsoft Visual C++ Redistributable for Visual Studio |
| 194 | + |
| 195 | +### The specified module could not be found |
| 196 | + |
| 197 | +If you simply double-click MiniBrowser.exe to execute, you'd get the following error message. |
| 198 | + |
| 199 | +``` |
| 200 | +--------------------------- |
| 201 | +MiniBrowser can't open. |
| 202 | +--------------------------- |
| 203 | +::LoadLibraryW failed: |
| 204 | +path=C:\path\to\bin64\MiniBrowserLib.dll |
| 205 | +The specified module could not be found. |
| 206 | +
|
| 207 | +--------------------------- |
| 208 | +OK |
| 209 | +--------------------------- |
| 210 | +``` |
| 211 | + |
| 212 | +Due to the useless error message, this is a Windows port FAQ. |
| 213 | +The error message actually means MiniBrowserLib.dll can't load required DLL of WebKitRequirements. |
| 214 | +You have to set the env var WEBKIT_LIBRARIES. Or, copy all DLL of WebKitRequirements to the directory of MiniBrowser.exe as explained in the above section. |
| 215 | + |
| 216 | + |
| 217 | +## Compiling with Clang |
| 218 | + |
| 219 | +[clang-cl has a problem for /MP support.](https://reviews.llvm.org/D52193) |
| 220 | +It's recommended to use Ninja with clang-cl. |
| 221 | +Install clang-cl and Ninja. |
| 222 | + |
| 223 | +``` |
| 224 | +choco install -y llvm ninja |
| 225 | +``` |
| 226 | + |
| 227 | +Open Visual Studio Command Prompt, and invoke the following commands. |
| 228 | + |
| 229 | +``` |
| 230 | +set CC=clang-cl |
| 231 | +set CXX=clang-cl |
| 232 | +perl Tools\Scripts\build-webkit --release --ninja |
| 233 | +``` |
| 234 | + |
| 235 | +clang-cl builds are experimental, see [Bug 171618](https://bugs.webkit.org/show_bug.cgi?id=171618) for the current status. |
0 commit comments