Skip to content

Instantly share code, notes, and snippets.

@noiges
Created December 4, 2013 02:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noiges/7781364 to your computer and use it in GitHub Desktop.
Save noiges/7781364 to your computer and use it in GitHub Desktop.
A shell script to build WebRTC for iOS/Mac.
#! bin/bash
# webrtc - A script to sync and build the webrtc codebase
#
# Dependencies
# Make sure to install the chromium depot_tools first. Detailed instructions available at
# http://dev.chromium.org/developers/how-tos/install-depot-tools
##### Constants
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
##### Functions
function gyp_config() {
cd "$DIR/trunk"
export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1"
export GYP_GENERATORS="ninja"
if [[ $1 == "ios" ]]; then
export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=armv7"
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_ios"
export GYP_CROSSCOMPILE=1
elif [[ $1 == "mac" ]]; then
export GYP_DEFINES="$GYP_DEFINES OS=mac target_arch=x64"
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_mac"
elif [[ $1 == "sim" ]]; then
export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=ia32"
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_sim"
export GYP_CROSSCOMPILE=1
fi
}
function usage() {
echo "Usage: webrtc OPTIONS\n\nOptions:\n\tsync\n\tbuild [ios|mac|sim]"
}
function sync() {
echo "Syncing with WebRTC repository on Google Code…"
# Checkout the webrtc repository
gclient config http://webrtc.googlecode.com/svn/trunk
gclient sync --force
# Sync files for iOS and Mac
# Note that until http://crbug.com/248168 is fixed one needs to do a gclient
# sync with just 'mac' and then follow that with a sync with both.
echo "target_os = ['mac']" >> .gclient
gclient sync
sed -i - "s/target_os.*/target_os = ['ios', 'mac']/" .gclient
gclient sync
# Generate ninja files
gclient runhooks
echo "Done!"
}
function build() {
if [[ $1 == "ios" ]]; then
build_ios
elif [[ $1 == "mac" ]]; then
build_mac
elif [[ $1 == "sim" ]]; then
build_sim
else
usage
fi
}
function build_ios() {
echo "Building for iOS…"
gyp_config ios
gclient runhooks
ninja -C out_ios/Debug-iphoneos AppRTCDemo
echo "Done!"
}
function build_mac() {
echo "Building for Mac…"
gyp_config mac
gclient runhooks
ninja -C out_mac/Debug libjingle_peerconnection_objc_test
./out_mac/Debug/libjingle_peerconnection_objc_test.app/Contents/MacOS/libjingle_peerconnection_objc_test
echo "Done!"
}
function build_sim() {
echo "Building for Simulator…"
gyp_config sim
gclient runhooks
ninja -C out_sim/Debug iossim AppRTCDemo
./out_sim/Debug/iossim out_sim/Debug/AppRTCDemo.app
echo "Done!"
}
##### Main
if [ $1 == "build" ]; then
build $2
elif [[ $1 == "sync" ]]; then
sync
else
usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment