Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build.sh for repeatable builds of libwebrtc-magic.a #51

Merged
merged 2 commits into from
Jan 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 59 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,55 @@ THIRD_PARTY_DIR="$PROJECT_DIR/third_party"
WEBRTC_REPO="https://chromium.googlesource.com/external/webrtc"
WEBRTC_DIR="$THIRD_PARTY_DIR/webrtc"
WEBRTC_SRC="$WEBRTC_DIR/src"
DEPOT_TOOLS_DIR="$THIRD_PARTY_DIR/depot_tools"
OS=$(go env GOOS)
ARCH=$(go env GOARCH)
CONFIG="Debug"
CONFIG="Release"
COMMIT="f33698296719f956497d2dbff81b5080864a8804" # branch-heads/52

INCLUDE_DIR="$PROJECT_DIR/include"
LIB_DIR="$PROJECT_DIR/lib"

# TODO(arlolra): depot_tools

GYP_DEFINES="include_tests=0"
PATH="$PATH:$DEPOT_TOOLS_DIR"

mkdir -p $THIRD_PARTY_DIR
mkdir -p $INCLUDE_DIR
mkdir -p $LIB_DIR

if [[ -d $DEPOT_TOOLS_DIR ]]; then
echo "Syncing depot_tools ..."
pushd $DEPOT_TOOLS_DIR
git pull --rebase || exit 1
popd
else
echo "Getting depot_tools ..."
mkdir -p $DEPOT_TOOLS_DIR
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS_DIR || exit 1
fi

if [[ -d $WEBRTC_DIR ]]; then
echo "Sync'ing webrtc ..."
echo "Syncing webrtc ..."
pushd $WEBRTC_SRC || exit 1
if ! git diff-index --quiet HEAD --; then
echo -en "\nOpen files present in $WEBRTC_SRC\nReset them? (y/N): "
read ANSWER
if [ "$ANSWER" != "y" ]; then
echo "*** Cancelled ***"
exit 1
fi
git reset --hard HEAD || exit 1
fi
popd

pushd $WEBRTC_DIR
gclient sync
gclient sync --with_branch_heads -r $COMMIT || exit 1
popd
else
echo "Getting webrtc ..."
mkdir -p $WEBRTC_DIR
pushd $WEBRTC_DIR
gclient config --name src $WEBRTC_REPO
gclient sync
gclient config --name src $WEBRTC_REPO || exit 1
gclient sync --with_branch_heads -r $COMMIT || exit 1
popd
fi

Expand All @@ -40,34 +62,51 @@ pushd $WEBRTC_SRC
git checkout $COMMIT
popd

echo "Generating build scripts ..."
pushd $WEBRTC_SRC
python webrtc/build/gyp_webrtc
echo "Cleaning webrtc ..."
pushd $WEBRTC_SRC || exit 1
rm -rf out/$CONFIG
popd

echo "Applying webrtc patches ..."
pushd $WEBRTC_SRC || exit 1
for PATCH in build_at_webrtc_branch_heads_52.patch; do
git apply --check ${PROJECT_DIR}/webrtc_patches/${PATCH} || exit 1
git am < ${PROJECT_DIR}/webrtc_patches/${PATCH} || exit 1
done
popd

echo "Building webrtc ..."
pushd $WEBRTC_SRC
ninja -C out/$CONFIG
export GYP_DEFINES="include_tests=0 include_examples=0"
python webrtc/build/gyp_webrtc webrtc/api/api.gyp || exit 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I forgot this change results in the Undefined symbols for ... webrtc::field_trial::FindFullName. Sorry :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem!

ninja -C out/$CONFIG || exit 1
popd

echo "Copying headers ..."
pushd $WEBRTC_SRC
pushd $WEBRTC_SRC || exit 1
rm -rf "$INCLUDE_DIR"
for h in $(find webrtc/ -type f -name '*.h')
do
mkdir -p "$INCLUDE_DIR/$(dirname $h)"
cp $h "$INCLUDE_DIR/$h"
done
popd
pushd $PROJECT_DIR || exit 1
git clean -fdx "$INCLUDE_DIR"
popd

echo "Concatenating libraries ..."
pushd $WEBRTC_SRC/out/$CONFIG
# on osx:
# ls *.a > filelist
# libtool -static -o libwebrtc-magic.a -filelist filelist
# strip -S -x -o libwebrtc-magic.a libwebrtc-magic.a
# on linux:
# ar crs libwebrtc-magic.a $(find . -name '*.o' -not -name '*.main.o')
mv libwebrtc-magic.a $LIB_DIR/libwebrtc-$OS-$ARCH-magic.a
if [ "$OS" = "darwin" ]; then
ls *.a > filelist
libtool -static -o libwebrtc-magic.a -filelist filelist
strip -S -x -o libwebrtc-magic.a libwebrtc-magic.a
else
ar crs libwebrtc-magic.a $(find . -name '*.o' -not -name '*.main.o')
fi
OUT_LIBRARY=$LIB_DIR/libwebrtc-$OS-$ARCH-magic.a
mv libwebrtc-magic.a ${OUT_LIBRARY}
echo "Built ${OUT_LIBRARY}"
popd

echo "Build complete."
35 changes: 35 additions & 0 deletions webrtc_patches/build_at_webrtc_branch_heads_52.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From dd503bd0c5696882d6ece760da1ef4865825e55c Mon Sep 17 00:00:00 2001
From: Cant Stop The Signal <cantstopthesignals@gmail.com>
Date: Sun, 4 Dec 2016 16:01:43 -0800
Subject: [PATCH] Add patches to get webrtc to build from webrtc
branch-heads/52

webrtc commit f33698296719f956497d2dbff81b5080864a8804
---
webrtc/api/api.gyp | 3 +++
1 file changed, 3 insertions(+)

diff --git a/webrtc/api/api.gyp b/webrtc/api/api.gyp
index 377ef8f70..794fdb99c 100644
--- a/webrtc/api/api.gyp
+++ b/webrtc/api/api.gyp
@@ -129,6 +129,7 @@
'dependencies': [
'<(webrtc_root)/media/media.gyp:rtc_media',
'<(webrtc_root)/pc/pc.gyp:rtc_pc',
+ '<(webrtc_root)/system_wrappers/system_wrappers.gyp:field_trial_default',
],
'sources': [
'audiotrack.cc',
@@ -199,6 +200,8 @@
'webrtcsession.h',
'webrtcsessiondescriptionfactory.cc',
'webrtcsessiondescriptionfactory.h',
+ 'test/fakeaudiocapturemodule.cc',
+ 'test/fakeaudiocapturemodule.h',
],
# TODO(kjellander): Make the code compile without disabling these flags.
# See https://bugs.chromium.org/p/webrtc/issues/detail?id=3307
--
2.11.0