Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: webrtc/build/ios/build_ios_libs.sh

Issue 2651973002: Moving build/ios to tools-webrtc/ios (Closed)
Patch Set: Fixing path to comply with the new location Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/build/ios/SDK/PodTest/Podfile ('k') | webrtc/build/ios/client.webrtc/iOS32_Debug.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
11 # Generates static FAT libraries for ios in out_ios_libs.
12
13 # Exit on errors.
14 set -e
15
16 # Environment
17 export PATH=/usr/libexec:$PATH
18
19 SCRIPT_DIR=$(cd $(dirname $0) && pwd)
20 WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../..
21
22 function clean_artifacts {
23 local output_dir=$1
24 if [[ -d ${output_dir} ]]; then
25 echo "Deleting ${output_dir}"
26 rm -r ${output_dir}
27 fi
28 }
29
30 function build_webrtc {
31 local target_arch=$1
32 local flavor=$2
33 local build_type=$3
34 local ios_deployment_target=$4
35 local libvpx_build_vp9=$5
36 local use_bitcode=$6
37 local custom_gn_options=$7
38
39 OUTPUT_DIR=${SDK_OUTPUT_DIR}/${target_arch}_libs
40 GN_ARGS="target_os=\"ios\" ios_enable_code_signing=false \
41 use_xcode_clang=true is_component_build=false"
42
43 # Add flavor option.
44 if [[ ${flavor} = "debug" ]]; then
45 GN_ARGS="${GN_ARGS} is_debug=true"
46 elif [[ ${flavor} = "release" ]]; then
47 GN_ARGS="${GN_ARGS} is_debug=false"
48 else
49 echo "Unexpected flavor type: ${flavor}"
50 exit 1
51 fi
52
53 # Add the specified architecture.
54 GN_ARGS="${GN_ARGS} target_cpu=\"${target_arch}\""
55
56 # Add deployment target.
57 GN_ARGS="${GN_ARGS} ios_deployment_target=\"${ios_deployment_target}\""
58
59 # Add vp9 option.
60 GN_ARGS="${GN_ARGS} rtc_libvpx_build_vp9=${libvpx_build_vp9}"
61
62 # Add bitcode option.
63 GN_ARGS="${GN_ARGS} enable_ios_bitcode=${use_bitcode}"
64
65 # Add custom options.
66 if [[ -n "${custom_gn_options}" ]]; then
67 GN_ARGS="${GN_ARGS} ${custom_gn_options}"
68 fi
69
70 # Generate static or dynamic.
71 if [[ ${build_type} = "static_only" ]]; then
72 GN_TARGET_NAME="rtc_sdk_objc"
73 elif [[ ${build_type} == "framework" ]]; then
74 GN_TARGET_NAME="rtc_sdk_framework_objc"
75 GN_ARGS="${GN_ARGS} enable_dsyms=true enable_stripping=true"
76 fi
77
78 echo "Building WebRTC with args: ${GN_ARGS}"
79 gn gen ${OUTPUT_DIR} --args="${GN_ARGS}"
80 echo "Building target: ${GN_TARGET_NAME}"
81 ninja -C ${OUTPUT_DIR} ${GN_TARGET_NAME}
82
83 # Strip debug symbols to reduce size.
84 if [[ ${build_type} = "static_only" ]]; then
85 strip -S ${OUTPUT_DIR}/obj/webrtc/sdk/lib${GN_TARGET_NAME}.a -o \
86 ${OUTPUT_DIR}/lib${GN_TARGET_NAME}.a
87 fi
88 }
89
90 function usage {
91 echo "WebRTC iOS FAT libraries build script."
92 echo "Each architecture is compiled separately before being merged together."
93 echo "By default, the fat libraries will be created in out_ios_libs/."
94 echo "The headers will be copied to out_ios_libs/include."
95 echo "Usage: $0 [-h] [-b build_type] [-c] [-o output_dir]"
96 echo " -h Print this help."
97 echo " -b The build type. Can be framework or static_only."
98 echo " Defaults to framework."
99 echo " -c Removes generated build output."
100 echo " -o Specifies a directory to output build artifacts to."
101 echo " If specified together with -c, deletes the dir."
102 echo " -r Specifies a revision number to embed if building the framework."
103 echo " -e Compile with bitcode."
104 exit 0
105 }
106
107 SDK_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs
108 SDK_LIB_NAME="librtc_sdk_objc.a"
109 SDK_FRAMEWORK_NAME="WebRTC.framework"
110
111 BUILD_FLAVOR="release"
112 BUILD_TYPE="framework"
113 ENABLED_ARCHITECTURES=("arm" "arm64" "x64")
114 IOS_DEPLOYMENT_TARGET="8.0"
115 LIBVPX_BUILD_VP9="false"
116 USE_BITCODE="false"
117 CUSTOM_GN_OPTS=""
118 WEBRTC_REVISION="0"
119
120 # Parse arguments.
121 while getopts "hb:co:r:e" opt; do
122 case "${opt}" in
123 h) usage;;
124 b) BUILD_TYPE="${OPTARG}";;
125 c) PERFORM_CLEAN=1;;
126 e) USE_BITCODE="true";;
127 o) SDK_OUTPUT_DIR="${OPTARG}";;
128 r) WEBRTC_REVISION="${OPTARG}";;
129 *)
130 usage
131 exit 1
132 ;;
133 esac
134 done
135
136 if [[ ${PERFORM_CLEAN} -ne 0 ]]; then
137 clean_artifacts ${SDK_OUTPUT_DIR}
138 exit 0
139 fi
140
141 # Build all architectures.
142 for arch in ${ENABLED_ARCHITECTURES[*]}; do
143 build_webrtc $arch ${BUILD_FLAVOR} ${BUILD_TYPE} \
144 ${IOS_DEPLOYMENT_TARGET} ${LIBVPX_BUILD_VP9} ${USE_BITCODE} \
145 ${CUSTOM_GN_OPTS}
146 done
147
148 # Ignoring x86 except for static libraries for now because of a GN build issue
149 # where the generated dynamic framework has the wrong architectures.
150
151 # Create FAT archive.
152 if [[ ${BUILD_TYPE} = "static_only" ]]; then
153 build_webrtc "x86" ${BUILD_FLAVOR} ${BUILD_TYPE} \
154 ${IOS_DEPLOYMENT_TARGET} ${LIBVPX_BUILD_VP9} ${USE_BITCODE} \
155 ${CUSTOM_GN_OPTS}
156
157 ARM_LIB_PATH=${SDK_OUTPUT_DIR}/arm_libs/${SDK_LIB_NAME}
158 ARM64_LIB_PATH=${SDK_OUTPUT_DIR}/arm64_libs/${SDK_LIB_NAME}
159 X64_LIB_PATH=${SDK_OUTPUT_DIR}/x64_libs/${SDK_LIB_NAME}
160 X86_LIB_PATH=${SDK_OUTPUT_DIR}/x86_libs/${SDK_LIB_NAME}
161
162 # Combine the slices.
163 lipo ${ARM_LIB_PATH} ${ARM64_LIB_PATH} ${X64_LIB_PATH} ${X86_LIB_PATH} \
164 -create -output ${SDK_OUTPUT_DIR}/${SDK_LIB_NAME}
165 elif [[ ${BUILD_TYPE} = "framework" ]]; then
166 ARM_LIB_PATH=${SDK_OUTPUT_DIR}/arm_libs
167 ARM64_LIB_PATH=${SDK_OUTPUT_DIR}/arm64_libs
168 X64_LIB_PATH=${SDK_OUTPUT_DIR}/x64_libs
169 X86_LIB_PATH=${SDK_OUTPUT_DIR}/x86_libs
170
171 # Combine the slices.
172 DYLIB_PATH="WebRTC.framework/WebRTC"
173 cp -R ${ARM64_LIB_PATH}/WebRTC.framework ${SDK_OUTPUT_DIR}
174 rm ${SDK_OUTPUT_DIR}/${DYLIB_PATH}
175 echo "Merging framework slices."
176 lipo ${ARM_LIB_PATH}/${DYLIB_PATH} \
177 ${ARM64_LIB_PATH}/${DYLIB_PATH} \
178 ${X64_LIB_PATH}/${DYLIB_PATH} \
179 -create -output ${SDK_OUTPUT_DIR}/${DYLIB_PATH}
180
181 # Remove stray mobileprovision if it exists until chromium roll lands.
182 # See https://codereview.chromium.org/2397433002.
183 PROVISION_FILE=${SDK_OUTPUT_DIR}/WebRTC.framework/embedded.mobileprovision
184 if [[ -e ${PROVISION_FILE} ]]; then
185 rm ${PROVISION_FILE}
186 fi
187
188 # Merge the dSYM slices.
189 DSYM_PATH="WebRTC.dSYM/Contents/Resources/DWARF/WebRTC"
190 cp -R ${ARM64_LIB_PATH}/WebRTC.dSYM ${SDK_OUTPUT_DIR}
191 rm ${SDK_OUTPUT_DIR}/${DSYM_PATH}
192 echo "Merging dSYM slices."
193 lipo ${ARM_LIB_PATH}/${DSYM_PATH} \
194 ${ARM64_LIB_PATH}/${DSYM_PATH} \
195 ${X64_LIB_PATH}/${DSYM_PATH} \
196 -create -output ${SDK_OUTPUT_DIR}/${DSYM_PATH}
197
198 # Modify the version number.
199 # Format should be <Branch cut MXX>.<Hotfix #>.<Rev #>.
200 # e.g. 55.0.14986 means branch cut 55, no hotfixes, and revision number 14986.
201 INFOPLIST_PATH=${SDK_OUTPUT_DIR}/WebRTC.framework/Info.plist
202 MAJOR_MINOR=$(PlistBuddy -c "Print :CFBundleShortVersionString" \
203 ${INFOPLIST_PATH})
204 VERSION_NUMBER="${MAJOR_MINOR}.${WEBRTC_REVISION}"
205 echo "Substituting revision number: ${VERSION_NUMBER}"
206 PlistBuddy -c "Set :CFBundleVersion ${VERSION_NUMBER}" ${INFOPLIST_PATH}
207 plutil -convert binary1 ${INFOPLIST_PATH}
208 else
209 echo "BUILD_TYPE ${BUILD_TYPE} not supported."
210 exit 1
211 fi
212
213 echo "Done."
OLDNEW
« no previous file with comments | « webrtc/build/ios/SDK/PodTest/Podfile ('k') | webrtc/build/ios/client.webrtc/iOS32_Debug.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698