blob: a50140e335417f065897eaf266b06c719325f15b [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
tkchin5fa51e22016-10-05 13:16:03 -070011# Generates static FAT libraries for ios in out_ios_libs.
hjonbc73fe12016-03-21 11:38:26 -070012
tkchin5209d672016-04-16 12:06:33 -070013# Exit on errors.
14set -e
hjonbc73fe12016-03-21 11:38:26 -070015
tkchin5209d672016-04-16 12:06:33 -070016SCRIPT_DIR=$(cd $(dirname $0) && pwd)
hjonbc73fe12016-03-21 11:38:26 -070017WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../..
hjonbc73fe12016-03-21 11:38:26 -070018
tkchin5fa51e22016-10-05 13:16:03 -070019SDK_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs
20SDK_LIB_NAME="librtc_sdk_objc.a"
21GN_BASE_ARGS="target_os=\"ios\" is_debug=false ios_enable_code_signing=false \
22rtc_libvpx_build_vp9=false"
23GN_STATIC_TARGET_NAMES="rtc_sdk_peerconnection_objc field_trial_default \
24metrics_default"
hjonbc73fe12016-03-21 11:38:26 -070025
tkchin5fa51e22016-10-05 13:16:03 -070026# TODO(tkchin): Restore functionality of old script to build dynamic framework,
27# symbols and license file.
tkchin5209d672016-04-16 12:06:33 -070028
tkchin5fa51e22016-10-05 13:16:03 -070029function build_static_webrtc {
30 local arch=$1
31 local xcode_arch=$2
tkchin5209d672016-04-16 12:06:33 -070032
tkchin5fa51e22016-10-05 13:16:03 -070033 OUTPUT_DIR=${SDK_OUTPUT_DIR}/${arch}_libs
34 OUTPUT_LIB=${OUTPUT_DIR}/${SDK_LIB_NAME}
35 GN_ARGS="${GN_BASE_ARGS} target_cpu=\"${arch}\""
36 gn gen ${OUTPUT_DIR} --args="${GN_ARGS}"
37 ninja -C ${OUTPUT_DIR} ${GN_STATIC_TARGET_NAMES}
38 # Combine the object files together into a single archive and strip debug
39 # symbols.
40 find ${OUTPUT_DIR}/obj -type f -name "*.o" |
41 xargs ld -r -static -S -all_load -arch ${xcode_arch} -o ${OUTPUT_LIB}
hjonbc73fe12016-03-21 11:38:26 -070042}
43
tkchin5209d672016-04-16 12:06:33 -070044# Build all the common architectures.
tkchin5fa51e22016-10-05 13:16:03 -070045build_static_webrtc "arm" "armv7"
46build_static_webrtc "arm64" "arm64"
47build_static_webrtc "x86" "i386"
48build_static_webrtc "x64" "x86_64"
hjonbc73fe12016-03-21 11:38:26 -070049
tkchin5fa51e22016-10-05 13:16:03 -070050# Combine the libraries.
51lipo ${SDK_OUTPUT_DIR}/arm_libs/${SDK_LIB_NAME} \
52 ${SDK_OUTPUT_DIR}/arm64_libs/${SDK_LIB_NAME} \
53 ${SDK_OUTPUT_DIR}/x86_libs/${SDK_LIB_NAME} \
54 ${SDK_OUTPUT_DIR}/x64_libs/${SDK_LIB_NAME} \
55 -create -output ${SDK_OUTPUT_DIR}/${SDK_LIB_NAME}
hjonbc73fe12016-03-21 11:38:26 -070056
tkchin5fa51e22016-10-05 13:16:03 -070057echo "Done."