Changes between Version 99 and Version 100 of BuildingCairoOnWindows


Ignore:
Timestamp:
Aug 27, 2023 2:16:18 PM (8 months ago)
Author:
Fujii Hironori
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildingCairoOnWindows

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