Keywords:Networking, WebRTC Building Notes

Attention

If you checkout a old branch (e.g. git checkout branch-heads/70), you may got a error:

ERROR at //modules/video_capture/BUILD.gn:157:19: Can't load input file.
    deps += [ "//third_party/winsdk_samples" ]

Because many repositories of third party are independent from webrtc, so there’s a mismatch between webrtc version and third parties version.

Documents

Building on Windows

Building and Installing WebRTC on Windows
https://sourcey.com/articles/building-and-installing-webrtc-on-windows

编译WebRTC源码(2019年11月)
https://www.xilixili.net/2019/11/14/build-webrtc/

Windows编译WebRTC(声网教程补充篇)
https://www.dazhuanlan.com/2019/11/02/5dbcb3b174963/

Building on Linux

无需翻墙的 WebRTC 源码下载
https://webrtc.ren/post?id=1208

Issues

unknown type name ‘KSJACK DESCRIPTION’; did you mean ‘SERVICE_DESCRIPTION’
unknown type name ‘KSJACK DESCRIPTION’; did you mean ‘SERVICE_DESCRIPTION’
ValueError: duplicate key in dictionary: src/third_party/android_deps/libs/com_google_android_gms_play_services_base

Case:
There’re some errors on executing gclient sync:

D:\build\webrtc-checkout\src>gclient sync

