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 | |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 11 | # Generates static FAT libraries for ios in out_ios_libs. |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 12 | |
tkchin | 5209d67 | 2016-04-16 12:06:33 -0700 | [diff] [blame] | 13 | # Exit on errors. |
| 14 | set -e |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 15 | |
tkchin | 5209d67 | 2016-04-16 12:06:33 -0700 | [diff] [blame] | 16 | SCRIPT_DIR=$(cd $(dirname $0) && pwd) |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 17 | WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../.. |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 18 | |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 19 | SDK_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs |
| 20 | SDK_LIB_NAME="librtc_sdk_objc.a" |
| 21 | GN_BASE_ARGS="target_os=\"ios\" is_debug=false ios_enable_code_signing=false \ |
| 22 | rtc_libvpx_build_vp9=false" |
| 23 | GN_STATIC_TARGET_NAMES="rtc_sdk_peerconnection_objc field_trial_default \ |
| 24 | metrics_default" |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 25 | |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 26 | # TODO(tkchin): Restore functionality of old script to build dynamic framework, |
| 27 | # symbols and license file. |
tkchin | 5209d67 | 2016-04-16 12:06:33 -0700 | [diff] [blame] | 28 | |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 29 | function build_static_webrtc { |
| 30 | local arch=$1 |
| 31 | local xcode_arch=$2 |
tkchin | 5209d67 | 2016-04-16 12:06:33 -0700 | [diff] [blame] | 32 | |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 33 | 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} |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 42 | } |
| 43 | |
tkchin | 5209d67 | 2016-04-16 12:06:33 -0700 | [diff] [blame] | 44 | # Build all the common architectures. |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 45 | build_static_webrtc "arm" "armv7" |
| 46 | build_static_webrtc "arm64" "arm64" |
| 47 | build_static_webrtc "x86" "i386" |
| 48 | build_static_webrtc "x64" "x86_64" |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 49 | |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 50 | # Combine the libraries. |
| 51 | lipo ${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} |
hjon | bc73fe1 | 2016-03-21 11:38:26 -0700 | [diff] [blame] | 56 | |
tkchin | 5fa51e2 | 2016-10-05 13:16:03 -0700 | [diff] [blame^] | 57 | echo "Done." |