Skip to content

Building for Linux and Android

sebjf edited this page May 13, 2021 · 8 revisions

Introduction

This page describes how to configure a VM to build the WebRtc fork for Linux and Android. It is possible to cross-compile to Windows but that is not supported in this document. We recommend using a Windows VM for building for Windows.

These instructions are tested on a Windows 10 Hyper-V Ubuntu image, though where differences in other images are known they are noted.

Notes

  • Docker is not supported because snapsd, which is a dependency of install-build-deps-android.sh, does not work in Docker.
  • Hyper-V on Windows 10 has a few issues:
  1. Enhanced Session does not work. The easiest way to complete the tasks below is to sudo apt install openssh-server and use Putty to SSH into the VM, then use WinSCP to download the binaries.
  2. The machine by default is put on an internal virtual switch. Create a new virtual switch with mode set to external and set this as the VM's switch to connect to the internet.
  3. The virtual hard disk size is initially limited to 12GB. Ensure you create it with, or expand it to, to 100GB before beginning.

Instructions

  1. Install a copy of Ubuntu 20.04 (LTS) and configure it with default locale settings.

  2. Create a user called user

  3. Uninstall conflicting packages.

  • openjdk-jre > 8[1]
  • sudo apt list --installed | grep jdk (To check for existing packages)
  1. Run sudo apt-get update

  2. Install necessary packages

  • sudo apt-get install -y git
  • sudo apt-get install -y curl
  • sudo apt-get install -y wget
  • sudo apt-get install -y python2
  • sudo apt-get install -y python
  • sudo apt-get install -y openjdk-8-jre-headless
  • sudo apt-get install -y lsb-core
  1. Install .NET Core 3.1 SDK using the working instructions
  • curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  • sudo apt-add-repository https://packages.microsoft.com/ubuntu/20.04/prod
  • sudo apt-get update
  • sudo apt-get install -y dotnet-sdk-3.1
  1. Install the Chromium Depot Tools, which manage the Chromium project of which WebRtc is a part.
  • cd /home/user
  • git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
  1. Add depot tools to the front of the path and append to .bashrc
  • export PATH=/home/user/depot_tools:$PATH
  • echo "export PATH=/home/user/depot_tools:$PATH" >> ~/.bashrc [2]
  1. Fetch WebRTC into webrtc-checkout. 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
  1. Perform gclient sync. This will create the initial gclient files.
  • gclient sync
  1. Add the Android target OS to the .gclient file and re-sync.
  • cd src
  • echo "target_os = [ 'android' ]" >> ../.gclient
  • gclient sync
  1. Install the Android Build Dependencies and run the hooks
  • build/install-build-deps-android.sh
  • gclient runhooks
  1. Fetch the fork over the existing checkout
  • git remote add ucl https://github.com/UCL-VR/webrtc.git
  • git fetch ucl
  • git checkout ucl/ucl-main
  1. Re-sync (with Delete, as there may be newer dependencies added since the last update to the fork).
  • gclient sync -D
  1. Enter the Unity directory.
  • cd /home/user/webrtc-checkout/src/sdk/dotnet/unity
  1. Build for (a) Linux or (b) Android
  • dotnet build unity.msbuildproj -property:Targets=LinuxX64 [3]
  • dotnet build unity.msbuildproj -property:Targets=Android

[1] Newer versions of the JRE are sometimes installed on the ISO offered by Canonical. [2] Todo; stop this actually evaluating whole path into .bashrc [3] The debug build for Linux exceeds GitHubs file size limit. When building to distribute, build for Release by adding -property:Configuration=Release to the build command.

Clone this wiki locally