-
Notifications
You must be signed in to change notification settings - Fork 1
Development
The expected development environment is Windows with Visual Studio, though the toolchain should support any common platform. The WebRtc project is part of Chromium, and built using the Chromium build tools.
The WebRtc library is meant to be used by browser developers, and the native API is not standardised; check the discussion group for recent changes.
The Chromium tools have three components:
- Utilities, such as fetch & gclient
- GN, the meta-build system for NinjaBuild
- NinjaBuild itself, which actually builds the project
Additionally, the WebRtc fork uses dotnet to build both the managed and unmanaged components with an msbuild project (unity.msbuild).
Before beginning, ensure that you have all the necessary Visual Studio components installed. These can be installed through the Visual Studio Installer.
- Desktop development with C++
- MFC/ATL support
- Windows 10 SDK version 10.0.19041 or higher
- SDK Debugging Tools (Debugging Tools for Windows)
- Clone the Chromium Depot Tools into a directory
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
To avoid interfering with the system configuration, it is recommended to create a batch file to configure a terminal for Depot Tools.
- Create a batch file with an adjusted PATH, and toolchain settings:
SET "PATH=D:\UCL\webrtc\webrtcbuild\depot_tools;%PATH%;"
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
SET GYP_MSVS_VERSION=2019
cmd /k
The cmd /k
command at the end leaves the terminal open with the existing settings, so the environment is accessible by double clicking the batch file in explorer.
- Run
gclient
without any arguments to ensure that all dependencies are downloaded.
- Fetch the webrtc part of Chromium into another directory (parallel to depot_tools). This creates the .gclient and src directory, under which the fork can be checked out.
mkdir webrtc_checkout
cd webrtc_checkout
fetch --nohooks --no-history webrtc
- Perform GClient Sync. This will create the initial gclient files.
gclient sync
- Fetch the fork over the existing checkout
git remote add ucl [email protected]:UCL-VR/webrtc.git
git fetch ucl
git checkout ucl/ucl-main
- Re-sync (with Delete, as there may be newer dependencies added since the last update to the fork). This can be done in
src
.
gclient sync -D
- Generate the Visual Studio Solution. This will create the
sln
inout/Default
, which can be used to attach the debugger to a running process.
gn gen --ide=vs out\Default
- Add the webrtc managed
csproj
to the solution by using theAdd Existing Item
command.
Once in Visual Studio, the project is more easily explored using the Folder View
in Solution Explorer
.
For further details see the Chromium Projects Get the Code page.
The build is controlled by NinjaBuild. GN is driven through the .gn
files throughout the project hierarchy.
The .gn
files define modules, that can be added as dependencies to higher modules, and the source files that make up those modules. If new source files should be added to the project, the .gn
files for the module (or directory) must also be modified. As an example, see the initial commit that added the .NET bindings.
The gn reference is available here.
When a build is invoked, gn will traverse the BUILD.gn files starting from the top level BUILD.gn, adding dependencies as it goes. Each depedency will come with a set of build instructions, such as command line arguments and defines from configs. The built objects are created in a shadow hierarchy under unity/obj/Debug/build
or unity/obj/Release/build
.
In these folders are the intermediate files - such as object files for individual c/cpp files, and shared libraries.
For example, the libjingle_peerconnection_so.so library is defined in the sdk\android\BUILD.gn
file as rtc_shared_library("libjingle_peerconnection_so")
. In sdk\dotnet\unity\obj\Debug\build\android\arm64-v8a\
there is the final .so
. In the src/sdk/dotnet/unity/obj/Debug/build/android/armeabi-v7a/obj/sdk/android
folder there is the libjingle_peerconnection_so.ninja
file that contains the command line instructions to build the shared library.
With these files it is possible to debug the build and find where symbols go missing.