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

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

Issue 1903663002: Build dynamic iOS SDK. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix test gyp Created 4 years, 8 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/build_ios_framework.sh ('k') | webrtc/build/ios/export_headers.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 # Generates static FAT libraries for ios in out_ios_libs. 11 # Generates static or dynamic FAT libraries for ios in out_ios_libs.
12 12
13 # Exit on errors. 13 # Exit on errors.
14 set -e 14 set -e
15 15
16 # Globals. 16 # Globals.
17 SCRIPT_DIR=$(cd $(dirname $0) && pwd) 17 SCRIPT_DIR=$(cd $(dirname $0) && pwd)
18 WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../.. 18 WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../..
19 GYP_WEBRTC_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/gyp_webrtc.py 19 GYP_WEBRTC_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/gyp_webrtc.py
20 EXPORT_HEADERS_SCRIPT=${SCRIPT_DIR}/export_headers.py
21 MERGE_SCRIPT=${SCRIPT_DIR}/merge_ios_libs.py 20 MERGE_SCRIPT=${SCRIPT_DIR}/merge_ios_libs.py
22 21
23 function check_preconditions { 22 function check_preconditions {
24 # Check for Darwin. 23 # Check for Darwin.
25 if [[ ! $(uname) = "Darwin" ]]; then 24 if [[ ! $(uname) = "Darwin" ]]; then
26 echo "OS/X required." >&2 25 echo "OS/X required." >&2
27 exit 1 26 exit 1
28 fi 27 fi
29 28
30 # Check for libtool. 29 # Check for libtool.
31 if [[ -z $(which libtool) ]]; then 30 if [[ -z $(which libtool) ]]; then
32 echo "Missing libtool binary." >&2 31 echo "Missing libtool binary." >&2
33 exit 1 32 exit 1
34 fi 33 fi
35 34
36 # Check for GYP generator. 35 # Check for GYP generator.
37 if [[ ! -x ${GYP_WEBRTC_SCRIPT} ]]; then 36 if [[ ! -x ${GYP_WEBRTC_SCRIPT} ]]; then
38 echo "Failed to find gyp generator." >&2 37 echo "Failed to find gyp generator." >&2
39 exit 1 38 exit 1
40 fi 39 fi
41 40
42 # Check for export headers script.
43 if [[ ! -x ${EXPORT_HEADERS_SCRIPT} ]]; then
44 echo "Failed to find export headers script." >&2
45 exit 1
46 fi
47
48 # Check for merge script. 41 # Check for merge script.
49 if [[ ! -x ${MERGE_SCRIPT} ]]; then 42 if [[ ! -x ${MERGE_SCRIPT} ]]; then
50 echo "Failed to find library merging script." >&2 43 echo "Failed to find library merging script." >&2
51 exit 1 44 exit 1
52 fi 45 fi
53 } 46 }
54 47
55 function build_webrtc { 48 function build_webrtc {
56 local base_output_dir=$1 49 local base_output_dir=$1
57 local flavor=$2 50 local flavor=$2
58 local target_arch=$3 51 local target_arch=$3
52 local build_type=$4
53
59 local ninja_output_dir=${base_output_dir}/${target_arch}_ninja 54 local ninja_output_dir=${base_output_dir}/${target_arch}_ninja
60 local library_output_dir=${base_output_dir}/${target_arch}_libs 55 local library_output_dir=${base_output_dir}/${target_arch}_libs
61 if [[ ${target_arch} = 'arm' || ${target_arch} = 'arm64' ]]; then 56 if [[ ${target_arch} = 'arm' || ${target_arch} = 'arm64' ]]; then
62 flavor="${flavor}-iphoneos" 57 flavor="${flavor}-iphoneos"
63 else 58 else
64 flavor="${flavor}-iphonesimulator" 59 flavor="${flavor}-iphonesimulator"
65 fi 60 fi
61 local ninja_flavor_dir=${ninja_output_dir}/${flavor}
62
63 # Compile framework by default.
64 local gyp_file=webrtc/sdk/sdk.gyp
65 local gyp_target=rtc_sdk_framework_objc
66 # Set to 1 to explicitly not hide symbols. We'll want this if we're just
67 # generating static libs.
68 local override_visibility=0
69 if [[ ${build_type} = "legacy" ]]; then
70 echo "Building legacy."
71 gyp_file=webrtc/build/ios/merge_ios_libs.gyp
72 gyp_target=libjingle_peerconnection_objc_no_op
73 override_visibility=1
74 elif [[ ${build_type} = "static_only" ]]; then
75 echo "Building static only."
76 gyp_file=webrtc/build/ios/merge_ios_libs.gyp
77 gyp_target=rtc_sdk_peerconnection_objc_no_op
78 override_visibility=1
79 elif [[ ${build_type} == "framework" ]]; then
80 echo "Building framework."
81 else
82 echo "Unexpected build type: ${build_type}"
83 exit 1
84 fi
85
66 export GYP_DEFINES="OS=ios target_arch=${target_arch} use_objc_h264=1 \ 86 export GYP_DEFINES="OS=ios target_arch=${target_arch} use_objc_h264=1 \
67 clang_xcode=1 ios_override_visibility=1" 87 clang_xcode=1 ios_deployment_target=8.0 \
88 ios_override_visibility=${override_visibility}"
68 export GYP_GENERATORS="ninja" 89 export GYP_GENERATORS="ninja"
69 export GYP_GENERATOR_FLAGS="output_dir=${ninja_output_dir}" 90 export GYP_GENERATOR_FLAGS="output_dir=${ninja_output_dir}"
70 91
71 # GYP generation requires relative path for some reason. 92 # GYP generation requires relative path for some reason.
72 pushd ${WEBRTC_BASE_DIR} 93 pushd ${WEBRTC_BASE_DIR}
73 ${GYP_WEBRTC_SCRIPT} webrtc/build/ios/merge_ios_libs.gyp 94 webrtc/build/gyp_webrtc.py ${gyp_file}
74 popd 95 popd
75 if [[ ${USE_LEGACY_API} -eq 1 ]]; then 96 # Compile the target we're interested in.
76 ninja -C ${ninja_output_dir}/${flavor} libjingle_peerconnection_objc_no_op 97 ninja -C ${ninja_flavor_dir} ${gyp_target}
77 else 98
78 ninja -C ${ninja_output_dir}/${flavor} webrtc_api_objc_no_op 99 if [[ ${build_type} = "framework" ]]; then
100 # Manually generate the dSYM files before stripping them. GYP does not seem
101 # to instruct ninja to generate dSYM files.
102 dsymutil --out=${ninja_flavor_dir}/WebRTC.framework.dSYM \
103 ${ninja_flavor_dir}/WebRTC.framework/WebRTC
79 fi 104 fi
105
106 # Make links to the generated static archives.
80 mkdir -p ${library_output_dir} 107 mkdir -p ${library_output_dir}
81 108 for f in ${ninja_flavor_dir}/*.a
82 for f in ${ninja_output_dir}/${flavor}/*.a
83 do 109 do
84 ln -sf "${f}" "${library_output_dir}/$(basename ${f})" 110 ln -sf "${f}" "${library_output_dir}/$(basename ${f})"
85 done 111 done
86 } 112 }
87 113
88 function clean_artifacts { 114 function clean_artifacts {
89 local output_dir=$1 115 local output_dir=$1
90 if [[ -d ${output_dir} ]]; then 116 if [[ -d ${output_dir} ]]; then
91 rm -r ${output_dir} 117 rm -r ${output_dir}
92 fi 118 fi
93 } 119 }
94 120
95 function usage { 121 function usage {
96 echo "WebRTC iOS FAT libraries build script." 122 echo "WebRTC iOS FAT libraries build script."
97 echo "Each architecture is compiled separately before being merged together." 123 echo "Each architecture is compiled separately before being merged together."
98 echo "By default, the fat libraries will be created in out_ios_libs/fat_libs." 124 echo "By default, the fat libraries will be created in out_ios_libs/fat_libs."
99 echo "The headers will be copied to out_ios_libs/include." 125 echo "The headers will be copied to out_ios_libs/include."
100 echo "Usage: $0 [-h] [-c] [-o]" 126 echo "Usage: $0 [-h] [-b build_type] [-c] [-o output_dir]"
101 echo " -h Print this help." 127 echo " -h Print this help."
128 echo " -b The build type. Can be framework, static_only or legacy."
129 echo " Defaults to framework."
102 echo " -c Removes generated build output." 130 echo " -c Removes generated build output."
103 echo " -o Specifies a directory to output build artifacts to." 131 echo " -o Specifies a directory to output build artifacts to."
104 echo " If specified together with -c, deletes the dir." 132 echo " If specified together with -c, deletes the dir."
133 echo " -r Specifies a revision number to embed if building the framework."
105 exit 0 134 exit 0
106 } 135 }
107 136
108 check_preconditions 137 check_preconditions
109 138
110 # Set default arguments. 139 # Set default arguments.
111 # Output directory for build artifacts. 140 # Output directory for build artifacts.
112 OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs 141 OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs
113 # Flag to build the new or legacy version of the API. 142 # The type of build to perform. Valid arguments are framework, static_only and
114 USE_LEGACY_API=0 143 # legacy.
144 BUILD_TYPE="framework"
115 PERFORM_CLEAN=0 145 PERFORM_CLEAN=0
146 FLAVOR="Profile"
147 POINT_VERSION="0"
116 148
117 # Parse arguments. 149 # Parse arguments.
118 while getopts "hco:" opt; do 150 while getopts "hb:co:r:" opt; do
119 case "${opt}" in 151 case "${opt}" in
120 h) usage;; 152 h) usage;;
153 b) BUILD_TYPE="${OPTARG}";;
121 c) PERFORM_CLEAN=1;; 154 c) PERFORM_CLEAN=1;;
122 o) OUTPUT_DIR="${OPTARG}";; 155 o) OUTPUT_DIR="${OPTARG}";;
156 r) POINT_VERSION="${OPTARG}";;
123 *) 157 *)
124 usage 158 usage
125 exit 1 159 exit 1
126 ;; 160 ;;
127 esac 161 esac
128 done 162 done
129 163
130 if [[ ${PERFORM_CLEAN} -ne 0 ]]; then 164 if [[ ${PERFORM_CLEAN} -ne 0 ]]; then
131 clean_artifacts ${OUTPUT_DIR} 165 clean_artifacts ${OUTPUT_DIR}
132 exit 0 166 exit 0
133 fi 167 fi
134 168
135 # Build all the common architectures. 169 # Build all the common architectures.
136 archs=( "arm" "arm64" "ia32" "x64" ) 170 ARCHS=( "arm" "arm64" "ia32" "x64" )
137 for arch in "${archs[@]}" 171 for ARCH in "${ARCHS[@]}"
138 do 172 do
139 echo "Building WebRTC arch: ${arch}" 173 echo "Building WebRTC arch: ${ARCH}"
140 build_webrtc ${OUTPUT_DIR} "Profile" $arch 174 build_webrtc ${OUTPUT_DIR} ${FLAVOR} $ARCH ${BUILD_TYPE}
141 done 175 done
142 176
143 # Export header files. 177 ARM_NINJA_DIR=${OUTPUT_DIR}/arm_ninja/${FLAVOR}-iphoneos
144 ${EXPORT_HEADERS_SCRIPT} ${OUTPUT_DIR} ${USE_LEGACY_API} 178 ARM64_NINJA_DIR=${OUTPUT_DIR}/arm64_ninja/${FLAVOR}-iphoneos
179 IA32_NINJA_DIR=${OUTPUT_DIR}/ia32_ninja/${FLAVOR}-iphonesimulator
180 X64_NINJA_DIR=${OUTPUT_DIR}/x64_ninja/${FLAVOR}-iphonesimulator
145 181
146 # Merge the libraries together. 182 if [[ ${BUILD_TYPE} = "framework" ]]; then
147 ${MERGE_SCRIPT} ${OUTPUT_DIR} 183 # Merge the framework slices together into a FAT library by copying one arch
184 # output and merging the rest in.
185 DYLIB_PATH="WebRTC.framework/WebRTC"
186 cp -R ${ARM_NINJA_DIR}/WebRTC.framework ${OUTPUT_DIR}
187 rm ${OUTPUT_DIR}/${DYLIB_PATH}
188 echo "Merging framework slices."
189 lipo ${ARM_NINJA_DIR}/${DYLIB_PATH} \
190 ${ARM64_NINJA_DIR}/${DYLIB_PATH} \
191 ${IA32_NINJA_DIR}/${DYLIB_PATH} \
192 ${X64_NINJA_DIR}/${DYLIB_PATH} \
193 -create -output ${OUTPUT_DIR}/${DYLIB_PATH}
194
195 # Merge the dSYM files together in a similar fashion.
196 DSYM_PATH="WebRTC.framework.dSYM/Contents/Resources/DWARF/WebRTC"
197 cp -R ${ARM_NINJA_DIR}/WebRTC.framework.dSYM ${OUTPUT_DIR}
198 rm ${OUTPUT_DIR}/${DSYM_PATH}
199 echo "Merging dSYM slices."
200 lipo ${ARM_NINJA_DIR}/${DSYM_PATH} \
201 ${ARM64_NINJA_DIR}/${DSYM_PATH} \
202 ${IA32_NINJA_DIR}/${DSYM_PATH} \
203 ${X64_NINJA_DIR}/${DSYM_PATH} \
204 -create -output ${OUTPUT_DIR}/${DSYM_PATH}
205
206 # Strip the dynamic framework of non-global symbols.
207 # TODO(tkchin): Override chromium strip settings in supplement.gypi instead.
208 echo "Stripping non-global symbols."
209 strip -x ${OUTPUT_DIR}/${DYLIB_PATH}
210
211 # Modify the version number.
212 INFOPLIST_PATH=${OUTPUT_DIR}/WebRTC.framework/Resources/Info.plist
213 MAJOR_MINOR=$(plistbuddy -c "Print :CFBundleShortVersionString" \
214 ${INFOPLIST_PATH})
215 VERSION_NUMBER="${MAJOR_MINOR}.${POINT_VERSION}"
216 echo "Substituting revision number: ${VERSION_NUMBER}"
217 plistbuddy -c "Set :CFBundleVersion ${VERSION_NUMBER}" ${INFOPLIST_PATH}
218 plutil -convert binary1 ${INFOPLIST_PATH}
219
220 # Copy pod file.
221 FORMAT_STRING=s/\${FRAMEWORK_VERSION_NUMBER}/${VERSION_NUMBER}/g
222 sed -e ${FORMAT_STRING} ${WEBRTC_BASE_DIR}/webrtc/sdk/objc/WebRTC.podspec > \
223 ${OUTPUT_DIR}/WebRTC.podspec
224 else
225 echo "Merging static library slices."
226 # Merge the static libraries together into individual FAT archives.
227 ${MERGE_SCRIPT} ${OUTPUT_DIR}
228
229 # Merge the dSYM files together.
230 TARGET_NAME="rtc_sdk_peerconnection_objc_no_op"
231 if [[ ${BUILD_TYPE} = "legacy" ]]; then
232 TARGET_NAME="libjingle_peerconnection_objc_no_op"
233 fi
234 DSYM_PATH="${TARGET_NAME}.app.dSYM/Contents/Resources/DWARF/${TARGET_NAME}"
235 cp -R ${ARM_NINJA_DIR}/${TARGET_NAME}.app.dSYM ${OUTPUT_DIR}
236 echo "Merging dSYM slices."
237 lipo ${ARM_NINJA_DIR}/${DSYM_PATH} \
238 ${ARM64_NINJA_DIR}/${DSYM_PATH} \
239 ${IA32_NINJA_DIR}/${DSYM_PATH} \
240 ${X64_NINJA_DIR}/${DSYM_PATH} \
241 -create -output ${OUTPUT_DIR}/${DSYM_PATH}
242
243 # Strip debugging symbols.
244 # TODO(tkchin): Override chromium settings in supplement.gypi instead to do
245 # stripping at build time.
246 echo "Stripping debug symbols."
247 strip -S ${OUTPUT_DIR}/fat_libs/*.a
248
249 # Symlink the headers.
250 echo "Symlinking headers."
251 INPUT_HEADER_DIR="${WEBRTC_BASE_DIR}/webrtc/sdk/objc/Framework/Headers/WebRTC"
252 OUTPUT_HEADER_DIR="${OUTPUT_DIR}/include"
253 if [[ -d ${OUTPUT_HEADER_DIR} ]]; then
254 rm -rf ${OUTPUT_HEADER_DIR}
255 fi
256 if [[ ${BUILD_TYPE} = "legacy" ]]; then
257 INPUT_HEADER_DIR="${WEBRTC_BASE_DIR}/talk/app/webrtc/objc/public"
258 ln -sf ${INPUT_HEADER_DIR} ${OUTPUT_HEADER_DIR}
259 else
260 mkdir -p ${OUTPUT_HEADER_DIR}
261 ln -sf ${INPUT_HEADER_DIR} ${OUTPUT_HEADER_DIR}/WebRTC
262 fi
263 fi
264
265 echo "Done!"
OLDNEW
« no previous file with comments | « webrtc/build/ios/build_ios_framework.sh ('k') | webrtc/build/ios/export_headers.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698