blob: 1d920a49baa6495cf38d8486cab9edf473f150d8 [file] [log] [blame]
hjonbc73fe12016-03-21 11:38:26 -07001#!/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.
14USE_LEGACY_API=0
15
16# Check for Darwin.
17if [[ ! $(uname) = "Darwin" ]]; then
18 echo "OS/X required." >&2
19fi
20
21# Check for libtool.
22if [[ -z $(which libtool) ]]; then
23 echo "Missing libtool binary." >&2
24fi
25
26# Check for GYP generator.
27SCRIPT_DIR=$(dirname $0)
28WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../..
29GYP_WEBRTC_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/gyp_webrtc
30if [[ ! -x ${GYP_WEBRTC_SCRIPT} ]]; then
31 echo "Failed to find gyp generator." >&2
32 exit 1
33fi
34# Check for export headers script.
35EXPORT_HEADERS_SCRIPT=${SCRIPT_DIR}/export_headers
36if [[ ! -x ${EXPORT_HEADERS_SCRIPT} ]]; then
37 echo "Failed to find export headers script." >&2
38 exit 1
39fi
40# Check for merge script.
41MERGE_SCRIPT=${SCRIPT_DIR}/merge_ios_libs
42if [[ ! -x ${MERGE_SCRIPT} ]]; then
43 echo "Failed to find library merging script." >&2
44 exit 1
45fi
46
47pushd ${WEBRTC_BASE_DIR}
48LIBRARY_BASE_DIR="out_ios_libs"
49
50function 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 \
60clang_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.
74build_webrtc "out_ios_arm" "Release" "arm"
75build_webrtc "out_ios_arm64" "Release" "arm64"
76build_webrtc "out_ios_ia32" "Release" "ia32"
77build_webrtc "out_ios_x86_64" "Release" "x64"
78
79popd
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}