#!/bin/bash -eu if [ ! -e "$(pwd)/depot_tools" ] then git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git fi export COMMAND_DIR=$(cd $(dirname $0); pwd) export PATH="$(pwd)/depot_tools:$PATH" export WEBRTC_VERSION=4515 export OUTPUT_DIR="$(pwd)/out" export ARTIFACTS_DIR="$(pwd)/artifacts" if [ ! -e "$(pwd)/src" ] then fetch --nohooks webrtc_android cd src sudo sh -c 'echo 127.0.1.1 $(hostname) >> /etc/hosts' sudo git config --system core.longpaths true git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION" cd .. gclient sync -f fi # add jsoncpp patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch" mkdir -p "$ARTIFACTS_DIR/lib" for target_cpu in "arm64" do mkdir -p "$ARTIFACTS_DIR/lib/${target_cpu}" for is_debug in "true" "false" do # generate ninja files gn gen "$OUTPUT_DIR" --root="src" \ --args="is_debug=${is_debug} \ target_os=\"android\" \ target_cpu=\"${target_cpu}\" \ rtc_use_h264=false \ rtc_include_tests=false \ rtc_build_examples=false \ is_component_build=false \ use_rtti=true \ use_custom_libcxx=false" # build static library ninja -C "$OUTPUT_DIR" webrtc filename="libwebrtc.a" if [ $is_debug = "true" ]; then filename="libwebrtcd.a" fi # copy static library cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/${target_cpu}/${filename}" done done pushd src for is_debug in "true" "false" do python 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} \ rtc_use_h264=false \ rtc_include_tests=false \ rtc_build_examples=false \ is_component_build=false \ use_rtti=true \ use_custom_libcxx=false" filename="libwebrtc.aar" if [ $is_debug = "true" ]; then filename="libwebrtc-debug.aar" fi # copy aar cp "$OUTPUT_DIR/libwebrtc.aar" "$ARTIFACTS_DIR/lib/${filename}" 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" cd src find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include" cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR" # create zip cd "$ARTIFACTS_DIR" zip -r webrtc-android.zip lib include LICENSE.md