@cubicleai/wrtc
uses node-cmake to build
from source. When building from source, in addition to the prerequisites
required by node-cmake, you will need
- Git
- CMake 3.12 or newer
- GCC 5.4 or newer (Linux)
- Xcode 9 or newer (macOS)
- Microsoft Visual Studio 2019 (Windows)
- Check the additional prerequisites listed by WebRTC - although their install is automated by the CMake scripts provided
Once you have the prerequisites, clone the repository, set the SKIP_DOWNLOAD
environment variable to "true", and run npm install
. Just like when
installing prebuilt binaries, you can set the TARGET_ARCH
environment
variable to "arm" or "arm64" to build for armv7l or arm64, respectively. Linux
and macOS users can also set the DEBUG
environment variable for debug builds.
git clone https://github.com/cubicleai/webrtc.git
cd webrtc
SKIP_DOWNLOAD=true npm install
Note: Use $SKIP_DOWNLOAD = 'true'; npm install
on Windows Powershell.
Subsequent builds can be triggered with ncmake
:
./node_modules/.bin/ncmake configure
./node_modules/.bin/ncmake build
You can pass either --debug
or --release
to build a debug or release build of @cubicleai/wrtc
(and the underlying WebRTC
library). Refer to node-cmake for additional command-line options to
ncmake
.
On Linux, we use the system provided version of libstdc++
. You must have the appropriate headers installed. Also,
although we compile WebRTC sources with Clang (downloaded as part of WebRTC's build process), we compile @cubicleai/wrtc
sources with GCC 5.4 or newer.
In order to cross-compile for armv7l on Linux,
- Set
TARGET_ARCH
to "arm". - Install the appropriate toolchain, and set
ARM_TOOLS_PATH
. - On Ubuntu, you may also need g++-arm-linux-gnueabihf.
wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/arm-linux-gnueabihf/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz
tar xf gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz
SKIP_DOWNLOAD=true TARGET_ARCH=arm ARM_TOOLS_PATH=$(pwd)/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf npm install
In order to cross-compile for arm64 on Linux,
- Set
TARGET_ARCH
to "arm64". - Install the appropriate toolchain, and set
ARM_TOOLS_PATH
. - On Ubuntu, you may also need g++-aarch64-linux-gnu.
wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
SKIP_DOWNLOAD=true TARGET_ARCH=arm64 ARM_TOOLS_PATH=$(pwd)/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu npm install
On macOS, we statically link libc++ and libc++abi. Also, we compile WebRTC
sources with the version of Clang downloaded as part of WebRTC's build process,
but we compile @cubicleai/wrtc
sources using the system Clang.
On Windows, we do not compile WebRTC sources with Clang. This is disabled by
passing is_clang=false
to gn gen
.
To fix error Filename too long
, use (optionally with --global
or --system
switches to set for more than just this project):
git config core.longpaths true
Creating symbolic links with MKLINK is used by the build script but is disabled for non-Administrative users by default with a local security policy. On Windows 10, fix this with Run (Windows-R) then gpedit.msc
. Edit key "Local Computer Policy -> Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment -> Create Symbolic Links" and add your user name. Log out and in to change the policy. Note the associated security vunerability.
The Windows SDK debugging tools should be installed. One way to achieve this is to Download the Windows Driver Kit.
Once everything is built, run
npm test
web-platform-tests/wpt defines a suite of WebRTC tests. @cubicleai/wrtc
borrows
a technique from jsdom/jsdom to run these tests in Node.js.
Run the tests with:
npm run wpt:test
These tests are run by CircleCI to ensure @cubicleai/wrtc
remains compatible with the latest versions of Chrome and
Firefox.
npm run test:browsers
npm run test:electron