src (ERROR)
----------------------------------------
[0:00:00] Started.
[0:00:00] ________ unmanaged solution; skipping src
[0:00:00] Finished running: git rev-parse --verify HEAD
----------------------------------------
Traceback (most recent call last):
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\metrics.py", line 267, in print_notice_and_exit
    yield
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient.py", line 3196, in <module>
    sys.exit(main(sys.argv[1:]))
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient.py", line 3182, in main
    return dispatcher.execute(OptionParser(), argv)
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient.py", line 2738, in CMDsync
    ret = client.RunOnDeps('update', args)
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient.py", line 1780, in RunOnDeps
    work_queue.flush(revision_overrides, command, args, options=self._options,
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient_utils.py", line 947, in flush
    reraise(e[0], e[1], e[2])
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient_utils.py", line 66, in reraise
    raise value
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient_utils.py", line 1024, in run
    self.item.run(*self.args, **self.kwargs)
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient.py", line 954, in run
    self.ParseDepsFile()
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient.py", line 713, in ParseDepsFile
    local_scope = gclient_eval.Parse(
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient_eval.py", line 508, in Parse
    result = Exec(content, filename, vars_override, builtin_vars)
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient_eval.py", line 414, in Exec
    value = _gclient_eval(node, filename, vars_dict)
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient_eval.py", line 338, in _gclient_eval
    return _convert(node_or_string)
  File "D:\workspace\webrtc_dev\build_20200719T1600\depot_tools\gclient_eval.py", line 282, in _convert
    raise ValueError(
ValueError: duplicate key in dictionary: src/third_party/android_deps/libs/com_google_android_gms_play_services_base (file 'D:\\workspace\\webrtc_dev\\build_20200719T1600\\webrtc-checkout\\src\\DEPS', line 661)

Solution:
These erros don’t matter, just ignore them.

Toolchain is out of date. Run “gclient runhooks” to update the toolchain, or set DEPOT_TOOLS_WIN_TOOLCHAIN=0 to use the locally installed toolchain.
Toolchain is out of date. Run "gclient runhooks" to update the toolchain, or set DEPOT_TOOLS_WIN_TOOLCHAIN=0 to use the locally installed toolchain.
Traceback (most recent call last):
  File "D:/workspace/webrtc_dev/build_20200719T1600/webrtc-checkout/src/build/vs_toolchain.py", line 578, in <module>
    sys.exit(main())
  File "D:/workspace/webrtc_dev/build_20200719T1600/webrtc-checkout/src/build/vs_toolchain.py", line 574, in main
    return commands[sys.argv[1]](*sys.argv[2:])
  File "D:/workspace/webrtc_dev/build_20200719T1600/webrtc-checkout/src/build/vs_toolchain.py", line 551, in GetToolchainDir
    runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
  File "D:/workspace/webrtc_dev/build_20200719T1600/webrtc-checkout/src/build/vs_toolchain.py", line 62, in SetEnvironmentAndGetRuntimeDllDirs
    update_result = Update(no_download=True)
  File "D:/workspace/webrtc_dev/build_20200719T1600/webrtc-checkout/src/build/vs_toolchain.py", line 522, in Update
    subprocess.check_call(get_toolchain_args)
  File "D:\SDKs\Python\Python27\lib\subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['D:\\SDKs\\Python\\Python27\\python.exe', 'D:\\build\\webrtc-checkout\\src\\third_party\\depot_tools\\win_toolchain\\get_toolchain_if_necessary.py', '--output-json', 'D:\\build\\webrtc-checkout\\src\\build\\win_toolchain.json', 'a687d8e2e4114d9015eb550e1b156af21381faac', '--no-download']' returned non-zero exit status 1

Solution:
Execute set DEPOT_TOOLS_WIN_TOOLCHAIN=0 before executing gn gen.

gn.py: Could not find checkout in any parent of the current path.

Case:
There’s a error in executing gn gen:

gn.py: Could not find checkout in any parent of the current path.
This must be run inside a checkout.

May be caused by:
Directory buildtools was missed in directory of webrc source (https://webrtc.googlesource.com/src.git),

Solution:
https://chromium.googlesource.com/chromium/src/buildtools

Reference:
https://www.bountysource.com/issues/59195128-gn-py-could-not-find-checkout-in-any-parent-of-the-current-path

ERROR at //.gn:9:1: Unable to load “D:/libwebrtc/out/src/build/dotfile_settings.gni”.
ERROR at //.gn:9:1: Unable to load "D:/libwebrtc/out/src/build/dotfile_settings.gni".
import("//build/dotfile_settings.gni")

https://chromium.googlesource.com/chromium/src/build

ERROR at //webrtc.gni:166:3: Can’t load input file. import("//testing/test.gni")
ERROR at //webrtc.gni:166:3: Can't load input file.
  import("//testing/test.gni")
  ^--------------------------
Unable to load:
  D:/libwebrtc/out/src/testing/test.gni
I also checked in the secondary tree for:
  D:/libwebrtc/out/src/build/secondary/testing/test.gni
See //BUILD.gn:17:1: whence it was imported.
import("webrtc.gni")

https://chromium.googlesource.com/chromium/src/testing

ERROR at //BUILD.gn:19:3: Can’t load input file. import("//third_party/protobuf/proto_library.gni")
ERROR at //BUILD.gn:19:3: Can't load input file.
  import("//third_party/protobuf/proto_library.gni")
  ^------------------------------------------------
Unable to load:
  D:/libwebrtc/out/src/third_party/protobuf/proto_library.gni
I also checked in the secondary tree for:
  D:/libwebrtc/out/src/build/secondary/third_party/protobuf/proto_library.gni

https://chromium.googlesource.com/chromium/src/third_party

ERROR at //modules/video_capture/BUILD.gn:157:19: Can’t load input file.
ERROR at //modules/video_capture/BUILD.gn:157:19: Can't load input file.
    deps += [ "//third_party/winsdk_samples" ]

Solution:
Add build_with_mozilla=true in --args.

ERROR at //rtc_base/BUILD.gn:45:5: Assertion failed. assert(rtc_ssl_root != ""
ERROR at //rtc_base/BUILD.gn:45:5: Assertion failed.
    assert(rtc_ssl_root != "",
    ^-----
You must specify rtc_ssl_root when rtc_build_ssl==0.
See //BUILD.gn:347:7: which caused the file to be included.
      "rtc_base",
      ^---------

Solution:
Add rtc_build_ssl=true in --args.

‘secondary/tools/clang/scripts/update.py’: [Errno 2] No such file or directory
D:/SDKs/Python/Python27/python.exe: can't open file 'D:/libwebrtc-avaer/out/src/build/secondary/tools/clang/scripts/update.py': [Errno 2] No such file or directory
ERROR at //build/config/compiler/BUILD.gn:1094:22: Script returned non-zero exit code.
    clang_revision = exec_script("//tools/clang/scripts/update.py",
                     ^----------
Current dir: D:/libwebrtc-avaer/out/src/out/Release_x64/
Command: D:/SDKs/Python/Python27/python.exe D:/libwebrtc-avaer/out/src/build/secondary/tools/clang/scripts/update.py --print-revision --verify-version=7.0.0
Returned 2.
See //build/config/BUILDCONFIG.gn:535:3: which caused the file to be included.
  "//build/config/compiler:runtime_library",

Solution:
Checkout source:

https://chromium.googlesource.com/chromium/src/tools

People who don't take risks generally make about two big mistakes a year. People who do take risks generally make about two big mistakes a year. ― Peter F. Drucker