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

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

Issue 1875003004: Fix WebRTC API framework build. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase 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/SDK/Framework/WebRTC/WebRTC.h ('k') | webrtc/build/ios/build_ios_libs.sh » ('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 dynamic FAT framework for iOS in out_ios_framework. 11 # Generates dynamic FAT framework for iOS in out_ios_framework.
12 12
13 # Check for Darwin. 13 # Exit on errors.
14 if [[ ! $(uname) = "Darwin" ]]; then 14 set -e
15 echo "OS X required." >&2 15
16 # Globals.
17 SCRIPT_DIR=$(cd $(dirname $0) && pwd)
18 WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../..
19 BUILD_WEBRTC_SCRIPT=${SCRIPT_DIR}/build_ios_libs.sh
20 FLATTEN_HEADERS_SCRIPT=${SCRIPT_DIR}/flatten_ios_headers.py
21 SDK_DIR=${SCRIPT_DIR}/SDK
22 FRAMEWORK_PROJECT_DIR=${SDK_DIR}/Framework
23 FRAMEWORK_PROJECT_PATH=${FRAMEWORK_PROJECT_DIR}/WebRTC.xcodeproj
24
25 function check_preconditions {
26 # Check for Darwin.
27 if [[ ! $(uname) = "Darwin" ]]; then
28 echo "OS X required." >&2
29 exit 1
30 fi
31 if [[ ! -x ${BUILD_WEBRTC_SCRIPT} ]]; then
32 echo "Failed to find iOS library build script." >&2
33 exit 1
34 fi
35 if [[ ! -x ${FLATTEN_HEADERS_SCRIPT} ]]; then
36 echo "Failed to find flatten iOS headers script." >&2
37 exit 1
38 fi
39 if [[ ! -x ${FRAMEWORK_PROJECT_PATH} ]]; then
40 echo "Failed to find framework XCode project." >&2
41 exit 1
42 fi
43 }
44
45 function clean_artifacts {
46 # Make XCode clean up after itself.
47 xcodebuild -project ${FRAMEWORK_PROJECT_PATH} -scheme WebRTC \
48 -configuration Release clean
49 xcodebuild -project ${FRAMEWORK_PROJECT_PATH} -scheme WebRTC \
50 -configuration Release clean \
51 -destination "platform=iOS Simulator,name=iPhone 6"
52 # Remove remaining directory that XCode doesn't delete.
53 XCODE_BUILD_DIR=${FRAMEWORK_PROJECT_DIR}/build
54 if [[ -d ${XCODE_BUILD_DIR} ]]; then
55 rm -r ${XCODE_BUILD_DIR}
56 fi
57
58 # Remove the temporary framework header dir.
59 if [[ -d ${FRAMEWORK_INCLUDE_DIR} ]]; then
60 rm -r ${FRAMEWORK_INCLUDE_DIR}
61 fi
62
63 # Remove the generated framework.
64 if [[ -d ${FRAMEWORK_OUTPUT_DIR} ]]; then
65 rm -r ${FRAMEWORK_OUTPUT_DIR}
66 fi
67
68 # Let the other script clean up after itself.
69 ${BUILD_WEBRTC_SCRIPT} -c
70 }
71
72 function usage {
73 echo "WebRTC iOS Framework build script."
74 echo "Builds a dynamic Framework for the WebRTC APIs."
75 echo "Compiles various architectures and edits header paths as required."
76 echo "Usage: $0 [-h] [-c]"
77 echo " -h Print this help."
78 echo " -c Removes generated build output."
79 exit 0
80 }
81
82 check_preconditions
83
84 # Set the output directories for the various build artifacts.
85 # For convenience we'll output some generated files in the same directory
86 # as the one we used to output the generated statis libraries.
87 LIB_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_libs
88 INCLUDE_OUTPUT_DIR=${LIB_OUTPUT_DIR}/include
89 FRAMEWORK_INCLUDE_DIR=${LIB_OUTPUT_DIR}/framework_include
90 FRAMEWORK_OUTPUT_DIR=${WEBRTC_BASE_DIR}/out_ios_framework
91 PERFORM_CLEAN=0
92
93 # Parse arguments.
94 while getopts "hc" opt; do
95 case "${opt}" in
96 h) usage;;
97 c) PERFORM_CLEAN=1;;
98 *)
99 usage
100 exit 1
101 ;;
102 esac
103 done
104
105 if [[ ${PERFORM_CLEAN} -ne 0 ]]; then
106 clean_artifacts
107 exit 0
16 fi 108 fi
17 109
18 # Check for iOS library build script. 110 # Build static libraries for iOS.
19 SCRIPT_DIR=$(dirname $0) 111 ${BUILD_WEBRTC_SCRIPT} -o ${LIB_OUTPUT_DIR}
20 WEBRTC_BASE_DIR=${SCRIPT_DIR}/../../..
21 BUILD_WEBRTC_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/ios/build_ios_libs.sh
22 if [[ ! -x ${BUILD_WEBRTC_SCRIPT} ]]; then
23 echo "Failed to find iOS library build script." >&2
24 exit 1
25 fi
26 # Check for flatten iOS headers script.
27 FLATTEN_HEADERS_SCRIPT=${WEBRTC_BASE_DIR}/webrtc/build/ios/flatten_ios_headers
28 if [[ ! -x ${FLATTEN_HEADERS_SCRIPT} ]]; then
29 echo "Failed to find flatten iOS headers script." >&2
30 exit 1
31 fi
32 112
33 pushd ${WEBRTC_BASE_DIR} 113 # Flatten the directory structure for iOS headers generated from building the
34 LIB_BASE_DIR=out_ios_libs 114 # static libraries.
35 FRAMEWORK_BASE_DIR=out_ios_framework 115 ${FLATTEN_HEADERS_SCRIPT} ${INCLUDE_OUTPUT_DIR} ${FRAMEWORK_INCLUDE_DIR}
36
37 # Build static libraries for iOS.
38 ${BUILD_WEBRTC_SCRIPT}
39 if [ $? -ne 0 ]; then
40 echo "Failed to build iOS static libraries." >&2
41 exit 1
42 fi
43
44 # Flatten the directory structure for iOS headers.
45 ${FLATTEN_HEADERS_SCRIPT} ${LIB_BASE_DIR} ${FRAMEWORK_BASE_DIR}
46 if [ $? -ne 0 ]; then
47 echo "Failed to flatten iOS headers." >&2
48 exit 1
49 fi
50 116
51 # Replace full paths for headers with framework paths. 117 # Replace full paths for headers with framework paths.
52 SED_PATTERN=' 118 SED_PATTERN='
53 s/(\#import )\"webrtc\/api\/objc\/(.*)\"/\1<WebRTC\/\2>/g; 119 s/(\#import )\"webrtc\/api\/objc\/(.*)\"/\1<WebRTC\/\2>/g;
54 s/(\#import )\"webrtc\/base\/objc\/(.*)\"/\1<WebRTC\/\2>/g; 120 s/(\#import )\"webrtc\/base\/objc\/(.*)\"/\1<WebRTC\/\2>/g;
55 s/(\#include )\"webrtc\/base\/objc\/(.*)\"/\1<WebRTC\/\2>/g; 121 s/(\#include )\"webrtc\/base\/objc\/(.*)\"/\1<WebRTC\/\2>/g;
56 ' 122 '
57 sed -E -i '' "$SED_PATTERN" ${FRAMEWORK_BASE_DIR}/include/*.h 123 sed -E -i '' "$SED_PATTERN" ${FRAMEWORK_INCLUDE_DIR}/*.h
58 124
59 SDK_DIR=webrtc/build/ios/SDK
60 PROJECT_DIR=${SDK_DIR}/Framework
61 # Build the framework. 125 # Build the framework.
62 pushd ${PROJECT_DIR} 126 xcodebuild -project ${FRAMEWORK_PROJECT_PATH} -scheme WebRTC \
63 xcodebuild -project WebRTC.xcodeproj -scheme WebRTC -configuration Release \ 127 -configuration Release build \
64 build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO 128 CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
65 xcodebuild -project WebRTC.xcodeproj -scheme WebRTC -configuration Release \ 129 xcodebuild -project ${FRAMEWORK_PROJECT_PATH} -scheme WebRTC \
66 build -destination 'platform=iOS Simulator,name=iPhone 6' 130 -configuration Release build \
67 popd 131 -destination "platform=iOS Simulator,name=iPhone 6"
68 132
69 # Copy podspec, framework, dSYM and LICENSE to FRAMEWORK_BASE_DIR 133 # XCode should output the build artifacts to the following directories.
70 DEVICE_BUILD_DIR=${PROJECT_DIR}/build/Release-iphoneos 134 DEVICE_BUILD_DIR=${FRAMEWORK_PROJECT_DIR}/build/Release-iphoneos
71 cp ${SDK_DIR}/WebRTC.podspec ${FRAMEWORK_BASE_DIR}/ 135 SIMULATOR_BUILD_DIR=${FRAMEWORK_PROJECT_DIR}/build/Release-iphonesimulator
72 cp -R ${DEVICE_BUILD_DIR}/WebRTC.framework ${FRAMEWORK_BASE_DIR}/
73 cp -R ${DEVICE_BUILD_DIR}/WebRTC.framework.dSYM ${FRAMEWORK_BASE_DIR}/
74 cp -R webrtc/LICENSE ${FRAMEWORK_BASE_DIR}/
75 136
76 # Combine multiple architectures 137 # Copy podspec, framework, dSYM and LICENSE to FRAMEWORK_OUTPUT_DIR.
77 SIMULATOR_BUILD_DIR=${PROJECT_DIR}/build/Release-iphonesimulator 138 mkdir -p ${FRAMEWORK_OUTPUT_DIR}
139 cp ${SDK_DIR}/WebRTC.podspec ${FRAMEWORK_OUTPUT_DIR}/
140 cp -R ${DEVICE_BUILD_DIR}/WebRTC.framework ${FRAMEWORK_OUTPUT_DIR}/
141 cp -R ${DEVICE_BUILD_DIR}/WebRTC.framework.dSYM ${FRAMEWORK_OUTPUT_DIR}/
142 cp -R ${WEBRTC_BASE_DIR}/webrtc/LICENSE ${FRAMEWORK_OUTPUT_DIR}/
143
144 # Combine multiple architectures.
78 DYLIB_PATH=WebRTC.framework/WebRTC 145 DYLIB_PATH=WebRTC.framework/WebRTC
79 DWARF_PATH=WebRTC.framework.dSYM/Contents/Resources/DWARF/WebRTC 146 DWARF_PATH=WebRTC.framework.dSYM/Contents/Resources/DWARF/WebRTC
80 lipo ${FRAMEWORK_BASE_DIR}/${DYLIB_PATH} ${SIMULATOR_BUILD_DIR}/${DYLIB_PATH} \ 147 lipo ${FRAMEWORK_OUTPUT_DIR}/${DYLIB_PATH} \
81 -create -output ${FRAMEWORK_BASE_DIR}/${DYLIB_PATH} 148 ${SIMULATOR_BUILD_DIR}/${DYLIB_PATH} \
82 lipo ${FRAMEWORK_BASE_DIR}/${DWARF_PATH} ${SIMULATOR_BUILD_DIR}/${DWARF_PATH} \ 149 -create -output ${FRAMEWORK_OUTPUT_DIR}/${DYLIB_PATH}
83 -create -output ${FRAMEWORK_BASE_DIR}/${DWARF_PATH} 150 lipo ${FRAMEWORK_OUTPUT_DIR}/${DWARF_PATH} \
84 151 ${SIMULATOR_BUILD_DIR}/${DWARF_PATH} \
85 popd 152 -create -output ${FRAMEWORK_OUTPUT_DIR}/${DWARF_PATH}
OLDNEW
« no previous file with comments | « webrtc/build/ios/SDK/Framework/WebRTC/WebRTC.h ('k') | webrtc/build/ios/build_ios_libs.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698