| OLD | NEW | 
|---|
| 1 #!/bin/bash | 1 #!/bin/bash | 
| 2 | 2 | 
| 3 #  Copyright 2015 The WebRTC project authors. All Rights Reserved. | 3 #  Copyright 2015 The WebRTC project authors. All Rights Reserved. | 
| 4 # | 4 # | 
| 5 #  Use of this source code is governed by a BSD-style license | 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 | 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 | 7 #  tree. An additional intellectual property rights grant can be found | 
| 8 #  in the file PATENTS.  All contributing project authors may | 8 #  in the file PATENTS.  All contributing project authors may | 
| 9 #  be found in the AUTHORS file in the root of the source tree. | 9 #  be found in the AUTHORS file in the root of the source tree. | 
| 10 | 10 | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 26     rm -r ${output_dir} | 26     rm -r ${output_dir} | 
| 27   fi | 27   fi | 
| 28 } | 28 } | 
| 29 | 29 | 
| 30 function build_webrtc { | 30 function build_webrtc { | 
| 31   local target_arch=$1 | 31   local target_arch=$1 | 
| 32   local flavor=$2 | 32   local flavor=$2 | 
| 33   local build_type=$3 | 33   local build_type=$3 | 
| 34   local ios_deployment_target=$4 | 34   local ios_deployment_target=$4 | 
| 35   local libvpx_build_vp9=$5 | 35   local libvpx_build_vp9=$5 | 
| 36   local custom_gn_options=$6 | 36   local use_bitcode=$6 | 
|  | 37   local custom_gn_options=$7 | 
| 37 | 38 | 
| 38   OUTPUT_DIR=${SDK_OUTPUT_DIR}/${target_arch}_libs | 39   OUTPUT_DIR=${SDK_OUTPUT_DIR}/${target_arch}_libs | 
| 39   GN_ARGS="target_os=\"ios\" ios_enable_code_signing=false \ | 40   GN_ARGS="target_os=\"ios\" ios_enable_code_signing=false \ | 
| 40 use_xcode_clang=true is_component_build=false rtc_ios_enable_bitcode=true" | 41 use_xcode_clang=true is_component_build=false" | 
| 41 | 42 | 
| 42   # Add flavor option. | 43   # Add flavor option. | 
| 43   if [[ ${flavor} = "debug" ]]; then | 44   if [[ ${flavor} = "debug" ]]; then | 
| 44     GN_ARGS="${GN_ARGS} is_debug=true" | 45     GN_ARGS="${GN_ARGS} is_debug=true" | 
| 45   elif [[ ${flavor} = "release" ]]; then | 46   elif [[ ${flavor} = "release" ]]; then | 
| 46     GN_ARGS="${GN_ARGS} is_debug=false" | 47     GN_ARGS="${GN_ARGS} is_debug=false" | 
| 47   else | 48   else | 
| 48     echo "Unexpected flavor type: ${flavor}" | 49     echo "Unexpected flavor type: ${flavor}" | 
| 49     exit 1 | 50     exit 1 | 
| 50   fi | 51   fi | 
| 51 | 52 | 
| 52   # Add the specified architecture. | 53   # Add the specified architecture. | 
| 53   OUTPUT_LIB=${OUTPUT_DIR}/${SDK_LIB_NAME} | 54   OUTPUT_LIB=${OUTPUT_DIR}/${SDK_LIB_NAME} | 
| 54   GN_ARGS="${GN_ARGS} target_cpu=\"${target_arch}\"" | 55   GN_ARGS="${GN_ARGS} target_cpu=\"${target_arch}\"" | 
| 55 | 56 | 
| 56   # Add deployment target. | 57   # Add deployment target. | 
| 57   GN_ARGS="${GN_ARGS} ios_deployment_target=\"${ios_deployment_target}\"" | 58   GN_ARGS="${GN_ARGS} ios_deployment_target=\"${ios_deployment_target}\"" | 
| 58 | 59 | 
| 59   # Add vp9 option. | 60   # Add vp9 option. | 
| 60   GN_ARGS="${GN_ARGS} rtc_libvpx_build_vp9=${libvpx_build_vp9}" | 61   GN_ARGS="${GN_ARGS} rtc_libvpx_build_vp9=${libvpx_build_vp9}" | 
| 61 | 62 | 
|  | 63   # Add bitcode option. | 
|  | 64   GN_ARGS="${GN_ARGS} rtc_ios_enable_bitcode=${use_bitcode}" | 
|  | 65 | 
| 62   # Add custom options. | 66   # Add custom options. | 
| 63   if [[ -n "${custom_gn_options}" ]]; then | 67   if [[ -n "${custom_gn_options}" ]]; then | 
| 64     GN_ARGS="${GN_ARGS} ${custom_gn_options}" | 68     GN_ARGS="${GN_ARGS} ${custom_gn_options}" | 
| 65   fi | 69   fi | 
| 66 | 70 | 
| 67   # Generate static or dynamic. | 71   # Generate static or dynamic. | 
| 68   if [[ ${build_type} = "static_only" ]]; then | 72   if [[ ${build_type} = "static_only" ]]; then | 
| 69     GN_TARGET_NAME="rtc_sdk_objc" | 73     GN_TARGET_NAME="rtc_sdk_objc" | 
| 70   elif [[ ${build_type} == "framework" ]]; then | 74   elif [[ ${build_type} == "framework" ]]; then | 
| 71     GN_TARGET_NAME="rtc_sdk_framework_objc" | 75     GN_TARGET_NAME="rtc_sdk_framework_objc" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 90   echo "By default, the fat libraries will be created in out_ios_libs/." | 94   echo "By default, the fat libraries will be created in out_ios_libs/." | 
| 91   echo "The headers will be copied to out_ios_libs/include." | 95   echo "The headers will be copied to out_ios_libs/include." | 
| 92   echo "Usage: $0 [-h] [-b build_type] [-c] [-o output_dir]" | 96   echo "Usage: $0 [-h] [-b build_type] [-c] [-o output_dir]" | 
| 93   echo "  -h Print this help." | 97   echo "  -h Print this help." | 
| 94   echo "  -b The build type. Can be framework or static_only." | 98   echo "  -b The build type. Can be framework or static_only." | 
| 95   echo "     Defaults to framework." | 99   echo "     Defaults to framework." | 
| 96   echo "  -c Removes generated build output." | 100   echo "  -c Removes generated build output." | 
| 97   echo "  -o Specifies a directory to output build artifacts to." | 101   echo "  -o Specifies a directory to output build artifacts to." | 
| 98   echo "     If specified together with -c, deletes the dir." | 102   echo "     If specified together with -c, deletes the dir." | 
| 99   echo "  -r Specifies a revision number to embed if building the framework." | 103   echo "  -r Specifies a revision number to embed if building the framework." | 
|  | 104   echo "  -e Compile with bitcode." | 
| 100   exit 0 | 105   exit 0 | 
| 101 } | 106 } | 
| 102 | 107 | 
| 103 SDK_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs | 108 SDK_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs | 
| 104 SDK_LIB_NAME="librtc_sdk_objc.a" | 109 SDK_LIB_NAME="librtc_sdk_objc.a" | 
| 105 SDK_FRAMEWORK_NAME="WebRTC.framework" | 110 SDK_FRAMEWORK_NAME="WebRTC.framework" | 
| 106 | 111 | 
| 107 BUILD_FLAVOR="release" | 112 BUILD_FLAVOR="release" | 
| 108 BUILD_TYPE="framework" | 113 BUILD_TYPE="framework" | 
| 109 ENABLED_ARCHITECTURES=("arm" "arm64" "x64") | 114 ENABLED_ARCHITECTURES=("arm" "arm64" "x64") | 
| 110 IOS_DEPLOYMENT_TARGET="8.0" | 115 IOS_DEPLOYMENT_TARGET="8.0" | 
| 111 LIBVPX_BUILD_VP9="false" | 116 LIBVPX_BUILD_VP9="false" | 
|  | 117 USE_BITCODE="false" | 
| 112 CUSTOM_GN_OPTS="" | 118 CUSTOM_GN_OPTS="" | 
| 113 WEBRTC_REVISION="0" | 119 WEBRTC_REVISION="0" | 
| 114 | 120 | 
| 115 # Parse arguments. | 121 # Parse arguments. | 
| 116 while getopts "hb:co:r:" opt; do | 122 while getopts "hb:co:r:" opt; do | 
| 117   case "${opt}" in | 123   case "${opt}" in | 
| 118     h) usage;; | 124     h) usage;; | 
| 119     b) BUILD_TYPE="${OPTARG}";; | 125     b) BUILD_TYPE="${OPTARG}";; | 
| 120     c) PERFORM_CLEAN=1;; | 126     c) PERFORM_CLEAN=1;; | 
|  | 127     e) USE_BITCODE="true";; | 
| 121     o) SDK_OUTPUT_DIR="${OPTARG}";; | 128     o) SDK_OUTPUT_DIR="${OPTARG}";; | 
| 122     r) WEBRTC_REVISION="${OPTARG}";; | 129     r) WEBRTC_REVISION="${OPTARG}";; | 
| 123     *) | 130     *) | 
| 124       usage | 131       usage | 
| 125       exit 1 | 132       exit 1 | 
| 126       ;; | 133       ;; | 
| 127   esac | 134   esac | 
| 128 done | 135 done | 
| 129 | 136 | 
| 130 if [[ ${PERFORM_CLEAN} -ne 0 ]]; then | 137 if [[ ${PERFORM_CLEAN} -ne 0 ]]; then | 
| 131   clean_artifacts ${SDK_OUTPUT_DIR} | 138   clean_artifacts ${SDK_OUTPUT_DIR} | 
| 132   exit 0 | 139   exit 0 | 
| 133 fi | 140 fi | 
| 134 | 141 | 
| 135 # Build all architectures. | 142 # Build all architectures. | 
| 136 for arch in ${ENABLED_ARCHITECTURES[*]}; do | 143 for arch in ${ENABLED_ARCHITECTURES[*]}; do | 
| 137     build_webrtc $arch ${BUILD_FLAVOR} ${BUILD_TYPE} \ | 144     build_webrtc $arch ${BUILD_FLAVOR} ${BUILD_TYPE} \ | 
| 138                  ${IOS_DEPLOYMENT_TARGET} ${LIBVPX_BUILD_VP9} ${CUSTOM_GN_OPTS} | 145                  ${IOS_DEPLOYMENT_TARGET} ${LIBVPX_BUILD_VP9} ${USE_BITCODE} \ | 
|  | 146                  ${CUSTOM_GN_OPTS} | 
| 139 done | 147 done | 
| 140 | 148 | 
| 141 # Ignoring x86 except for static libraries for now because of a GN build issue | 149 # Ignoring x86 except for static libraries for now because of a GN build issue | 
| 142 # where the generated dynamic framework has the wrong architectures. | 150 # where the generated dynamic framework has the wrong architectures. | 
| 143 | 151 | 
| 144 # Create FAT archive. | 152 # Create FAT archive. | 
| 145 if [[ ${BUILD_TYPE} = "static_only" ]]; then | 153 if [[ ${BUILD_TYPE} = "static_only" ]]; then | 
| 146   build_webrtc "x86" ${BUILD_FLAVOR} ${BUILD_TYPE} \ | 154   build_webrtc "x86" ${BUILD_FLAVOR} ${BUILD_TYPE} \ | 
| 147                ${IOS_DEPLOYMENT_TARGET} ${LIBVPX_BUILD_VP9} ${CUSTOM_GN_OPTS} | 155                ${IOS_DEPLOYMENT_TARGET} ${LIBVPX_BUILD_VP9} ${USE_BITCODE} \ | 
|  | 156                ${CUSTOM_GN_OPTS} | 
| 148 | 157 | 
| 149   ARM_LIB_PATH=${SDK_OUTPUT_DIR}/arm_libs/${SDK_LIB_NAME} | 158   ARM_LIB_PATH=${SDK_OUTPUT_DIR}/arm_libs/${SDK_LIB_NAME} | 
| 150   ARM64_LIB_PATH=${SDK_OUTPUT_DIR}/arm64_libs/${SDK_LIB_NAME} | 159   ARM64_LIB_PATH=${SDK_OUTPUT_DIR}/arm64_libs/${SDK_LIB_NAME} | 
| 151   X64_LIB_PATH=${SDK_OUTPUT_DIR}/x64_libs/${SDK_LIB_NAME} | 160   X64_LIB_PATH=${SDK_OUTPUT_DIR}/x64_libs/${SDK_LIB_NAME} | 
| 152   X86_LIB_PATH=${SDK_OUTPUT_DIR}/x86_libs/${SDK_LIB_NAME} | 161   X86_LIB_PATH=${SDK_OUTPUT_DIR}/x86_libs/${SDK_LIB_NAME} | 
| 153 | 162 | 
| 154   # Combine the slices. | 163   # Combine the slices. | 
| 155   lipo ${ARM_LIB_PATH} ${ARM64_LIB_PATH} ${X64_LIB_PATH} ${X86_LIB_PATH} \ | 164   lipo ${ARM_LIB_PATH} ${ARM64_LIB_PATH} ${X64_LIB_PATH} ${X86_LIB_PATH} \ | 
| 156        -create -output ${SDK_OUTPUT_DIR}/${SDK_LIB_NAME} | 165        -create -output ${SDK_OUTPUT_DIR}/${SDK_LIB_NAME} | 
| 157 elif [[ ${BUILD_TYPE} = "framework" ]]; then | 166 elif [[ ${BUILD_TYPE} = "framework" ]]; then | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 196   VERSION_NUMBER="${MAJOR_MINOR}.${WEBRTC_REVISION}" | 205   VERSION_NUMBER="${MAJOR_MINOR}.${WEBRTC_REVISION}" | 
| 197   echo "Substituting revision number: ${VERSION_NUMBER}" | 206   echo "Substituting revision number: ${VERSION_NUMBER}" | 
| 198   PlistBuddy -c "Set :CFBundleVersion ${VERSION_NUMBER}" ${INFOPLIST_PATH} | 207   PlistBuddy -c "Set :CFBundleVersion ${VERSION_NUMBER}" ${INFOPLIST_PATH} | 
| 199   plutil -convert binary1 ${INFOPLIST_PATH} | 208   plutil -convert binary1 ${INFOPLIST_PATH} | 
| 200 else | 209 else | 
| 201   echo "BUILD_TYPE ${BUILD_TYPE} not supported." | 210   echo "BUILD_TYPE ${BUILD_TYPE} not supported." | 
| 202   exit 1 | 211   exit 1 | 
| 203 fi | 212 fi | 
| 204 | 213 | 
| 205 echo "Done." | 214 echo "Done." | 
| OLD | NEW | 
|---|