1#!/bin/bash 2# 3# libjingle 4# Copyright 2015 Google Inc. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are met: 8# 9# 1. Redistributions of source code must retain the above copyright notice, 10# this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright notice, 12# this list of conditions and the following disclaimer in the documentation 13# and/or other materials provided with the distribution. 14# 3. The name of the author may not be used to endorse or promote products 15# derived from this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 18# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28# Generates static FAT libraries for ios in out_ios_libs. 29 30# Check for Darwin. 31if [[ ! $(uname) = "Darwin" ]]; then 32 echo "OS/X required." >&2 33fi 34 35# Check for libtool. 36if [[ -z $(which libtool) ]]; then 37 echo "Missing libtool binary." >&2 38fi 39 40# Check for GYP generator. 41SCRIPT_DIR=$(dirname $0) 42WEBRTC_BASE_DIR=${SCRIPT_DIR}/../.. 43GYP_WEBRTC_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/gyp_webrtc 44if [[ ! -x ${GYP_WEBRTC_SCRIPT} ]]; then 45 echo "Failed to find gyp generator." >&2 46 exit 1 47fi 48# Check for merge script. 49MERGE_SCRIPT=${SCRIPT_DIR}/merge_ios_libs 50if [[ ! -x ${MERGE_SCRIPT} ]]; then 51 echo "Failed to find library merging script." >&2 52 exit 1 53fi 54 55pushd ${WEBRTC_BASE_DIR} 56LIBRARY_BASE_DIR="out_ios_libs" 57 58function build_webrtc { 59 OUTPUT_DIR=$1 60 FLAVOR=$2 61 TARGET_ARCH=$3 62 TARGET_SUBARCH=$4 63 if [[ ${TARGET_ARCH} = 'armv7' || ${TARGET_ARCH} = 'arm64' ]]; then 64 FLAVOR="${FLAVOR}-iphoneos" 65 else 66 FLAVOR="${FLAVOR}-iphonesimulator" 67 fi 68 export GYP_DEFINES="OS=ios use_openssl=1" 69 export GYP_DEFINES="${GYP_DEFINES} target_arch=${TARGET_ARCH}" 70 if [[ -n ${TARGET_SUBARCH} ]]; then 71 export GYP_DEFINES="${GYP_DEFINES} target_subarch=${TARGET_SUBARCH}" 72 fi 73 export GYP_GENERATORS="ninja" 74 export GYP_GENERATOR_FLAGS="output_dir=${OUTPUT_DIR}" 75 webrtc/build/gyp_webrtc talk/build/merge_ios_libs.gyp 76 ninja -C ${OUTPUT_DIR}/${FLAVOR} libjingle_peerconnection_objc_no_op 77 mkdir -p ${LIBRARY_BASE_DIR}/${TARGET_ARCH} 78 mv ${OUTPUT_DIR}/${FLAVOR}/*.a ${LIBRARY_BASE_DIR}/${TARGET_ARCH} 79} 80 81# Build all the common architectures. 82build_webrtc "out_ios_armv7" "Release" "armv7" "arm32" 83build_webrtc "out_ios_arm64" "Release" "arm64" "arm64" 84build_webrtc "out_ios_ia32" "Release" "ia32" "arm32" 85build_webrtc "out_ios_x86_64" "Release" "x64" "arm64" 86 87popd 88 89# Merge the libraries together. 90${MERGE_SCRIPT} ${WEBRTC_BASE_DIR}/${LIBRARY_BASE_DIR} 91