OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # Copyright 2016 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 or dynamic FAT libraries for ios in out_ios_libs. |
| 12 |
| 13 # Exit on errors. |
| 14 set -e |
| 15 |
| 16 SCRIPT_DIR=$(cd $(dirname $0) && pwd) |
| 17 WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../.. |
| 18 |
| 19 SDK_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_sdk |
| 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_override_visibility=true" |
| 23 GN_STATIC_TARGET_NAMES="rtc_sdk_peerconnection_objc field_trial_default \ |
| 24 metrics_default" |
| 25 |
| 26 # Chromium currently hides all inline symbols by default. This is not |
| 27 # overridable in GN, but we need it to build static libraries correctly. Apply |
| 28 # a temporary hack to get what we want until inline symbol visibility is |
| 29 # configurable. |
| 30 CHROMIUM_BASE_DIR=${WEBRTC_BASE_DIR}/chromium/src |
| 31 pushd ${CHROMIUM_BASE_DIR} |
| 32 git apply ${SCRIPT_DIR}/rtc_override_visibility.diff |
| 33 popd |
| 34 |
| 35 # Static libraries need to be built with all symbols visible for linking to |
| 36 # behave correctly when static libraries are included in external projects. |
| 37 function build_static_webrtc { |
| 38 local arch=$1 |
| 39 local xcode_arch=$2 |
| 40 |
| 41 OUTPUT_DIR=${SDK_OUTPUT_DIR}/${arch}_libs |
| 42 OUTPUT_LIB=${OUTPUT_DIR}/${SDK_LIB_NAME} |
| 43 GN_ARGS="${GN_BASE_ARGS} target_cpu=\"${arch}\"" |
| 44 gn gen ${OUTPUT_DIR} --args="${GN_ARGS}" |
| 45 ninja -C ${OUTPUT_DIR} ${GN_STATIC_TARGET_NAMES} |
| 46 find ${OUTPUT_DIR}/obj -type f -name "*.o" | |
| 47 xargs ld -r -static -S -all_load -arch ${xcode_arch} -o ${OUTPUT_LIB} |
| 48 } |
| 49 |
| 50 # Build all the common architectures. |
| 51 build_static_webrtc "arm" "armv7" |
| 52 build_static_webrtc "arm64" "arm64" |
| 53 build_static_webrtc "x86" "i386" |
| 54 build_static_webrtc "x64" "x86_64" |
| 55 |
| 56 # Combine the libraries. |
| 57 lipo ${SDK_OUTPUT_DIR}/arm_libs/${SDK_LIB_NAME} \ |
| 58 ${SDK_OUTPUT_DIR}/arm64_libs/${SDK_LIB_NAME} \ |
| 59 ${SDK_OUTPUT_DIR}/x86_libs/${SDK_LIB_NAME} \ |
| 60 ${SDK_OUTPUT_DIR}/x64_libs/${SDK_LIB_NAME} \ |
| 61 -create -output ${SDK_OUTPUT_DIR}/${SDK_LIB_NAME} |
| 62 |
| 63 # Undo our hack. |
| 64 pushd ${CHROMIUM_BASE_DIR} |
| 65 git checkout -- build/config/compiler/BUILD.gn |
| 66 popd |
OLD | NEW |