diff --git a/.yamato/package.metafile b/.yamato/package.metafile index cba8a5234..058ec5a13 100644 --- a/.yamato/package.metafile +++ b/.yamato/package.metafile @@ -2,7 +2,7 @@ upm: registry_url: https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm package_version: stable webrtc_version: - name: M92 + name: M107 editors: - version: 2019.4 diff --git a/.yamato/upm-ci-libwebrtc.yml b/.yamato/upm-ci-libwebrtc.yml index b62788546..ad39f2b55 100644 --- a/.yamato/upm-ci-libwebrtc.yml +++ b/.yamato/upm-ci-libwebrtc.yml @@ -3,17 +3,17 @@ platforms: - name: win type: Unity::VM - image: renderstreaming/win10:v0.3.13-1084239 + image: renderstreaming/win10:v0.4.0-1250406 flavor: b1.xlarge build_command: BuildScripts~/build_libwebrtc_win.cmd - name: macos type: Unity::VM::osx - image: package-ci/mac:v1.20.0-1079282 + image: package-ci/macos-12:v4.3.0-1248181 flavor: m1.mac build_command: BuildScripts~/build_libwebrtc_macos.sh - name: linux type: Unity::VM - image: cds-ops/ubuntu-18.04-base:v1.6.0-546186 + image: package-ci/ubuntu-20.04:v1.4.0-1235639 flavor: b1.xlarge build_command: BuildScripts~/build_libwebrtc_linux.sh - name: android @@ -23,7 +23,7 @@ platforms: build_command: BuildScripts~/build_libwebrtc_android.sh - name: ios type: Unity::VM::osx - image: package-ci/mac:v1.20.0-1079282 + image: package-ci/macos-12:v4.3.0-1248181 flavor: m1.mac build_command: BuildScripts~/build_libwebrtc_ios.sh projects: diff --git a/BuildScripts~/build_libwebrtc_android.sh b/BuildScripts~/build_libwebrtc_android.sh index d488d15c3..05b76f284 100755 --- a/BuildScripts~/build_libwebrtc_android.sh +++ b/BuildScripts~/build_libwebrtc_android.sh @@ -7,9 +7,10 @@ fi export COMMAND_DIR=$(cd $(dirname $0); pwd) export PATH="$(pwd)/depot_tools:$PATH" -export WEBRTC_VERSION=4515 +export WEBRTC_VERSION=5304 export OUTPUT_DIR="$(pwd)/out" export ARTIFACTS_DIR="$(pwd)/artifacts" +export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3" if [ ! -e "$(pwd)/src" ] then @@ -19,12 +20,25 @@ then sudo git config --system core.longpaths true git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION" cd .. - gclient sync -f + gclient sync -D --force --reset fi -# add jsoncpp +# Add jsoncpp patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch" +# Add visibility libunwind +patch -N "src/buildtools/third_party/libunwind/BUILD.gn" < "$COMMAND_DIR/patches/add_visibility_libunwind.patch" + +# Add deps libunwind +patch -N "src/build/config/BUILD.gn" < "$COMMAND_DIR/patches/add_deps_libunwind.patch" + +# downgrade JDK11 to JDK8 because Unity supports OpenJDK version 1.8. +# https://docs.unity3d.com/Manual/android-sdksetup.html +pushd "src/build" +git apply "$COMMAND_DIR/patches/downgrade_JDK.patch" +popd + + mkdir -p "$ARTIFACTS_DIR/lib" for target_cpu in "arm64" @@ -34,8 +48,10 @@ do for is_debug in "true" "false" do # generate ninja files + # use `treat_warnings_as_errors` option to avoid deprecation warnings gn gen "$OUTPUT_DIR" --root="src" \ --args="is_debug=${is_debug} \ + is_java_debug=${is_debug} \ target_os=\"android\" \ target_cpu=\"${target_cpu}\" \ rtc_use_h264=false \ @@ -43,7 +59,8 @@ do rtc_build_examples=false \ is_component_build=false \ use_rtti=true \ - use_custom_libcxx=false" + use_custom_libcxx=false \ + treat_warnings_as_errors=false" # build static library ninja -C "$OUTPUT_DIR" webrtc @@ -62,17 +79,20 @@ pushd src for is_debug in "true" "false" do - python tools_webrtc/android/build_aar.py \ + # use `treat_warnings_as_errors` option to avoid deprecation warnings + "$PYTHON3_BIN" tools_webrtc/android/build_aar.py \ --build-dir $OUTPUT_DIR \ --output $OUTPUT_DIR/libwebrtc.aar \ --arch arm64-v8a \ --extra-gn-args "is_debug=${is_debug} \ + is_java_debug=${is_debug} \ rtc_use_h264=false \ rtc_include_tests=false \ rtc_build_examples=false \ is_component_build=false \ use_rtti=true \ - use_custom_libcxx=false" + use_custom_libcxx=false \ + treat_warnings_as_errors=false" filename="libwebrtc.aar" if [ $is_debug = "true" ]; then @@ -84,12 +104,8 @@ done popd -# fix error when generate license -patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \ - "$COMMAND_DIR/patches/generate_licenses.patch" - -python "./src/tools_webrtc/libs/generate_licenses.py" \ - --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR" +"$PYTHON3_BIN" "./src/tools_webrtc/libs/generate_licenses.py" \ + --target :webrtc "$OUTPUT_DIR" "$OUTPUT_DIR" cd src find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include" @@ -98,4 +114,4 @@ cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR" # create zip cd "$ARTIFACTS_DIR" -zip -r webrtc-android.zip lib include LICENSE.md \ No newline at end of file +zip -r webrtc-android.zip lib include LICENSE.md diff --git a/BuildScripts~/build_libwebrtc_ios.sh b/BuildScripts~/build_libwebrtc_ios.sh index 667e0c238..505b517a2 100755 --- a/BuildScripts~/build_libwebrtc_ios.sh +++ b/BuildScripts~/build_libwebrtc_ios.sh @@ -7,9 +7,10 @@ fi export COMMAND_DIR=$(cd $(dirname $0); pwd) export PATH="$(pwd)/depot_tools:$PATH" -export WEBRTC_VERSION=4515 +export WEBRTC_VERSION=5304 export OUTPUT_DIR="$(pwd)/out" export ARTIFACTS_DIR="$(pwd)/artifacts" +export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3" if [ ! -e "$(pwd)/src" ] then @@ -19,7 +20,7 @@ then sudo git config --system core.longpaths true git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION" cd .. - gclient sync -f + gclient sync -D --force --reset fi # add jsoncpp @@ -44,18 +45,15 @@ do # See below for details. # https://bugs.chromium.org/p/webrtc/issues/detail?id=11729 # - # note: `use_xcode_clang=true` is for using bitcode. - # gn gen "$OUTPUT_DIR" --root="src" \ - --args="is_debug=${is_debug} \ - target_os=\"ios\" \ - target_cpu=\"${target_cpu}\" \ - rtc_use_h264=false \ - treat_warnings_as_errors=false \ - use_xcode_clang=true \ - enable_ios_bitcode=true \ - ios_enable_code_signing=false \ - rtc_include_tests=false \ + --args="is_debug=${is_debug} \ + target_os=\"ios\" \ + target_cpu=\"${target_cpu}\" \ + rtc_use_h264=false \ + use_custom_libcxx=false \ + treat_warnings_as_errors=false \ + ios_enable_code_signing=false \ + rtc_include_tests=false \ rtc_build_examples=false" # build static library @@ -81,12 +79,8 @@ do rm -r "$ARTIFACTS_DIR/lib/x64" done -# fix error when generate license -patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \ - "$COMMAND_DIR/patches/generate_licenses.patch" - -vpython "./src/tools_webrtc/libs/generate_licenses.py" \ - --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR" +"$PYTHON3_BIN" "./src/tools_webrtc/libs/generate_licenses.py" \ + --target :webrtc "$OUTPUT_DIR" "$OUTPUT_DIR" cd src find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include" diff --git a/BuildScripts~/build_libwebrtc_linux.sh b/BuildScripts~/build_libwebrtc_linux.sh index 1b4657582..711d596b7 100755 --- a/BuildScripts~/build_libwebrtc_linux.sh +++ b/BuildScripts~/build_libwebrtc_linux.sh @@ -7,9 +7,10 @@ fi export COMMAND_DIR=$(cd $(dirname $0); pwd) export PATH="$(pwd)/depot_tools:$PATH" -export WEBRTC_VERSION=4515 +export WEBRTC_VERSION=5304 export OUTPUT_DIR="$(pwd)/out" export ARTIFACTS_DIR="$(pwd)/artifacts" +export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3" if [ ! -e "$(pwd)/src" ] then @@ -19,7 +20,7 @@ then sudo git config --system core.longpaths true git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION" cd .. - gclient sync -f + gclient sync -D --force --reset fi # add jsoncpp @@ -32,7 +33,19 @@ do mkdir -p "$ARTIFACTS_DIR/lib/${target_cpu}" for is_debug in "true" "false" do - args="is_debug=${is_debug} target_os=\"linux\" target_cpu=\"${target_cpu}\" 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"; + args="is_debug=${is_debug} \ + target_os=\"linux\" \ + target_cpu=\"${target_cpu}\" \ + use_custom_libcxx=false \ + 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" + if [ $is_debug = "true" ]; then args="${args} is_asan=true is_lsan=true"; fi @@ -53,12 +66,8 @@ do done done -# fix error when generate license -patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \ - "$COMMAND_DIR/patches/generate_licenses.patch" - -vpython "./src/tools_webrtc/libs/generate_licenses.py" \ - --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR" +"$PYTHON3_BIN" "./src/tools_webrtc/libs/generate_licenses.py" \ + --target :webrtc "$OUTPUT_DIR" "$OUTPUT_DIR" cd src find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include" diff --git a/BuildScripts~/build_libwebrtc_macos.sh b/BuildScripts~/build_libwebrtc_macos.sh index c43de492f..8f5d47a83 100755 --- a/BuildScripts~/build_libwebrtc_macos.sh +++ b/BuildScripts~/build_libwebrtc_macos.sh @@ -7,9 +7,10 @@ fi export COMMAND_DIR=$(cd $(dirname $0); pwd) export PATH="$(pwd)/depot_tools:$PATH" -export WEBRTC_VERSION=4515 +export WEBRTC_VERSION=5304 export OUTPUT_DIR="$(pwd)/out" export ARTIFACTS_DIR="$(pwd)/artifacts" +export PYTHON3_BIN="$(pwd)/depot_tools/python-bin/python3" if [ ! -e "$(pwd)/src" ] then @@ -19,7 +20,7 @@ then sudo git config --system core.longpaths true git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION" cd .. - gclient sync -f + gclient sync -D --force --reset fi # add jsoncpp @@ -44,6 +45,7 @@ do --args="is_debug=${is_debug} \ target_os=\"mac\" \ target_cpu=\"${target_cpu}\" \ + use_custom_libcxx=false \ rtc_include_tests=false \ rtc_build_examples=false \ rtc_use_h264=false \ @@ -51,8 +53,7 @@ do enable_iterator_debugging=false \ is_component_build=false \ use_rtti=true \ - rtc_use_x11=false \ - libcxx_abi_unstable=false" + rtc_use_x11=false" # build static library ninja -C "$OUTPUT_DIR" webrtc @@ -77,12 +78,8 @@ do rm -r "$ARTIFACTS_DIR/lib/x64" done -# fix error when generate license -patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \ - "$COMMAND_DIR/patches/generate_licenses.patch" - -vpython "./src/tools_webrtc/libs/generate_licenses.py" \ - --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR" +"$PYTHON3_BIN" "./src/tools_webrtc/libs/generate_licenses.py" \ + --target :webrtc "$OUTPUT_DIR" "$OUTPUT_DIR" cd src find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include" diff --git a/BuildScripts~/build_libwebrtc_win.cmd b/BuildScripts~/build_libwebrtc_win.cmd index dfa75bd44..e34a108cb 100644 --- a/BuildScripts~/build_libwebrtc_win.cmd +++ b/BuildScripts~/build_libwebrtc_win.cmd @@ -6,9 +6,8 @@ if not exist depot_tools ( set COMMAND_DIR=%~dp0 set PATH=%cd%\depot_tools;%PATH% -set WEBRTC_VERSION=4515 +set WEBRTC_VERSION=5304 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 -set CPPFLAGS=/WX- set GYP_GENERATORS=ninja,msvs-ninja set GYP_MSVS_VERSION=2019 set OUTPUT_DIR=out @@ -24,12 +23,18 @@ if not exist src ( call git.bat config --system core.longpaths true call git.bat checkout refs/remotes/branch-heads/%WEBRTC_VERSION% cd .. - call gclient.bat sync -f + call gclient.bat sync -D --force --reset ) rem add jsoncpp patch -N "src\BUILD.gn" < "%COMMAND_DIR%\patches\add_jsoncpp.patch" +rem fix towupper +patch -N "src\modules\desktop_capture\win\full_screen_win_application_handler.cc" < "%COMMAND_DIR%\patches\fix_towupper.patch" + +rem fix abseil +patch -N "src\third_party\abseil-cpp/absl/base/config.h" < "%COMMAND_DIR%\patches\fix_abseil.patch" + rem install pywin32 call "%cd%\depot_tools\bootstrap-3_8_0_chromium_8_bin\python\bin\python.exe" ^ -m pip install pywin32 --index-url "%PYPI_URL%" --upgrade @@ -44,10 +49,10 @@ for %%i in (x64) do ( rem generate ninja for release call gn.bat gen %OUTPUT_DIR% --root="src" ^ - --args="is_debug=%%j is_clang=false target_cpu=\"%%i\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false" + --args="is_debug=%%j is_clang=true target_cpu=\"%%i\" use_custom_libcxx=false rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false" rem build - ninja.exe -C %OUTPUT_DIR% + ninja.exe -C %OUTPUT_DIR% webrtc set filename= if true==%%j ( @@ -63,13 +68,9 @@ for %%i in (x64) do ( endlocal -rem fix error when generate license -patch -N "%cd%\src\tools_webrtc\libs\generate_licenses.py" < ^ - "%COMMAND_DIR%\patches\generate_licenses.patch" - rem generate license call python.bat "%cd%\src\tools_webrtc\libs\generate_licenses.py" ^ - --target //:default %OUTPUT_DIR% %OUTPUT_DIR% + --target :webrtc %OUTPUT_DIR% %OUTPUT_DIR% rem unescape license powershell -File "%COMMAND_DIR%\Unescape.ps1" "%OUTPUT_DIR%\LICENSE.md" diff --git a/BuildScripts~/patches/README.md b/BuildScripts~/patches/README.md new file mode 100644 index 000000000..b4c29396a --- /dev/null +++ b/BuildScripts~/patches/README.md @@ -0,0 +1,102 @@ +# Patch + + +## Workaround for gn error for building Android libwebrtc + +Building libwebrtc for Android with `use_custom_libcxx=false` args for gn will get error. More details [here](https://bugs.chromium.org/p/webrtc/issues/detail?id=13535#c8). + +### Patch files + +- add_visibility_lubunwind.patch +- add_deps_libunwind.patch + +### Example + +``` +# `src` is a root directory of libwebrtc. + +patch -N "src/buildtools/third_party/libunwind/BUILD.gn" < "$COMMAND_DIR/patches/add_visibility_libunwind.patch" + +patch -N "src/build/config/BUILD.gn" < "$COMMAND_DIR/patches/add_deps_libunwind.patch" +``` + +## Workaround for runtime error on Android + +Unity supports OpenJDK version 1.8 for building Android app. You can see [the table](https://docs.unity3d.com/Manual/android-sdksetup.html) shows the JDK version that each Unity version supports. However, JDK version for libwebrtc has been updated in [this commit](https://source.chromium.org/chromium/chromium/src/+/ff333588f945ab6438a98a8d5feabec2be60ccf1). We made a patch to downgrade the JDK. + +### Patch files + +- downgrade_JDK.patch + +### Example + +``` +# `src` is a root directory of libwebrtc. + +pushd "src/build" +git apply "BuildScripts~\patches\downgrade_JDK.patch" +``` + + +## Workaround for gn error for building Windows libwebrtc + +Building libwebrtc for Windows with `use_custom_libcxx=false` args for gn will get error. + +``` +../src/modules/desktop_capture/win/full_screen_win_application_handler.cc(281,18): error: no member named 'towupper' in namespace 'std'; did you mean simply 'towupper'? +std::towupper); +^~~~~~~~~~~~~ +towupper +../../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/ucrt\corecrt_wctype.h(102,40): note: 'towupper' declared here +_Check_return_ _ACRTIMP wint_t __cdecl towupper(_In_ wint_t _C); +^ +``` + +### Patch files + +- fix_towupper.patch + +### Example + +``` +# `src` is a root directory of libwebrtc. + +patch -N "src\modules\desktop_capture\win\full_screen_win_application_handler.cc" < "BuildScripts~\patches\fix_towupper.patch" +``` + +## Workaround for abseil library building Windows libwebrtc + +Building libwebrtc for Windows with `use_custom_libcxx=false` args for gn will get error. Referenced [here](https://github.com/abseil/abseil-cpp/pull/1289) for the patch file. + +``` +../src/audio/audio_send_stream.cc(344,25): error: object of type 'absl::optional>' cannot be assigned because its copy assignment operator is implicitly deleted +frame_length_range_ = encoder->GetFrameLengthRange(); +^ +../src/third_party/abseil-cpp\absl/types/optional.h(279,13): note: explicitly defaulted function was implicitly deleted here +optional& operator=(const optional& src) = default; +^ +../src/third_party/abseil-cpp\absl/types/optional.h(119,18): note: copy assignment operator of 'optional>' is implicitly deleted because base class 'optional_internal::optional_data>' has a deleted copy assignment operator +class optional : private optional_internal::optional_data, +^ +../src/third_party/abseil-cpp\absl/types/internal/optional.h(189,32): note: copy assignment operator of 'optional_data, true>' is implicitly deleted because base class 'optional_data_base>' has a deleted copy assignment operator +class optional_data : public optional_data_base { +^ +../src/third_party/abseil-cpp\absl/types/internal/optional.h(145,28): note: copy assignment operator of 'optional_data_base>' is implicitly deleted because base class 'optional_data_dtor_base>' has a deleted copy assignment operator +class optional_data_base : public optional_data_dtor_base { +^ +../src/third_party/abseil-cpp\absl/types/internal/optional.h(131,7): note: copy assignment operator of 'optional_data_dtor_base, true>' is implicitly deleted because variant field 'data_' has a non-trivial copy assignment operator +T data_; +^ +``` + +Patch file + +- fix_abseil.patch + +### Example + +``` +# `src` is a root directory of libwebrtc. + +patch -N "src\third_party\abseil-cpp/absl/base/config.h" < "BuildScripts~\patches\fix_abseil.patch" +``` \ No newline at end of file diff --git a/BuildScripts~/patches/add_deps_libunwind.patch b/BuildScripts~/patches/add_deps_libunwind.patch new file mode 100644 index 000000000..9b02f165e --- /dev/null +++ b/BuildScripts~/patches/add_deps_libunwind.patch @@ -0,0 +1,13 @@ +diff --git a/config/BUILD.gn b/config/BUILD.gn +index 265d4bc07..71ec29437 100644 +--- a/config/BUILD.gn ++++ b/config/BUILD.gn +@@ -241,6 +241,8 @@ group("common_deps") { + + if (use_custom_libcxx) { + public_deps += [ "//buildtools/third_party/libc++" ] ++ } else { ++ public_deps += [ "//buildtools/third_party/libunwind" ] + } + + if (use_afl) { diff --git a/BuildScripts~/patches/add_visibility_libunwind.patch b/BuildScripts~/patches/add_visibility_libunwind.patch new file mode 100644 index 000000000..166d87fcb --- /dev/null +++ b/BuildScripts~/patches/add_visibility_libunwind.patch @@ -0,0 +1,13 @@ +diff --git a/third_party/libunwind/BUILD.gn b/third_party/libunwind/BUILD.gn +index a8287bf..3ca6bc5 100644 +--- a/third_party/libunwind/BUILD.gn ++++ b/third_party/libunwind/BUILD.gn +@@ -20,7 +20,7 @@ config("libunwind_config") { + } + + source_set("libunwind") { +- visibility = [] ++ visibility = [ "//build/config:common_deps"] + if (is_fuchsia) { + visibility += [ "//buildtools/third_party/libc++abi" ] + } else if (is_android) { diff --git a/BuildScripts~/patches/downgrade_JDK.patch b/BuildScripts~/patches/downgrade_JDK.patch new file mode 100644 index 000000000..7cf4beae7 --- /dev/null +++ b/BuildScripts~/patches/downgrade_JDK.patch @@ -0,0 +1,285 @@ +diff --git a/android/gyp/compile_java.py b/android/gyp/compile_java.py +index 7953731c7..acb7e973e 100755 +--- a/android/gyp/compile_java.py ++++ b/android/gyp/compile_java.py +@@ -600,7 +600,16 @@ def _ParseOptions(argv): + '--generated-dir', + help='Subdirectory within target_gen_dir to place extracted srcjars and ' + 'annotation processor output for codesearch to find.') +- parser.add_option('--classpath', action='append', help='Classpath to use.') ++ parser.add_option( ++ '--bootclasspath', ++ action='append', ++ default=[], ++ help='Boot classpath for javac. If this is specified multiple times, ' ++ 'they will all be appended to construct the classpath.') ++ parser.add_option( ++ '--java-version', ++ help='Java language version to use in -source and -target args to javac.') ++ parser.add_option('--classpath', action='append', help='Classpath to use.') + parser.add_option( + '--processorpath', + action='append', +@@ -657,6 +666,7 @@ def _ParseOptions(argv): + options, args = parser.parse_args(argv) + build_utils.CheckOptions(options, parser, required=('jar_path', )) + ++ options.bootclasspath = build_utils.ParseGnList(options.bootclasspath) + options.classpath = build_utils.ParseGnList(options.classpath) + options.processorpath = build_utils.ParseGnList(options.processorpath) + options.java_srcjars = build_utils.ParseGnList(options.java_srcjars) +@@ -700,9 +710,6 @@ def main(argv): + + javac_args = [ + '-g', +- # We currently target JDK 11 everywhere. +- '--release', +- '11', + # Chromium only allows UTF8 source files. Being explicit avoids + # javac pulling a default encoding from the user's environment. + '-encoding', +@@ -711,9 +718,6 @@ def main(argv): + # See: http://blog.ltgt.net/most-build-tools-misuse-javac/ + '-sourcepath', + ':', +- # protobuf-generated files fail this check (javadoc has @deprecated, +- # but method missing @Deprecated annotation). +- '-Xlint:-dep-ann', + ] + + if options.enable_errorprone: +@@ -743,12 +747,31 @@ def main(argv): + if not ERRORPRONE_CHECKS_TO_APPLY: + javac_args += ['-XDshould-stop.ifNoError=FLOW'] + ++ if options.java_version: ++ javac_args.extend([ ++ '-source', ++ options.java_version, ++ '-target', ++ options.java_version, ++ ]) ++ if options.java_version == '1.8': ++ # Android's boot jar doesn't contain all java classes. ++ options.bootclasspath.append(build_utils.RT_JAR_PATH) ++ + # This effectively disables all annotation processors, even including + # annotation processors in service provider configuration files named + # META-INF/. See the following link for reference: + # https://docs.oracle.com/en/java/javase/11/tools/javac.html + javac_args.extend(['-proc:none']) + ++ if options.bootclasspath: ++ # if we are targeting source code higher than java 8, we cannot use ++ # -bootclasspath anymore (deprecated). Instead just prepend the classpath. ++ if options.java_version != '1.8': ++ options.classpath = options.bootclasspath + options.classpath ++ else: ++ javac_args.extend(['-bootclasspath', ':'.join(options.bootclasspath)]) ++ + if options.processorpath: + javac_args.extend(['-processorpath', ':'.join(options.processorpath)]) + if options.processor_args: +@@ -757,7 +780,8 @@ def main(argv): + + javac_args.extend(options.javac_arg) + +- classpath_inputs = options.classpath + options.processorpath ++ classpath_inputs = ( ++ options.bootclasspath + options.classpath + options.processorpath) + + depfile_deps = classpath_inputs + # Files that are already inputs in GN should go in input_paths. +diff --git a/android/gyp/turbine.py b/android/gyp/turbine.py +index 61935a6de..432c3cac7 100755 +--- a/android/gyp/turbine.py ++++ b/android/gyp/turbine.py +@@ -33,6 +33,15 @@ def main(argv): + action='append', + default=[], + help='List of srcjars to include in compilation.') ++ parser.add_argument( ++ '--bootclasspath', ++ action='append', ++ default=[], ++ help='Boot classpath for javac. If this is specified multiple times, ' ++ 'they will all be appended to construct the classpath.') ++ parser.add_argument( ++ '--java-version', ++ help='Java language version to use in -source and -target args to javac.') + parser.add_argument('--classpath', action='append', help='Classpath to use.') + parser.add_argument( + '--processors', +@@ -57,6 +66,7 @@ def main(argv): + help='Treat all warnings as errors.') + options, unknown_args = parser.parse_known_args(argv) + ++ options.bootclasspath = build_utils.ParseGnList(options.bootclasspath) + options.classpath = build_utils.ParseGnList(options.classpath) + options.processorpath = build_utils.ParseGnList(options.processorpath) + options.processors = build_utils.ParseGnList(options.processors) +@@ -71,11 +81,7 @@ def main(argv): + cmd = build_utils.JavaCmd(options.warnings_as_errors) + [ + '-classpath', options.turbine_jar_path, 'com.google.turbine.main.Main' + ] +- javac_cmd = [ +- # We currently target JDK 11 everywhere. +- '--release', +- '11', +- ] ++ javac_cmd = [] + + # Turbine reads lists from command line args by consuming args until one + # starts with double dash (--). Thus command line args should be grouped +@@ -84,6 +90,22 @@ def main(argv): + cmd += ['--processors'] + cmd += options.processors + ++ if options.java_version: ++ javac_cmd.extend([ ++ '-source', ++ options.java_version, ++ '-target', ++ options.java_version, ++ ]) ++ if options.java_version == '1.8': ++ # Android's boot jar doesn't contain all java classes. ++ options.bootclasspath.append(build_utils.RT_JAR_PATH) ++ ++ if options.bootclasspath: ++ cmd += ['--bootclasspath'] ++ for bootclasspath in options.bootclasspath: ++ cmd += bootclasspath.split(':') ++ + if options.processorpath: + cmd += ['--processorpath'] + cmd += options.processorpath +@@ -110,9 +132,10 @@ def main(argv): + cmd += ['--sources'] + cmd += ['@' + files_rsp_path] + +- cmd += ['--javacopts'] +- cmd += javac_cmd +- cmd += ['--'] # Terminate javacopts ++ if javac_cmd: ++ cmd.append('--javacopts') ++ cmd += javac_cmd ++ cmd.append('--') # Terminate javacopts + + # Use AtomicOutput so that output timestamps are not updated when outputs + # are not changed. +@@ -136,8 +159,8 @@ def main(argv): + if options.depfile: + # GN already knows of the java files, so avoid listing individual java files + # in the depfile. +- depfile_deps = (options.classpath + options.processorpath + +- options.java_srcjars) ++ depfile_deps = (options.bootclasspath + options.classpath + ++ options.processorpath + options.java_srcjars) + build_utils.WriteDepfile(options.depfile, options.jar_path, depfile_deps) + + +diff --git a/android/gyp/util/build_utils.py b/android/gyp/util/build_utils.py +index af19f14fb..b5784c0ab 100644 +--- a/android/gyp/util/build_utils.py ++++ b/android/gyp/util/build_utils.py +@@ -37,6 +37,8 @@ DIR_SOURCE_ROOT = os.path.relpath( + JAVA_HOME = os.path.join(DIR_SOURCE_ROOT, 'third_party', 'jdk', 'current') + JAVAC_PATH = os.path.join(JAVA_HOME, 'bin', 'javac') + JAVAP_PATH = os.path.join(JAVA_HOME, 'bin', 'javap') ++RT_JAR_PATH = os.path.join(DIR_SOURCE_ROOT, 'third_party', 'jdk', 'extras', ++ 'java_8', 'jre', 'lib', 'rt.jar') + + try: + string_types = basestring +diff --git a/config/android/internal_rules.gni b/config/android/internal_rules.gni +index 822116480..2c576b9c2 100644 +--- a/config/android/internal_rules.gni ++++ b/config/android/internal_rules.gni +@@ -1714,19 +1714,6 @@ if (enable_java_templates) { + } + } + if (_desugar_needs_classpath) { +- if (defined(invoker.unprocessed_jar_path)) { +- # Cannot use header jar for the active jar, because it does not +- # contain anonymous classes. https://crbug.com/1342018#c5 +- # Cannot use processed .jar here because it might have classes +- # filtered out via jar_excluded_patterns. +- # Must come first in classpath in order to take precedence over +- # deps that defined the same classes (via jar_excluded_patterns). +- args += [ +- "--classpath", +- rebase_path(invoker.unprocessed_jar_path, root_build_dir), +- ] +- inputs += [ invoker.unprocessed_jar_path ] +- } + _desugar_dependencies_path = + "$target_gen_dir/$target_name.desugardeps" + args += [ +@@ -1743,6 +1730,15 @@ if (enable_java_templates) { + rebase_path(invoker.desugar_jars_paths, root_build_dir) + args += [ "--classpath=${_rebased_desugar_jars_paths}" ] + } ++ if (defined(invoker.final_ijar_path)) { ++ # Need to include the input .interface.jar on the classpath in order to make ++ # jar_excluded_patterns classes visible to desugar. ++ args += [ ++ "--classpath", ++ rebase_path(invoker.final_ijar_path, root_build_dir), ++ ] ++ inputs += [ invoker.final_ijar_path ] ++ } + } else { + not_needed(invoker, [ "desugar_jars_paths" ]) + } +@@ -3048,11 +3044,6 @@ if (enable_java_templates) { + get_label_info(":${target_name}", "label_no_toolchain"), + ] + +- # SDK jar must be first on classpath. +- if (invoker.include_android_sdk) { +- args += [ "--classpath=@FileArg($_rebased_build_config:android:sdk_interface_jars)" ] +- } +- + if (defined(invoker.header_jar_path)) { + inputs += [ invoker.header_jar_path ] + args += [ +@@ -3090,6 +3081,9 @@ if (enable_java_templates) { + ] + } + ++ if (invoker.supports_android || invoker.use_turbine) { ++ args += [ "--java-version=1.8" ] ++ } + if (use_java_goma) { + args += [ "--gomacc-path=$goma_dir/gomacc" ] + +@@ -3102,6 +3096,9 @@ if (enable_java_templates) { + if (enable_kythe_annotations && !invoker.enable_errorprone) { + args += [ "--enable-kythe-annotations" ] + } ++ if (invoker.include_android_sdk) { ++ args += [ "--bootclasspath=@FileArg($_rebased_build_config:android:sdk_interface_jars)" ] ++ } + if (_chromium_code) { + args += [ "--chromium-code=1" ] + if (treat_warnings_as_errors) { +@@ -3771,6 +3768,7 @@ if (enable_java_templates) { + java_sources_file = _java_sources_file + } + chromium_code = _chromium_code ++ supports_android = _supports_android + include_android_sdk = _is_robolectric || _requires_android + } + } +@@ -3987,8 +3985,8 @@ if (enable_java_templates) { + if (enable_desugar) { + # Desugaring with D8 requires full classpath. + build_config = _build_config +- unprocessed_jar_path = _unprocessed_jar_path +- deps += _header_classpath_deps + _unprocessed_jar_deps ++ final_ijar_path = _final_ijar_path ++ deps += _header_classpath_deps + [ ":$_header_target_name" ] + } + + enable_multidex = false diff --git a/BuildScripts~/patches/fix_abseil.patch b/BuildScripts~/patches/fix_abseil.patch new file mode 100644 index 000000000..af44a24b7 --- /dev/null +++ b/BuildScripts~/patches/fix_abseil.patch @@ -0,0 +1,20 @@ +diff --git a/abseil-cpp/absl/base/config.h b/abseil-cpp/absl/base/config.h +index 951310686ca..359116989e8 100644 +--- a/abseil-cpp/absl/base/config.h ++++ b/abseil-cpp/absl/base/config.h +@@ -243,6 +243,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || + #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE + #error ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set + #elif defined(_LIBCPP_VERSION) || defined(_MSC_VER) || \ ++ (defined(__clang__) && __clang_major__ >= 15) || \ + (!defined(__clang__) && defined(__GLIBCXX__) && \ + ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(4, 8)) + #define ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1 +@@ -264,6 +265,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || + #elif defined(ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE) + #error ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set + #elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \ ++ (defined(__clang__) && __clang_major__ >= 15) || \ + (!defined(__clang__) && \ + ((ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(7, 4) && defined(__GLIBCXX__)) || \ + (ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(8, 2) && \ diff --git a/BuildScripts~/patches/fix_towupper.patch b/BuildScripts~/patches/fix_towupper.patch new file mode 100644 index 000000000..86a57aa85 --- /dev/null +++ b/BuildScripts~/patches/fix_towupper.patch @@ -0,0 +1,12 @@ +diff --git a/modules/desktop_capture/win/full_screen_win_application_handler.cc b/modules/desktop_capture/win/full_screen_win_application_handler.cc +index f7047dba06..4222dfc01e 100644 +--- a/modules/desktop_capture/win/full_screen_win_application_handler.cc ++++ b/modules/desktop_capture/win/full_screen_win_application_handler.cc +@@ -11,6 +11,7 @@ + #include "modules/desktop_capture/win/full_screen_win_application_handler.h" + + #include ++#include + #include + #include + #include diff --git a/BuildScripts~/patches/generate_licenses.patch b/BuildScripts~/patches/generate_licenses.patch deleted file mode 100644 index f1c217252..000000000 --- a/BuildScripts~/patches/generate_licenses.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- ./src/tools_webrtc/libs/generate_licenses.py 2021-03-09 15:23:53.000000000 +0900 -+++ ./src/tools_webrtc/libs/generate_licenses.py.edited 2021-03-09 15:28:56.000000000 +0900 -@@ -74,6 +74,14 @@ - 'g722': ['modules/third_party/g722/LICENSE'], - 'ooura': ['common_audio/third_party/ooura/LICENSE'], - 'spl_sqrt_floor': ['common_audio/third_party/spl_sqrt_floor/LICENSE'], -+ 'catapult': ['third_party/catapult/LICENSE'], -+ 'modp_b64': ['third_party/modp_b64/LICENSE'], -+ 'double_conversion': ['base/third_party/double_conversion/LICENSE'], -+ 'dynamic_annotations': ['base/third_party/dynamic_annotations/LICENSE'], -+ 'icu': ['base/third_party/icu/LICENSE'], -+ 'symbolize': ['base/third_party/symbolize/LICENSE'], -+ 'xdg_mime': ['base/third_party/xdg_mime/LICENSE'], -+ 'xdg_user_dirs': ['base/third_party/xdg_user_dirs/LICENSE'], - - # TODO(bugs.webrtc.org/1110): Remove this hack. This is not a lib. - # For some reason it is listed as so in _GetThirdPartyLibraries.