Repository: vsimon/webrtcbuilds Branch: master Commit: 4bc7a6b7006e Files: 10 Total size: 30.4 KB Directory structure: gitextract_oefc2tdo/ ├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── LICENSE ├── README.md ├── build.sh ├── resource/ │ └── pkgconfig/ │ └── libwebrtc_full.pc.in ├── test/ │ ├── run_tests.sh │ └── simple_app.cc └── util.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.local out depot_tools .DS_Store ================================================ FILE: .gitlab-ci.yml ================================================ before_script: - sed -i "s#universe#universe multiverse#" /etc/apt/sources.list - apt-get update - apt-get install -qq --no-install-recommends ca-certificates stages: - build - test build-webrtc: stage: build script: - ./build.sh $REVISION cache: paths: - out artifacts: expire_in: 6 months paths: - out/*.zip test-webrtc: stage: test before_script: - apt-get update - apt-get install -qq --no-install-recommends unzip pkg-config g++ libssl-dev libnss3-dev libx11-dev libexpat1-dev libasound2 script: - cd out; unzip *.zip; cd - - test/run_tests.sh $(ls -d -1 out/webrtc*/) dependencies: - build-webrtc ================================================ FILE: .travis.yml ================================================ language: cpp sudo: required os: - linux - osx osx_image: xcode9.3 addons: apt: sources: - ubuntu-toolchain-r-test packages: # Update the default 'trusty' linker and gcc version for tests to link and pass. - g++-5 - binutils-2.26 env: global: - LINUX_PICKLE_URL=https://www.dropbox.com/s/yclmzq1n63cminb/linux-pickle.tar.gz?dl=0 - OSX_PICKLE_URL=https://www.dropbox.com/s/m23s3l9g1s9yw87/osx-pickle.tar.gz?dl=0 before_script: # Update the default 'trusty' linker and gcc version for tests to link and pass. - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/ld ld /usr/lib/binutils-2.26/bin/ld 90; fi # To help prevent timeouts, download a 'pickled' .tar.gz archive of the linux # webrtc checkout. LINUX_PICKLE_URL was created with: # `GZIP=-9 tar zcvf linux-pickle.tar.gz .` - mkdir -p out - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_retry curl -L $LINUX_PICKLE_URL -o pickle.tar.gz; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then travis_retry curl -L $OSX_PICKLE_URL -o pickle.tar.gz; fi - tar xzf pickle.tar.gz -C out && rm pickle.tar.gz script: - ./build.sh -n Release -d # Run again since build.sh installation of dependencies sets back defaults - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 90 --slave /usr/bin/g++ g++ /usr/bin/g++-5; fi - test/run_tests.sh $(ls -d -1 out/webrtc*/) Release ================================================ FILE: LICENSE ================================================ Copyright (c) 2015, Vicken Simonian All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: README.md ================================================ # webrtcbuilds [![Build Status](https://travis-ci.org/vsimon/webrtcbuilds.svg?branch=master)](https://travis-ci.org/vsimon/webrtcbuilds) The goal of webrtcbuilds is to provide a single standalone static library and package for WebRTC. ## Current Platforms and Prerequisites * OSX (requires [Homebrew](http://brew.sh/) is installed) * Windows (requires [Visual Studio Community 2013](http://www.chromium.org/developers/how-tos/build-instructions-windows) at least and a [Bash shell such as Git for Windows](https://msysgit.github.io) is installed) * Linux (tested on Ubuntu 16.04 64-bit) ## How to run `./build.sh` to build the latest version of WebRTC. Or with options. ``` Usage: ./build.sh [OPTIONS] OPTIONS: -h Show this message -d Debug mode. Print all executed commands. -o OUTDIR Output directory. Default is 'out' -b BRANCH Latest revision on git branch. Overrides -r. Common branch names are 'branch-heads/nn', where 'n' is the release number. -r REVISION Git SHA revision. Default is latest revision. -t TARGET OS The target os for cross-compilation. Default is the host OS such as 'linux', 'mac', 'win'. Other values can be 'android', 'ios'. -c TARGET CPU The target cpu for cross-compilation. Default is 'x64'. Other values can be 'x86', 'arm64', 'arm'. -n CONFIGS Build configurations, space-separated. Default is 'Debug Release'. Other values can be 'Debug', 'Release'. -e Compile WebRTC with RTTI enabled. Default is with RTTI not enabled. -g [Linux] Compile 'Debug' WebRTC with iterator debugging disabled. Default is enabled but it might add significant overhead. -D [Linux] Generate a debian package -F PATTERN Allow customize package filename through a pattern -P PATTERN Allow customize package name through a pattern -V PATTERN Allow customize package version through a pattern The PATTERN is a string that can use the following tokens: %p% The system platform. %to% Target os. %tc% Target cpu. %b% The branch if it was specified. %r% Revision. %sr% Short revision. %rn% The associated revision number. %da% Debian architecture. ``` ## Where is the package `out/webrtcbuilds----.zip` where `` is the revision number of the commit, `` is the short git SHA of the commit, and `-` is the OS (linux, mac, win) and CPU (x64, x86) of the target environment. ## Documentation Wiki: https://github.com/vsimon/webrtcbuilds/wiki Mailing List: http://groups.google.com/group/webrtcbuilds ================================================ FILE: build.sh ================================================ #!/bin/bash set -o errexit set -o nounset set -o pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $DIR/util.sh usage () { cat << EOF Usage: $0 [OPTIONS] WebRTC build script. OPTIONS: -h Show this message -d Debug mode. Print all executed commands. -o OUTDIR Output directory. Default is 'out' -b BRANCH Latest revision on git branch. Overrides -r. Common branch names are 'branch-heads/nn', where 'nn' is the release number. -r REVISION Git SHA revision. Default is latest revision. -t TARGET OS The target os for cross-compilation. Default is the host OS such as 'linux', 'mac', 'win'. Other values can be 'android', 'ios'. -c TARGET CPU The target cpu for cross-compilation. Default is 'x64'. Other values can be 'x86', 'arm64', 'arm'. -n CONFIGS Build configurations, space-separated. Default is 'Debug Release'. Other values can be 'Debug', 'Release'. -e Compile WebRTC with RTTI enabled. Default is with RTTI not enabled. -g [Linux] Compile 'Debug' WebRTC with iterator debugging disabled. Default is enabled but it might add significant overhead. -D [Linux] Generate a debian package -F PATTERN Allow customize package filename through a pattern -P PATTERN Allow customize package name through a pattern -V PATTERN Allow customize package version through a pattern The PATTERN is a string that can use the following tokens: %p% The system platform. %to% Target os. %tc% Target cpu. %b% The branch if it was specified. %r% Revision. %sr% Short revision. %rn% The associated revision number. %da% Debian architecture. EOF } while getopts :b:o:r:t:c:n:degDF:P:V: OPTION; do case $OPTION in o) OUTDIR=$OPTARG ;; b) BRANCH=$OPTARG ;; r) REVISION=$OPTARG ;; t) TARGET_OS=$OPTARG ;; c) TARGET_CPU=$OPTARG ;; n) CONFIGS=$OPTARG ;; d) DEBUG=1 ;; e) ENABLE_RTTI=1 ;; g) DISABLE_ITERATOR_DEBUG=1 ;; D) PACKAGE_AS_DEBIAN=1 ;; F) PACKAGE_FILENAME_PATTERN=$OPTARG ;; P) PACKAGE_NAME_PATTERN=$OPTARG ;; V) PACKAGE_VERSION_PATTERN=$OPTARG ;; ?) usage; exit 1 ;; esac done OUTDIR=${OUTDIR:-out} BRANCH=${BRANCH:-} DEBUG=${DEBUG:-0} ENABLE_RTTI=${ENABLE_RTTI:-0} DISABLE_ITERATOR_DEBUG=${DISABLE_ITERATOR_DEBUG:-0} PACKAGE_AS_DEBIAN=${PACKAGE_AS_DEBIAN:-0} PACKAGE_FILENAME_PATTERN=${PACKAGE_FILENAME_PATTERN:-"webrtcbuilds-%rn%-%sr%-%to%-%tc%"} PACKAGE_NAME_PATTERN=${PACKAGE_NAME_PATTERN:-"webrtcbuilds"} PACKAGE_VERSION_PATTERN=${PACKAGE_VERSION_PATTERN:-"%rn%"} CONFIGS=${CONFIGS:-Debug Release} REPO_URL="https://webrtc.googlesource.com/src" DEPOT_TOOLS_URL="https://chromium.googlesource.com/chromium/tools/depot_tools.git" DEPOT_TOOLS_DIR=$DIR/depot_tools DEPOT_TOOLS_WIN_TOOLCHAIN=0 PATH=$DEPOT_TOOLS_DIR:$DEPOT_TOOLS_DIR/python276_bin:$PATH [ "$DEBUG" = 1 ] && set -x mkdir -p $OUTDIR OUTDIR=$(cd $OUTDIR && pwd -P) detect-platform TARGET_OS=${TARGET_OS:-$PLATFORM} TARGET_CPU=${TARGET_CPU:-x64} echo "Host OS: $PLATFORM" echo "Target OS: $TARGET_OS" echo "Target CPU: $TARGET_CPU" check::platform $PLATFORM $TARGET_OS echo Checking webrtcbuilds dependencies check::webrtcbuilds::deps $PLATFORM echo Checking depot-tools check::depot-tools $PLATFORM $DEPOT_TOOLS_URL $DEPOT_TOOLS_DIR if [ ! -z $BRANCH ]; then REVISION=$(git ls-remote $REPO_URL --heads $BRANCH | head -n1 | cut -f1) || \ { echo "Cound not get branch revision for $BRANCH" && exit 1; } [ -z $REVISION ] && echo "Cound not get branch revision for $BRANCH" && exit 1 echo "Building branch: $BRANCH" else REVISION=${REVISION:-$(latest-rev $REPO_URL)} || \ { echo "Could not get latest revision" && exit 1; } fi echo "Building revision: $REVISION" REVISION_NUMBER=$(revision-number $REPO_URL $REVISION) || \ { echo "Could not get revision number" && exit 1; } echo "Associated revision number: $REVISION_NUMBER" echo "Checking out WebRTC revision (this will take awhile): $REVISION" checkout "$TARGET_OS" $OUTDIR $REVISION echo Checking WebRTC dependencies check::webrtc::deps $PLATFORM $OUTDIR "$TARGET_OS" echo Patching WebRTC source patch $PLATFORM $OUTDIR $ENABLE_RTTI echo Compiling WebRTC compile $PLATFORM $OUTDIR "$TARGET_OS" "$TARGET_CPU" "$CONFIGS" "$DISABLE_ITERATOR_DEBUG" echo Packaging WebRTC PACKAGE_FILENAME=$(interpret-pattern "$PACKAGE_FILENAME_PATTERN" "$PLATFORM" "$OUTDIR" "$TARGET_OS" "$TARGET_CPU" "$BRANCH" "$REVISION" "$REVISION_NUMBER") PACKAGE_NAME=$(interpret-pattern "$PACKAGE_NAME_PATTERN" "$PLATFORM" "$OUTDIR" "$TARGET_OS" "$TARGET_CPU" "$BRANCH" "$REVISION" "$REVISION_NUMBER") PACKAGE_VERSION=$(interpret-pattern "$PACKAGE_VERSION_PATTERN" "$PLATFORM" "$OUTDIR" "$TARGET_OS" "$TARGET_CPU" "$BRANCH" "$REVISION" "$REVISION_NUMBER") package::prepare $PLATFORM $OUTDIR $PACKAGE_FILENAME $DIR/resource "$CONFIGS" $REVISION_NUMBER if [ "$PACKAGE_AS_DEBIAN" = 1 ]; then package::debian $OUTDIR $PACKAGE_FILENAME $PACKAGE_NAME $PACKAGE_VERSION "$(debian-arch $TARGET_CPU)" else package::zip $PLATFORM $OUTDIR $PACKAGE_FILENAME fi echo Build successful ================================================ FILE: resource/pkgconfig/libwebrtc_full.pc.in ================================================ prefix=${WEBRTC_LOCAL} libdir=${prefix}/lib includedir=${prefix}/include Name: libwebrtc_full Description: The WebRTC library Version: 0.0.1 Requires: libcrypto, nss Cflags: -DWEBRTC_POSIX -I${includedir} -std=gnu++11 Libs: ${libdir}/$CONFIG/libwebrtc_full.a -ldl -lX11 -lexpat ================================================ FILE: test/run_tests.sh ================================================ #!/bin/bash set -o errexit set -o nounset set -o pipefail DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) WEBRTCBUILDS_FOLDER="$1" WEBRTCBUILDS_FOLDER=$(cd $WEBRTCBUILDS_FOLDER && pwd -P) CONFIGS=${2:-Debug Release} # This is for handling breaking changes between WebRTC versions in our test WEBRTC_REVISION_NUMBER=$(echo $WEBRTCBUILDS_FOLDER | cut -d- -f2) tmpdir=$(mktemp -d) trap 'rm -rf "$tmpdir"' EXIT INT TERM HUP pushd $tmpdir >/dev/null for CONFIG in $CONFIGS; do if [[ $(uname) = Linux ]]; then export PKG_CONFIG_PATH=$WEBRTCBUILDS_FOLDER/lib/$CONFIG/pkgconfig c++ -o simple_app $DIR/simple_app.cc \ -DWEBRTC_REVISION_NUMBER=$WEBRTC_REVISION_NUMBER \ $(pkg-config --cflags --libs --define-variable=WEBRTC_LOCAL=$WEBRTCBUILDS_FOLDER libwebrtc_full) \ -lpthread elif [[ $(uname) = Darwin ]]; then clang++ -o simple_app $DIR/simple_app.cc -DWEBRTC_POSIX -DWEBRTC_MAC \ -DWEBRTC_REVISION_NUMBER=$WEBRTC_REVISION_NUMBER \ -I$WEBRTCBUILDS_FOLDER/include -std=c++11 -stdlib=libc++ \ $WEBRTCBUILDS_FOLDER/lib/$CONFIG/libwebrtc_full.a \ -framework Cocoa -framework Foundation -framework IOKit \ -framework Security -framework SystemConfiguration \ -framework ApplicationServices -framework CoreServices \ -framework CoreVideo -framework CoreAudio -framework AudioToolbox \ -framework QTKit -framework AVFoundation -framework CoreMedia else echo No test currently exists for this platform exit 1 fi ./simple_app done popd >/dev/null ================================================ FILE: test/simple_app.cc ================================================ // Revision 19846 is the following, where upstream moved src/webrtc to src/ // https://webrtc.googlesource.com/src/+/92ea95e34af5966555903026f45164afbd7e2088 #if WEBRTC_REVISION_NUMBER >= 19846 #include "rtc_base/thread.h" #include "p2p/base/basicpacketsocketfactory.h" #include "api/peerconnectioninterface.h" #include "api/test/fakeconstraints.h" #include "media/engine/webrtcvideocapturerfactory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "modules/audio_device/include/audio_device.h" #else #include "webrtc/rtc_base/thread.h" #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/api/peerconnectioninterface.h" #include "webrtc/api/test/fakeconstraints.h" #include "webrtc/media/engine/webrtcvideocapturerfactory.h" #endif int main(int argc, char* argv[]) { // something from base rtc::Thread* thread = rtc::Thread::Current(); // something from p2p std::unique_ptr socket_factory( new rtc::BasicPacketSocketFactory()); // something from api rtc::scoped_refptr peer_connection_factory = webrtc::CreatePeerConnectionFactory( NULL, rtc::Thread::Current(), NULL, webrtc::AudioDeviceModule::Create(0, webrtc::AudioDeviceModule::kDummyAudio), webrtc::CreateBuiltinAudioEncoderFactory(), webrtc::CreateBuiltinAudioDecoderFactory(), NULL, NULL); // something from api/test webrtc::FakeConstraints constraints; // something from media/engine cricket::WebRtcVideoDeviceCapturerFactory factory; std::unique_ptr capturer = factory.Create(cricket::Device("", 0)); return 0; } ================================================ FILE: util.sh ================================================ # Detect host platform. # Set PLATFORM environment variable to override default behavior. # Supported platform types - 'linux', 'win', 'mac' # 'msys' is the git bash shell, built using mingw-w64, running under Microsoft # Windows. function detect-platform() { # set PLATFORM to android on linux host to build android case "$OSTYPE" in darwin*) PLATFORM=${PLATFORM:-mac} ;; linux*) PLATFORM=${PLATFORM:-linux} ;; win32*|msys*) PLATFORM=${PLATFORM:-win} ;; *) echo "Building on unsupported OS: $OSTYPE"; exit 1; ;; esac } # Sanity check for the host os/platform supporting cross-compilation with the # target os. # $1: The platform type. # $2: The target os. function check::platform() { local platform="$1" local target_os="$2" if [[ $target_os = 'android' && $platform != 'linux' ]]; then # Codifying the webrtc documentation for android compilation support for non-linux platforms echo "Android compilation is only supported on Linux (https://webrtc.org/native-code/android/#getting-the-code)" exit 1 fi } # This cleans the output directory. # $1: The output directory. function clean() { local outdir="$1" rm -rf $outdir/* $outdir/.gclient* } # Makes sure depot tools are present. # $1: The platform type. # $2: The depot tools url. # $3: The depot tools directory. function check::depot-tools() { local platform="$1" local depot_tools_url="$2" local depot_tools_dir="$3" if [ ! -d $depot_tools_dir ]; then git clone -q $depot_tools_url $depot_tools_dir if [ $platform = 'win' ]; then # run gclient.bat to get python pushd $depot_tools_dir >/dev/null ./gclient.bat popd >/dev/null fi else pushd $depot_tools_dir >/dev/null git reset --hard -q popd >/dev/null fi } # Makes sure package is installed. Depends on sudo to be installed first. # $1: The name of the package # $2: Existence check binary. Defaults to name of the package. function ensure-package() { local name="$1" local binary="${2:-$1}" if ! which $binary > /dev/null ; then sudo apt-get update -qq sudo apt-get install -y $name fi } # Makes sure all webrtcbuilds dependencies are present. # $1: The platform type. function check::webrtcbuilds::deps() { local platform="$1" case $platform in mac) which brew > /dev/null || (echo "Building with 'mac' requires Homebrew. Visit https://brew.sh"; exit 1) # for GNU version of cp: gcp which gcp > /dev/null || brew install coreutils ;; linux) if ! grep -v \# /etc/apt/sources.list | grep -q multiverse ; then echo "*** Warning: The Multiverse repository is probably not enabled ***" echo "*** which is required for things like msttcorefonts. ***" fi if ! which sudo > /dev/null ; then apt-get update -qq apt-get install -y sudo fi ensure-package curl ensure-package git ensure-package python ensure-package lbzip2 ensure-package lsb-release lsb_release ;; win) VISUAL_STUDIO_TOOLS=${VS140COMNTOOLS:-} if [ -z VISUAL_STUDIO_TOOLS ]; then echo "Building with 'win' requires Microsoft Visual Studio 2015" exit 1 fi ;; esac } # Makes sure all WebRTC build dependencies are present. # $1: The platform type. function check::webrtc::deps() { local platform="$1" local outdir="$2" local target_os="$3" case $platform in linux) # Automatically accepts ttf-mscorefonts EULA echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections sudo $outdir/src/build/install-build-deps.sh --no-syms --no-arm --no-chromeos-fonts --no-nacl --no-prompt ;; esac if [ $target_os = 'android' ]; then sudo $outdir/src/build/install-build-deps-android.sh fi } # Checks out a specific revision # $1: The target OS type. # $2: The output directory. # $3: Revision represented as a git SHA. function checkout() { local target_os="$1" local outdir="$2" local revision="$3" pushd $outdir >/dev/null local prev_target_os=$(cat $outdir/.webrtcbuilds_target_os 2>/dev/null) if [[ -n "$prev_target_os" && "$target_os" != "$prev_target_os" ]]; then echo The target OS has changed. Refetching sources for the new target OS rm -rf src .gclient* fi # Fetch only the first-time, otherwise sync. if [ ! -d src ]; then case $target_os in android) yes | fetch --nohooks webrtc_android ;; ios) fetch --nohooks webrtc_ios ;; *) fetch --nohooks webrtc ;; esac fi # Checkout the specific revision after fetch or for older branches, run # setup_links.py to replace all directories which now must be symlinks then # try again. gclient sync --force --revision $revision || (test -f src/setup_links.py && src/setup_links.py --force --no-prompt && gclient sync --force --revision $revision) # Cache the target OS echo $target_os > $outdir/.webrtcbuilds_target_os popd >/dev/null } # Patches a checkout for building static standalone libs # $1: The platform type. # $2: The output directory. # $3: Enable RTTI or not. '0' or '1'. function patch() { local platform="$1" local outdir="$2" local rtti_enabled="$3" pushd $outdir/src >/dev/null # This removes the examples from being built. sed -i.bak 's|"//webrtc/examples",|#"//webrtc/examples",|' BUILD.gn # This configures whether to build with RTTI enabled or not. [ "$rtti_enabled" = 1 ] && sed -i.bak \ 's|"//build/config/compiler:no_rtti",|"//build/config/compiler:rtti",|' \ build/config/BUILDCONFIG.gn popd >/dev/null } # This function compiles a single library using Microsoft Visual C++ for a # Microsoft Windows (32/64-bit) target. This function is separate from the # other compile functions because of differences using the Microsoft tools: # # The Microsoft Windows tools use different file extensions than the other tools: # '.obj' as the object file extension, instead of '.o' # '.lib' as the static library file extension, instead of '.a' # '.dll' as the shared library file extension, instead of '.so' # # The Microsoft Windows tools have different names than the other tools: # 'lib' as the librarian, instead of 'ar'. 'lib' must be found through the path # variable $VS140COMNTOOLS. # # The Microsoft tools that target Microsoft Windows run only under # Microsoft Windows, so the build and target systems are the same. # # $1 the output directory, 'Debug', 'Debug_x64', 'Release', or 'Release_x64' # $2 additional gn arguments function compile-win() { local outputdir="$1" local gn_args="$2" gn gen $outputdir --args="$gn_args" pushd $outputdir >/dev/null ninja -C . rm -f libwebrtc_full.lib local objlist=$(strings .ninja_deps | grep -o '.*\.obj') local blacklist="unittest_main.obj|video_capture_external.obj|\ device_info_external.obj" echo "$objlist" | tr ' ' '\n' | grep -v -E $blacklist >libwebrtc_full.list # On Windows, asm files are compiled to object files that have .obj and .o # extensions. local extras=$(find \ ./obj/third_party/libvpx/libvpx_* \ ./obj/third_party/libjpeg_turbo/simd_asm \ ./obj/third_party/boringssl/boringssl_asm -name '*.o' -o -name '*.obj') echo "$extras" | tr ' ' '\n' >>libwebrtc_full.list "$VS140COMNTOOLS../../VC/bin/lib" /OUT:webrtc_full.lib @libwebrtc_full.list popd >/dev/null } # This function compile and combine build artifact objects into one library. # $1 the output directory, 'Debug', 'Release' # $2 additional gn arguments function compile-unix() { local outputdir="$1" local gn_args="$2" local blacklist="unittest|examples|/yasm|protobuf_lite|main.o|\ video_capture_external.o|device_info_external.o" gn gen $outputdir --args="$gn_args" pushd $outputdir >/dev/null ninja -C . rm -f libwebrtc_full.a # Produce an ordered objects list by parsing .ninja_deps for strings # matching .o files. local objlist=$(strings .ninja_deps | grep -o '.*\.o') echo "$objlist" | tr ' ' '\n' | grep -v -E $blacklist >libwebrtc_full.list # various intrinsics aren't included by default in .ninja_deps local extras=$(find \ ./obj/third_party/libvpx/libvpx_* \ ./obj/third_party/libjpeg_turbo/simd_asm \ ./obj/third_party/boringssl/boringssl_asm -name '*.o') echo "$extras" | tr ' ' '\n' >>libwebrtc_full.list # generate the archive cat libwebrtc_full.list | xargs ar -crs libwebrtc_full.a # generate an index list ranlib libwebrtc_full.a popd >/dev/null } # This compiles the library. # $1: The platform type. # $2: The output directory. # $3: The target os for cross-compilation. # $4: The target cpu for cross-compilation. # $5: The build configurations. # $6: Enable iterator debug or not. '0' or '1'. function compile() { local platform="$1" local outdir="$2" local target_os="$3" local target_cpu="$4" local configs="$5" local disable_iterator_debug="$6" local common_args="is_component_build=false rtc_include_tests=false treat_warnings_as_errors=false" local target_args="target_os=\"$target_os\" target_cpu=\"$target_cpu\"" [ "$disable_iterator_debug" = 1 ] && common_args+=' enable_iterator_debugging=false' pushd $outdir/src >/dev/null for cfg in $configs; do [ "$cfg" = 'Release' ] && common_args+=' is_debug=false' case $platform in win) # 32-bit build compile-win "out/$cfg" "$common_args $target_args" # 64-bit build GYP_DEFINES="target_arch=x64 $GYP_DEFINES" compile-win "out/${cfg}_x64" "$common_args $target_args" ;; *) # On Linux when not cross-compiling, use clang = false and sysroot = false # to build using gcc. Comment this out to use clang. if [[ $platform = 'linux' && $target_os != 'android' && $target_cpu != amd* ]]; then target_args+=" is_clang=false use_sysroot=false" fi # Debug builds are component builds (shared libraries) by default unless # is_component_build=false is passed to gn gen --args. Release builds are # static by default. compile-unix "out/$cfg" "$common_args $target_args" ;; esac done popd >/dev/null } # This prepares artifacts to be packaged. # $1: The platform type. # $2: The output directory. # $3: The package filename. # $4: The project's resource dirctory. # $5: The build configurations. # $6: : The revision number. function package::prepare() { local platform="$1" local outdir="$2" local package_filename="$3" local resourcedir="$4" local configs="$5" local revision_number="$6" if [ $platform = 'mac' ]; then CP='gcp' else CP='cp' fi pushd $outdir >/dev/null # create directory structure mkdir -p $package_filename/include $package_filename/lib for cfg in $configs; do mkdir -p $package_filename/lib/$cfg done # find and copy header files # copy all non third-party header files first then copy only the third-party # header files that are required such as abseil-cpp for optional.h pushd src >/dev/null local headersSourceDir=webrtc local headersDestDir=$outdir/$package_filename/include # Revision 19846 is the following, where upstream moved src/webrtc to src/ # https://webrtc.googlesource.com/src/+/92ea95e34af5966555903026f45164afbd7e2088 if [[ $revision_number -ge 19846 ]]; then headersSourceDir=. fi find $headersSourceDir -path './third_party*' -prune -o -name '*.h' -exec $CP --parents '{}' $headersDestDir ';' # Revision 23941 introduced absl::optional from abseil-cpp if [[ $revision_number -ge 23941 ]]; then pushd $headersSourceDir/third_party/abseil-cpp >/dev/null find . -name '*.h' -exec $CP --parents '{}' $headersDestDir ';' popd >/dev/null fi popd >/dev/null # find and copy libraries pushd src/out >/dev/null find . -maxdepth 3 \( -name '*.so' -o -name '*.dll' -o -name '*webrtc_full*' -o -name *.jar \) \ -exec $CP --parents '{}' $outdir/$package_filename/lib ';' popd >/dev/null # for linux, add pkgconfig files if [ $platform = 'linux' ]; then for cfg in $configs; do mkdir -p $package_filename/lib/$cfg/pkgconfig CONFIG=$cfg envsubst '$CONFIG' < $resourcedir/pkgconfig/libwebrtc_full.pc.in > \ $package_filename/lib/$cfg/pkgconfig/libwebrtc_full.pc done fi popd >/dev/null } # This packages a compiled build into a zip file in the output directory. # $1: The platform type. # $2: The output directory. # $3: The package filename. function package::zip() { local platform="$1" local outdir="$2" local package_filename="$3" pushd $outdir >/dev/null # remove first for cleaner builds rm -f $package_filename.zip # zip up the package if [ $platform = 'win' ]; then $DEPOT_TOOLS/win_toolchain/7z/7z.exe a -tzip $package_filename.zip $package_filename else zip -r $package_filename.zip $package_filename >/dev/null fi popd >/dev/null } # This packages into a debian package in the output directory. # $1: The output directory. # $2: The package filename. # $3: The package name. # $4: The package version. # $5: The architecture. function package::debian() { local outdir="$1" local package_filename="$2" local package_name="$3" local package_version="$4" local arch="$5" local debianize="debianize/$package_filename" echo "Debianize WebRTC" pushd $outdir >/dev/null mkdir -p $debianize/DEBIAN mkdir -p $debianize/opt mv $package_filename $debianize/opt/webrtc cat << EOF > $debianize/DEBIAN/control Package: $package_name Architecture: $arch Maintainer: webrtcbuilds manintainers Depends: debconf (>= 0.5.00) Priority: optional Version: $package_version Description: webrtc static library This package provides webrtc library generated with webrtcbuilds EOF fakeroot dpkg-deb --build $debianize mv debianize/*.deb . rm -rf debianize popd >/dev/null } # This returns the latest revision from the git repo. # $1: The git repo URL function latest-rev() { local repo_url="$1" git ls-remote $repo_url HEAD | cut -f1 } # This returns the associated revision number for a given git sha revision # $1: The git repo URL # $2: The revision git sha string function revision-number() { local repo_url="$1" local revision="$2" # This says curl the revision log with text format, base64 decode it using # openssl since its more portable than just 'base64', take the last line which # contains the commit revision number and output only the matching {#nnn} part openssl base64 -d -A <<< $(curl --silent $repo_url/+/$revision?format=TEXT) \ | tail -1 | egrep -o '{#([0-9]+)}' | tr -d '{}#' } # This returns a short revision sha. # $1: The revision string function short-rev() { local revision="$1" echo $revision | cut -c -7 } # This returns a short revision sha. # $1: The target cpu for cross-compilation. function debian-arch() { local target_cpu="$1" # set PLATFORM to android on linux host to build android case "$target_cpu" in x86*) echo "i386" ;; x64*) echo "amd64" ;; *) echo "$target_cpu" ;; esac } # This interprets a pattern and returns the interpreted one. # $1: The pattern. # $2: The output directory. # $3: The platform type. # $4: The target os for cross-compilation. # $5: The target cpu for cross-compilation. # $6: The branch. # $7: The revision. # $8: The revision number. function interpret-pattern() { local pattern="$1" local platform="$2" local outdir="$3" local target_os="$4" local target_cpu="$5" local branch="$6" local revision="$7" local revision_number="$8" local debian_arch="$(debian-arch $target_cpu)" local short_revision="$(short-rev $revision)" pattern=${pattern//%p%/$platform} pattern=${pattern//%to%/$target_os} pattern=${pattern//%tc%/$target_cpu} pattern=${pattern//%b%/$branch} pattern=${pattern//%r%/$revision} pattern=${pattern//%rn%/$revision_number} pattern=${pattern//%da%/$debian_arch} pattern=${pattern//%sr%/$short_revision} echo "$pattern" }