Skip to content

Commit 381f8ed

Browse files
committed
chore: upgrade libwebrtc M85 (#177)
* wip * wip * fixed build error * add webrtcd.lib for debug * fixed cmake to build for debug * debug build on macos * create static library for debug build on Linux * upgrade libwebrtc version M85 * change webrtc version * fixed library build error * fixed build error * fixed build error * fixed error
1 parent 988a3f8 commit 381f8ed

File tree

19 files changed

+766
-91
lines changed

19 files changed

+766
-91
lines changed

.yamato/meta/environments.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ upm:
22
registry_url: https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
33
package_version: stable
44
webrtc_version:
5-
name: M84
5+
name: M85

BuildScripts~/ReplaceText.ps1

Lines changed: 0 additions & 1 deletion
This file was deleted.

BuildScripts~/build_libwebrtc_linux.sh

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,57 @@ then
55
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
66
fi
77

8+
export COMMAND_DIR=$(cd $(dirname $0); pwd)
89
export PATH="$(pwd)/depot_tools:$PATH"
9-
export WEBRTC_VERSION=4147
10+
export WEBRTC_VERSION=4183
1011
export OUTPUT_DIR="$(pwd)/out"
1112
export ARTIFACTS_DIR="$(pwd)/artifacts"
1213

13-
fetch webrtc
14+
if [ ! -e "$(pwd)/src" ]
15+
then
16+
fetch webrtc
17+
cd src
18+
git config --system core.longpaths true
19+
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
20+
cd ..
21+
gclient sync -f
22+
fi
1423

15-
cd src
16-
git config --system core.longpaths true
17-
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
18-
cd ..
24+
# add jsoncpp
25+
patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch"
1926

20-
gclient sync -f
27+
mkdir -p "$ARTIFACTS_DIR/lib"
2128

22-
# add jsoncpp
23-
patch "src/BUILD.gn" < "BuildScripts~/add_jsoncpp.patch"
29+
# generate ninja files for release
30+
gn gen "$OUTPUT_DIR" --root="src" \
31+
--args="is_debug=false target_os=\"linux\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
2432

25-
gn gen "$OUTPUT_DIR" --root="src" --args="is_debug=false target_os=\"linux\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
33+
# build static library for release
34+
ninja -C "$OUTPUT_DIR" webrtc
2635

36+
# cppy static library for release
37+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtc.a"
38+
39+
# generate ninja files for debug
40+
gn gen "$OUTPUT_DIR" --root="src" \
41+
--args="is_debug=true target_os=\"linux\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
42+
43+
# build static library for debug
2744
ninja -C "$OUTPUT_DIR" webrtc
2845

29-
python ./src/tools_webrtc/libs/generate_licenses.py --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
46+
# cppy static library for debug
47+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtcd.a"
48+
49+
# fix error when generate license
50+
patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \
51+
"$COMMAND_DIR/patches/generate_licenses.patch"
52+
53+
python "./src/tools_webrtc/libs/generate_licenses.py" \
54+
--target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
3055

3156
cd src
3257
find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include"
3358

34-
mkdir -p "$ARTIFACTS_DIR/lib"
35-
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib"
36-
3759
cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR"
3860

3961
# create zip

BuildScripts~/build_libwebrtc_macos.sh

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,57 @@ then
55
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
66
fi
77

8+
export COMMAND_DIR=$(cd $(dirname $0); pwd)
89
export PATH="$(pwd)/depot_tools:$PATH"
9-
export WEBRTC_VERSION=4147
10+
export WEBRTC_VERSION=4183
1011
export OUTPUT_DIR="$(pwd)/out"
1112
export ARTIFACTS_DIR="$(pwd)/artifacts"
1213

13-
fetch webrtc
14+
if [ ! -e "$(pwd)/src" ]
15+
then
16+
fetch webrtc
17+
cd src
18+
git config --system core.longpaths true
19+
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
20+
cd ..
21+
gclient sync -f
22+
fi
1423

15-
cd src
16-
git config --system core.longpaths true
17-
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
18-
cd ..
24+
# add jsoncpp
25+
patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch"
1926

20-
gclient sync -f
27+
mkdir -p "$ARTIFACTS_DIR/lib"
2128

22-
# add jsoncpp
23-
patch "src/BUILD.gn" < "BuildScripts~/add_jsoncpp.patch"
29+
# generate ninja files for release
30+
gn gen "$OUTPUT_DIR" --root="src" \
31+
--args="is_debug=false target_os=\"mac\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
2432

25-
gn gen "$OUTPUT_DIR" --root="src" --args="is_debug=false target_os=\"mac\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
33+
# build static library for release
34+
ninja -C "$OUTPUT_DIR" webrtc
2635

36+
# cppy static library for release
37+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtc.a"
38+
39+
# generate ninja files for debug
40+
gn gen "$OUTPUT_DIR" --root="src" \
41+
--args="is_debug=true target_os=\"mac\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
42+
43+
# build static library for debug
2744
ninja -C "$OUTPUT_DIR" webrtc
2845

29-
python ./src/tools_webrtc/libs/generate_licenses.py --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
46+
# cppy static library for debug
47+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtcd.a"
48+
49+
# fix error when generate license
50+
patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \
51+
"$COMMAND_DIR/patches/generate_licenses.patch"
52+
53+
python "./src/tools_webrtc/libs/generate_licenses.py" \
54+
--target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
3055

3156
cd src
3257
find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include"
3358

34-
mkdir -p "$ARTIFACTS_DIR/lib"
35-
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib"
36-
3759
cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR"
3860

3961
# create zip
Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,76 @@
11
@echo off
22

33
if not exist depot_tools (
4-
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
4+
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
55
)
66

7+
set COMMAND_DIR=%~dp0
78
set PATH=%cd%\depot_tools;%PATH%
8-
set WEBRTC_VERSION=4147
9+
set WEBRTC_VERSION=4183
910
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
1011
set CPPFLAGS=/WX-
1112
set GYP_GENERATORS=ninja,msvs-ninja
1213
set GYP_MSVS_VERSION=2017
1314
set OUTPUT_DIR=out
1415
set ARTIFACTS_DIR=%cd%\artifacts
16+
set PYPI_URL=https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
1517
set vs2017_install=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
1618

17-
cmd /k fetch.bat webrtc
19+
if not exist src (
20+
call fetch.bat webrtc
21+
cd src
22+
call git.bat config --system core.longpaths true
23+
call git.bat checkout refs/remotes/branch-heads/%WEBRTC_VERSION%
24+
cd ..
25+
call gclient.bat sync -f
26+
)
1827

19-
cd src
20-
cmd /k git.bat config --system core.longpaths true
21-
cmd /k git.bat checkout refs/remotes/branch-heads/%WEBRTC_VERSION%
22-
cd ..
28+
rem add jsoncpp
29+
patch -N "src\BUILD.gn" < "%COMMAND_DIR%\patches\add_jsoncpp.patch"
2330

24-
cmd /k gclient.bat sync -f
31+
rem install pywin32
32+
call "%cd%\depot_tools\bootstrap-3_8_0_chromium_8_bin\python\bin\python.exe" ^
33+
-m pip install pywin32 --index-url "%PYPI_URL%" --upgrade
2534

26-
REM add jsoncpp
27-
patch "src\BUILD.gn" < "BuildScripts~\add_jsoncpp.patch"
35+
rem generate ninja for release
36+
call gn.bat gen %OUTPUT_DIR% --root="src" ^
37+
--args="is_debug=false is_clang=false target_cpu=\"x64\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false"
2838

29-
REM install pywin32
30-
cmd /k %cd%\depot_tools\bootstrap-3_8_0_chromium_8_bin\python\bin\python.exe -m pip install pywin32 --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
39+
rem build
40+
ninja.exe -C %OUTPUT_DIR%
3141

32-
cmd /k gn.bat gen %OUTPUT_DIR% --root="src" --args="is_debug=false is_clang=false target_cpu=\"x64\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false"
42+
mkdir "%ARTIFACTS_DIR%\lib"
3343

34-
REM add json.obj in link list of webrtc.ninja
35-
powershell -File ".\BuildScripts~\ReplaceText.ps1" "%OUTPUT_DIR%\obj\webrtc.ninja" "obj/rtc_base/rtc_base/crc32.obj" "obj/rtc_base/rtc_base/crc32.obj obj/rtc_base/rtc_json/json.obj"
36-
type "%OUTPUT_DIR%\obj\webrtc.ninja"
44+
rem copy static library for release build
45+
copy "%OUTPUT_DIR%\obj\webrtc.lib" "%ARTIFACTS_DIR%\lib\webrtc.lib"
3746

38-
REM update LIB_TO_LICENSES_DICT in generate_licenses.py
39-
powershell -File ".\BuildScripts~\ReplaceText.ps1" "src\tools_webrtc\libs\generate_licenses.py" "'ow2_asm': []," "'ow2_asm': [], 'winsdk_samples': [], 'googletest': ['third_party/googletest/src/LICENSE'], 'nasm': ['third_party/nasm/LICENSE'], "
40-
type "src\tools_webrtc\libs\generate_licenses.py"
47+
rem generate ninja for debug build
48+
call gn.bat gen %OUTPUT_DIR% --root="src" ^
49+
--args="is_debug=true is_clang=false target_cpu=\"x64\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false"
4150

51+
rem build
4252
ninja.exe -C %OUTPUT_DIR%
4353

44-
REM generate license
45-
call python.bat .\src\tools_webrtc\libs\generate_licenses.py --target //:default %OUTPUT_DIR% %OUTPUT_DIR%
54+
rem copy static library for debug build
55+
copy "%OUTPUT_DIR%\obj\webrtc.lib" "%ARTIFACTS_DIR%\lib\webrtcd.lib"
56+
57+
rem fix error when generate license
58+
patch -N "%cd%\src\tools_webrtc\libs\generate_licenses.py" < ^
59+
"%COMMAND_DIR%\patches\generate_licenses.patch"
4660

47-
REM unescape license
48-
powershell -File .\Unescape.ps1 %OUTPUT_DIR%\LICENSE.md
61+
rem generate license
62+
call python.bat "%cd%\src\tools_webrtc\libs\generate_licenses.py" ^
63+
--target //:default %OUTPUT_DIR% %OUTPUT_DIR%
4964

50-
REM copy header
51-
xcopy src\*.h %ARTIFACTS_DIR%\include /C /S /I /F /H
65+
rem unescape license
66+
powershell -File "%COMMAND_DIR%\Unescape.ps1" "%OUTPUT_DIR%\LICENSE.md"
5267

53-
REM copy lib
54-
mkdir %ARTIFACTS_DIR%\lib
55-
for %%G in (webrtc.lib audio_decoder_opus.lib webrtc_opus.lib) do forfiles /P "%cd%\%OUTPUT_DIR%" /S /M %%G /C "cmd /c copy @path %ARTIFACTS_DIR%\lib"
68+
rem copy header
69+
xcopy src\*.h "%ARTIFACTS_DIR%\include" /C /S /I /F /H
5670

57-
REM copy license
58-
copy %OUTPUT_DIR%\LICENSE.md %ARTIFACTS_DIR%
71+
rem copy license
72+
copy "%OUTPUT_DIR%\LICENSE.md" "%ARTIFACTS_DIR%"
5973

60-
REM create zip
74+
rem create zip
6175
cd %ARTIFACTS_DIR%
6276
7z a -tzip webrtc-win.zip *

BuildScripts~/build_plugin.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

3-
set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M84/webrtc-win.zip
3+
set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M85/webrtc-win.zip
44
set SOLUTION_DIR=%cd%\Plugin~
55

66
echo -------------------

BuildScripts~/build_plugin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M84/webrtc-linux.zip
3+
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M85/webrtc-linux.zip
44
export SOLUTION_DIR=$(pwd)/Plugin~
55

66
# Download LibWebRTC

BuildScripts~/build_plugin_mac.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M84/webrtc-mac.zip
3+
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M85/webrtc-mac.zip
44
export SOLUTION_DIR=$(pwd)/Plugin~
55

66
# Install cmake
File renamed without changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- ./src/tools_webrtc/libs/generate_licenses.py 2020-08-08 11:02:57.064616700 +0900
2+
+++ ./src/tools_webrtc/libs/generate_licenses.py.edited 2020-08-29 10:58:18.826417100 +0900
3+
@@ -70,6 +70,7 @@ LIB_TO_LICENSES_DICT = {
4+
'g722': ['modules/third_party/g722/LICENSE'],
5+
'ooura': ['common_audio/third_party/ooura/LICENSE'],
6+
'spl_sqrt_floor': ['common_audio/third_party/spl_sqrt_floor/LICENSE'],
7+
+ 'catapult': ['third_party/catapult/LICENSE'],
8+
9+
# TODO(bugs.webrtc.org/1110): Remove this hack. This is not a lib.
10+
# For some reason it is listed as so in _GetThirdPartyLibraries.

0 commit comments

Comments
 (0)