Skip to content

Commit

Permalink
Build webrtc for mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Fifield authored and gk-tpo committed Jul 14, 2017
1 parent d3a6c35 commit fcdc2be
Show file tree
Hide file tree
Showing 3 changed files with 475 additions and 10 deletions.
139 changes: 139 additions & 0 deletions gitian/descriptors/mac/gitian-webrtc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
name: "webrtc-mac"
distro: "debian"
suites:
- "jessie"
architectures:
- "amd64"
packages:
- "unzip"
- "zip"
- "libglib2.0-dev"
- "libgtk2.0-dev"
- "pkg-config"
- "python-biplist"
reference_datetime: "2000-01-01 00:00:00"
remotes:
- "url": "https://chromium.googlesource.com/chromium/tools/depot_tools.git"
"dir": "depot_tools"
files:
- "versions"
- "clang-linux64-jessie-utils.zip"
- "cctools.tar.gz"
- "MacOSX10.7.sdk.tar.gz"
- "dzip.sh"
- "webrtc.tar.gz"
- "webrtc-mac.patch"
script: |
INSTDIR="$HOME/install"
source versions
export REFERENCE_DATETIME
export TZ=UTC
export LC_ALL=C
umask 0022
#
mkdir -p $OUTDIR/
# Setting up depot_tools
# https://dev.chromium.org/developers/how-tos/install-depot-tools
export PATH="$PATH:$PWD/depot_tools"
# Disable automatic updating.
export DEPOT_TOOLS_UPDATE=0
# Extracting all the necessary tools
tar xaf cctools.tar.gz
unzip clang-linux64-jessie-utils.zip
tar xaf MacOSX10.7.sdk.tar.gz
export SDKROOT="$PWD/MacOSX10.7.sdk"
# src/build/toolchain/mac/filter_libtool.py wants libtool to be called exactly "libtool".
ln -sf x86_64-apple-darwin10-libtool $HOME/build/cctools/bin/libtool
# ld needs libLTO.so from llvm
export LD_LIBRARY_PATH="$HOME/build/clang/lib"
export PATH="$HOME/build/cctools/bin:$PATH"
export AR=x86_64-apple-darwin10-ar
# Certain cross-compiling flags are set in webrtc-mac.patch because the build
# system doesn't honor CFLAGS etc. environment variables.
# Building webrtc
tar xaf webrtc.tar.gz
cd webrtc/src
patch -p1 < ../../webrtc-mac.patch
# The linux descriptor builds its own copy of gn, using tools/gn/bootstrap/bootstrap.py.
# I tried that here, but for some reason the gn so built doesn't work. On "gn gen",
# it crashes with this error:
# [0624/022439.767916:FATAL:command_gen.cc(59)] Check failed: !rule.empty().
# Instead, use the gn packaged with depot_tools.
GN="$HOME/build/depot_tools/gn"
# Hardcode the output of some utility programs that otherwise require Xcode
# tools, like xcode-select, xcodebuild, sw_vers, and xcrun. This probably
# needs to be kept in sync with the SDK version.
cat <<EOF > build/mac/find_sdk.py
print("$SDKROOT")
print("10.7")
EOF
cat <<EOF > build/config/mac/sdk_info.py
print("machine_os_build=\"10.7\"")
print("sdk_build=\"10.7\"")
print("sdk_path=\"$SDKROOT\"")
print("sdk_platform_path=\"$SDKROOT\"")
print("sdk_version=\"10.7\"")
print("xcode_build=\"7.3\"")
print("xcode_version=\"0730\"")
EOF
export GN_ARGS=""
# For a list of all possible GN args, do "gn gen out/Release; gn args --list out/Release".
# https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/cross_compiles.md
GN_ARGS+=" target_os=\"mac\" target_cpu=\"x64\" mac_deployment_target=\"10.7\""
# Not debug.
GN_ARGS+=" is_debug=false"
# There are warnings from unused returns.
GN_ARGS+=" treat_warnings_as_errors=false"
# Build static libraries.
GN_ARGS+=" is_component_build=false"
# Do not use bundled utilities.
GN_ARGS+=" is_clang=false use_sysroot=false"
GN_ARGS+=" clang_use_chrome_plugins=false"
GN_ARGS+=" clang_base_path=\"$HOME/build/clang\""
GN_ARGS+=" gold_path=\"$INSTDIR/binutils/bin\""
# Avoid some dependencies.
GN_ARGS+=" rtc_include_opus=false rtc_include_ilbc=false rtc_include_internal_audio_device=false"
# Tests are needed for field_trial, metrics_default, and pc_test_utils targets
# (which include code needed by go-webrtc).
GN_ARGS+=" rtc_include_tests=true"
# Make sure not to use bundled clang and binutils.
rm -rf third_party/llvm-build
rm -rf third_party/binutils
rm -rf out/Release
"$GN" gen out/Release --args="$GN_ARGS"
ninja -C out/Release webrtc field_trial metrics_default pc_test_utils
# The cctools ar doesn't have the 'D' deterministic option of GNU ar, but the
# ZERO_AR_DATE environment variable similarly sets timestamps within the
# archive to zero.
# https://opensource.apple.com/source/cctools/cctools-886/ar/archive.c.auto.html
# https://codereview.chromium.org/699083004/
# .o files under out/Release/obj/ are the build outputs. Don't include .o
# files from elsewhere under out/ because they are build helpers and things
# like that, not necessarily of the target architecture, and anyway are not
# needed.
# https://bugs.torproject.org/22832
ZERO_AR_DATE=1 "$AR" crs libwebrtc-magic.a $(find out/Release/obj -name '*.o' | sort)
# ZERO_AR_DATE additionally sets the mtime of the .a file itself to zero
# (1970-01-01), so change it to match everything else.
touch --date="$REFERENCE_DATETIME" libwebrtc-magic.a
cd ../..
# Grabbing the result
cd $INSTDIR
mkdir -p webrtc/include webrtc/lib
cp -f $HOME/build/webrtc/src/libwebrtc-magic.a webrtc/lib/libwebrtc-darwin-amd64-magic.a
INCLUDE_DIR="$PWD/webrtc/include"
(cd $HOME/build/webrtc/src && for h in $(find talk/ webrtc/ -type f -name '*.h'); do
mkdir -p "$INCLUDE_DIR/$(dirname $h)"
cp -f "$h" "$INCLUDE_DIR/$h"
done)
~/build/dzip.sh webrtc-mac64-gbuilt.zip webrtc
cp webrtc-mac64-gbuilt.zip $OUTDIR/
41 changes: 31 additions & 10 deletions gitian/mkbundle-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ if [ ! -f inputs/clang-$CLANG_VER-linux64-jessie-utils.zip -o \
! -f inputs/libevent-${LIBEVENT_TAG_ORIG#release-}-mac64-utils.zip ];
then
echo
echo "****** Starting Utilities Component of Mac Bundle (1/5 for Mac) ******"
echo "****** Starting Utilities Component of Mac Bundle (1/6 for Mac) ******"
echo
./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit libevent=$LIBEVENT_TAG,faketime=$FAKETIME_TAG,cmake=$CMAKE_TAG,llvm=$LLVM_TAG,clang=$CLANG_TAG $DESCRIPTOR_DIR/mac/gitian-utils.yml
if [ $? -ne 0 ];
Expand All @@ -158,7 +158,7 @@ then
#cp -a result/utils-mac-res.yml inputs/
else
echo
echo "****** SKIPPING already built Utilities Component of Mac Bundle (1/5 for
echo "****** SKIPPING already built Utilities Component of Mac Bundle (1/6 for
Mac) ******"
echo
# We might have built the utilities in the past but maybe the links are
Expand All @@ -173,7 +173,7 @@ fi
if [ ! -f inputs/tor-mac64-gbuilt.zip ];
then
echo
echo "****** Starting Tor Component of Mac Bundle (2/5 for Mac) ******"
echo "****** Starting Tor Component of Mac Bundle (2/6 for Mac) ******"
echo

./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit tor=$TOR_TAG $DESCRIPTOR_DIR/mac/gitian-tor.yml
Expand All @@ -187,14 +187,14 @@ then
#cp -a result/tor-mac-res.yml inputs/
else
echo
echo "****** SKIPPING already built Tor Component of Mac Bundle (2/5 for Mac) ******"
echo "****** SKIPPING already built Tor Component of Mac Bundle (2/6 for Mac) ******"
echo
fi

if [ ! -f inputs/tor-browser-mac64-gbuilt.zip ];
then
echo
echo "****** Starting TorBrowser Component of Mac Bundle (3/5 for Mac) ******"
echo "****** Starting TorBrowser Component of Mac Bundle (3/6 for Mac) ******"
echo

./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit tor-browser=$TORBROWSER_TAG,faketime=$FAKETIME_TAG $DESCRIPTOR_DIR/mac/gitian-firefox.yml
Expand All @@ -209,14 +209,35 @@ then
#cp -a result/torbrowser-mac-res.yml inputs/
else
echo
echo "****** SKIPPING already built TorBrowser Component of Mac Bundle (3/5 for Mac) ******"
echo "****** SKIPPING already built TorBrowser Component of Mac Bundle (3/6 for Mac) ******"
echo
fi

if [ ! -f inputs/webrtc-mac64-gbuilt.zip ];
then
echo
echo "****** Starting WebRTC Component of Mac Bundle (4/6 for Mac) ******"
echo

./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit depot_tools=$DEPOT_TOOLS_TAG $DESCRIPTOR_DIR/mac/gitian-webrtc.yml
if [ $? -ne 0 ];
then
#mv var/build.log ./webrtc-fail-mac.log.`date +%Y%m%d%H%M%S`
exit 1
fi

cp -a build/out/webrtc-mac*-gbuilt.zip inputs/
#cp -a result/webrtc-mac-res.yml inputs/
else
echo
echo "****** SKIPPING already built WebRTC Component of Mac Bundle (4/6 for Mac) ******"
echo
fi

if [ ! -f inputs/pluggable-transports-mac64-gbuilt.zip ];
then
echo
echo "****** Starting Pluggable Transports Component of Mac Bundle (4/5 for Mac) ******"
echo "****** Starting Pluggable Transports Component of Mac Bundle (5/6 for Mac) ******"
echo

./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit goptlib=$GOPTLIB_TAG,meek=$MEEK_TAG,ed25519=$GOED25519_TAG,siphash=$GOSIPHASH_TAG,goxcrypto=$GO_X_CRYPTO_TAG,goxnet=$GO_X_NET_TAG,obfs4=$OBFS4_TAG $DESCRIPTOR_DIR/mac/gitian-pluggable-transports.yml
Expand All @@ -230,15 +251,15 @@ then
#cp -a result/pluggable-transports-mac-res.yml inputs/
else
echo
echo "****** SKIPPING already built Pluggable Transports Component of Mac Bundle (4/5 for Mac) ******"
echo "****** SKIPPING already built Pluggable Transports Component of Mac Bundle (5/6 for Mac) ******"
echo
fi


if [ ! -f inputs/bundle-mac.gbuilt ];
then
echo
echo "****** Starting Bundling+Localization Component of Mac Bundle (5/5 for Mac) ******"
echo "****** Starting Bundling+Localization Component of Mac Bundle (6/6 for Mac) ******"
echo

cd $WRAPPER_DIR && ./record-inputs.sh $VERSIONS_FILE && cd $GITIAN_DIR
Expand All @@ -255,7 +276,7 @@ then
touch inputs/bundle-mac.gbuilt
else
echo
echo "****** SKIPPING already built Bundling+Localization Component of Mac Bundle (5/5 for Mac) ******"
echo "****** SKIPPING already built Bundling+Localization Component of Mac Bundle (6/6 for Mac) ******"
echo
fi

Expand Down
Loading

0 comments on commit fcdc2be

Please sign in to comment.