These are my notes on building ANGLE for Windows, based on what went wrong for me as I followed the ANGLE build instructions
here with commit
3453f745f068.
1) After installing depot_tools from the bundle, I had to manually run update_depot_tools.bat to install the required versions of python, git, etc. Before I figured out to do this, it used versions of python and git that I had previously installed, which were not compatible. Note that this is not because I forgot to put depot_tools at the head of PATH. I think the reason is because, as I remember from several years ago, gclient used to install python, git, etc on its first run and now it seems it doesn't and perhaps the build instructions should be updated.
2) The ANGLE working directory should be on the C: volume. When I initially had it on the D: volume, I got this error.
D:\src\angle>gn gen out\Debug
Traceback (most recent call last):
Traceback (most recent call last):
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 304, in <module>
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 304, in <module>
main()
main()
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 280, in main
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 280, in main
libpath_flags = ' '.join([q('-libpath:' + i) for i in lib])
libpath_flags = ' '.join([q('-libpath:' + i) for i in lib])
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 280, in <listcomp>
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 280, in <listcomp>
libpath_flags = ' '.join([q('-libpath:' + i) for i in lib])
libpath_flags = ' '.join([q('-libpath:' + i) for i in lib])
File "C:\Python36\lib\ntpath.py", line 586, in relpath
File "C:\Python36\lib\ntpath.py", line 586, in relpath
path_drive, start_drive))
path_drive, start_drive))
ValueError: path is on mount 'C:', start on mount 'D:'
ValueError: path is on mount 'C:', start on mount 'D:'
ERROR at //build/config/win/BUILD.gn:303:27: Script returned non-zero exit code.
vcvars_toolchain_data = exec_script("../../toolchain/win/setup_toolchain.py",
^----------
Current dir: D:/src/angle/out/Debug/
Command: C:/Python36/python.exe D:/src/angle/build/toolchain/win/setup_toolchain.py "C:\Program Files (x86)/Microsoft Visual Studio/2019/Community" "C:\Program Files (x86)\Windows Kits\10" "C:\WINDOWS\System32;C:\WINDOWS\SysWOW64;Arm64Unused" win x64 none
Returned 1.
See //build/config/BUILDCONFIG.gn:345:5: which caused the file to be included.
"//build/config/win:nominmax",
^----------------------------
3) Version 10.0.17134 of the Windows SDK, as suggested by the build instructions, didn't work. I got errors about missing DLLs with that version. Version 10.0.19041.0 of the Windows SDK worked for me.
D:\src\angle>gn gen out\Debug
Traceback (most recent call last):
File "D:/src/angle/build/vs_toolchain.py", line 577, in <module>
sys.exit(main())
File "D:/src/angle/build/vs_toolchain.py", line 573, in main
return commands[sys.argv[1]](*sys.argv[2:])
File "D:/src/angle/build/vs_toolchain.py", line 388, in CopyDlls
_CopyDebugger(target_dir, target_cpu)
File "D:/src/angle/build/vs_toolchain.py", line 424, in _CopyDebugger
(debug_file, full_path))
Exception: api-ms-win-downlevel-kernel32-l2-1-0.dll not found in "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\api-ms-win-downlevel-kernel32-l2-1-0.dll"
You must installWindows 10 SDK version 10.0.19041.0 including the "Debugging Tools for Windows" feature.
ERROR at //build/toolchain/win/BUILD.gn:49:3: Script returned non-zero exit code.
exec_script("../../vs_toolchain.py",
^----------
Current dir: D:/src/angle/out/Debug/
Command: C:/Python36/python.exe D:/src/angle/build/vs_toolchain.py copy_dlls D:/src/angle/out/Debug Debug x64
Returned 1.
See //BUILD.gn:46:3: which caused the file to be included.
group("all") {
^-------------
Traceback (most recent call last):
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 304, in <module>
main()
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 257, in main
vc_lib_um_path = FindFileInEnvList(env, 'LIB', ';', 'user32.lib')
File "D:/src/angle/build/toolchain/win/setup_toolchain.py", line 211, in FindFileInEnvList
file_name, env_name, '\n'.join(parts))
AssertionError: user32.lib is not found in LIB:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\ATLMFC\lib\x64
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x64
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64
C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x64
C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64
Check if it is installed.
4) On Window, I had to invoke autoninja via the batch file in depot_tools rather than directly. This didn't work:
C:\src\angle>autoninja -C out\Debug
Traceback (most recent call last):
File "C:\progs\depot_tools\autoninja.py", line 24, in <module>
import psutil
ImportError: No module named psutil
This did work:
C:\src\angle>autoninja.bat -C out\Debug
"c:\progs\depot_tools\ninja.exe" -C out\Debug -j 14
ninja: Entering directory `out\Debug'
...
5) There is an automatically generated file, "out\Debug\gen\angle_commit.h", that was generated incorrectly. This is how it was automatically generated:
#define ANGLE_COMMIT_HASH "b'3453f745f068'"
#define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "b'2020-10-06 11:50:23 +0000'"
#define ANGLE_COMMIT_POSITION b'13727'
It lead to this build error:
C:\src\angle>autoninja.bat -C out\Debug
"c:\progs\depot_tools\ninja.exe" -C out\Debug -j 14
ninja: Entering directory `out\Debug'
[2/4926] RC obj/libEGL/libEGL.res
FAILED: obj/libEGL/libEGL.res
C:/Python36/python.exe ../../build/toolchain/win/tool_wrapper.py rc-wrapper environment.x64 rc.exe /nologo "-imsvc..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\ATLMFC\include" "-imsvc..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-imsvc..\..\..\..\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" -DLIBEGL_IMPLEMENTATION -DEGLAPI= -DUSE_AURA=1 "-DCR_CLANG_REVISION=\"llvmorg-12-init-5627-gf086e85e-2\"" -D_HAS_NODISCARD -DCOMPONENT_BUILD -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_NO_AUTO_LINK -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_VB -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DANGLE_IS_64_BIT_CPU -DANGLE_IS_WIN -DANGLE_ENABLE_DEBUG_ANNOTATIONS "-DANGLE_EGL_LIBRARY_NAME=\"libEGL\"" "-DANGLE_GLESV2_LIBRARY_NAME=\"libGLESv2\"" -DANGLE_USE_ABSEIL -DABSL_ALLOCATOR_NOTHROW=1 -DANGLE_USE_EGL_LOADER -DGL_GLES_PROTOTYPES=1 -DEGL_EGL_PROTOTYPES=1 -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -I../../include -I../../src -I../../include -I../../src/common/third_party/base -I../../third_party/abseil-cpp -I../../third_party/abseil-cpp -Igen/angle /foobj/libEGL/libEGL.res ../../src/libEGL/libEGL.rc
rc: expected int, +, ~, or (, got b'13727'
[15/4926] CXX obj/src/tests/angle_end2end_tests_lib/GetImageTest.obj
ninja: build stopped: subcommand failed.
I manually "edited angle_commit.h" and that fixed compilation. Would be better to correct the script that generated it but I haven't figured that out yet.
#define ANGLE_COMMIT_HASH "3453f745f068"
#define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "2020-10-06 11:50:23 +0000"
#define ANGLE_COMMIT_POSITION 13727
With all these issues resolved, I was able to build ANGLE for Windows.