hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license |
| 6 | # that can be found in the LICENSE file in the root of the source |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
| 10 | |
| 11 | # Generates static FAT libraries for ios in out_ios_libs. |
| 12 | |
| 13 | # Flag to build the new or legacy version of the API. |
| 14 | USE_LEGACY_API=0 |
| 15 | |
| 16 | # Check for Darwin. |
| 17 | if [[ ! $(uname) = "Darwin" ]]; then |
| 18 | echo "OS/X required." >&2 |
| 19 | fi |
| 20 | |
| 21 | # Check for libtool. |
| 22 | if [[ -z $(which libtool) ]]; then |
| 23 | echo "Missing libtool binary." >&2 |
| 24 | fi |
| 25 | |
| 26 | # Check for GYP generator. |
| 27 | SCRIPT_DIR=$(dirname $0) |
| 28 | WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../.. |
| 29 | GYP_WEBRTC_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/gyp_webrtc |
| 30 | if [[ ! -x ${GYP_WEBRTC_SCRIPT} ]]; then |
| 31 | echo "Failed to find gyp generator." >&2 |
| 32 | exit 1 |
| 33 | fi |
| 34 | # Check for export headers script. |
| 35 | EXPORT_HEADERS_SCRIPT=${SCRIPT_DIR}/export_headers |
| 36 | if [[ ! -x ${EXPORT_HEADERS_SCRIPT} ]]; then |
| 37 | echo "Failed to find export headers script." >&2 |
| 38 | exit 1 |
| 39 | fi |
| 40 | # Check for merge script. |
| 41 | MERGE_SCRIPT=${SCRIPT_DIR}/merge_ios_libs |
| 42 | if [[ ! -x ${MERGE_SCRIPT} ]]; then |
| 43 | echo "Failed to find library merging script." >&2 |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | pushd ${WEBRTC_BASE_DIR} |
| 48 | LIBRARY_BASE_DIR="out_ios_libs" |
| 49 | |
| 50 | function build_webrtc { |
| 51 | OUTPUT_DIR=$1 |
| 52 | FLAVOR=$2 |
| 53 | TARGET_ARCH=$3 |
| 54 | if [[ ${TARGET_ARCH} = 'arm' || ${TARGET_ARCH} = 'arm64' ]]; then |
| 55 | FLAVOR="${FLAVOR}-iphoneos" |
| 56 | else |
| 57 | FLAVOR="${FLAVOR}-iphonesimulator" |
| 58 | fi |
| 59 | export GYP_DEFINES="OS=ios target_arch=${TARGET_ARCH} use_objc_h264=1 \ |
| 60 | clang_xcode=1" |
| 61 | export GYP_GENERATORS="ninja" |
| 62 | export GYP_GENERATOR_FLAGS="output_dir=${OUTPUT_DIR}" |
| 63 | webrtc/build/gyp_webrtc webrtc/build/ios/merge_ios_libs.gyp |
| 64 | if [[ ${USE_LEGACY_API} -eq 1 ]]; then |
| 65 | ninja -C ${OUTPUT_DIR}/${FLAVOR} libjingle_peerconnection_objc_no_op |
| 66 | else |
| 67 | ninja -C ${OUTPUT_DIR}/${FLAVOR} webrtc_api_objc_no_op |
| 68 | fi |
| 69 | mkdir -p ${LIBRARY_BASE_DIR}/${TARGET_ARCH} |
| 70 | mv ${OUTPUT_DIR}/${FLAVOR}/*.a ${LIBRARY_BASE_DIR}/${TARGET_ARCH} |
| 71 | } |
| 72 | |
| 73 | # Build all the common architectures. |
| 74 | build_webrtc "out_ios_arm" "Release" "arm" |
| 75 | build_webrtc "out_ios_arm64" "Release" "arm64" |
| 76 | build_webrtc "out_ios_ia32" "Release" "ia32" |
| 77 | build_webrtc "out_ios_x86_64" "Release" "x64" |
| 78 | |
| 79 | popd |
| 80 | |
| 81 | # Export header files. |
| 82 | ${EXPORT_HEADERS_SCRIPT} ${WEBRTC_BASE_DIR}/${LIBRARY_BASE_DIR} \ |
| 83 | ${USE_LEGACY_API} |
| 84 | |
| 85 | # Merge the libraries together. |
| 86 | ${MERGE_SCRIPT} ${WEBRTC_BASE_DIR}/${LIBRARY_BASE_DIR} |