| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 ## | 2 ## |
| 3 ## Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 3 ## Copyright (c) 2014 The WebM 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 ## | 11 ## |
| 12 ## This script generates 'VPX.framework'. An iOS app can encode and decode VPx | 12 ## This script generates 'VPX.framework'. An iOS app can encode and decode VPx |
| 13 ## video by including 'VPX.framework'. | 13 ## video by including 'VPX.framework'. |
| 14 ## | 14 ## |
| 15 ## Run iosbuild.sh to create 'VPX.framework' in the current directory. | 15 ## Run iosbuild.sh to create 'VPX.framework' in the current directory. |
| 16 ## | 16 ## |
| 17 set -e | 17 set -e |
| 18 devnull='> /dev/null 2>&1' | 18 devnull='> /dev/null 2>&1' |
| 19 | 19 |
| 20 BUILD_ROOT="_iosbuild" | 20 BUILD_ROOT="_iosbuild" |
| 21 DIST_DIR="_dist" | 21 DIST_DIR="_dist" |
| 22 FRAMEWORK_DIR="VPX.framework" | 22 FRAMEWORK_DIR="VPX.framework" |
| 23 HEADER_DIR="${FRAMEWORK_DIR}/Headers/vpx" | 23 HEADER_DIR="${FRAMEWORK_DIR}/Headers/vpx" |
| 24 MAKE_JOBS=1 | 24 MAKE_JOBS=1 |
| 25 LIBVPX_SOURCE_DIR=$(dirname "$0" | sed -e s,/build/make,,) | 25 SCRIPT_DIR=$(dirname "$0") |
| 26 LIBVPX_SOURCE_DIR=$(cd ${SCRIPT_DIR}/../..; pwd) |
| 26 LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo) | 27 LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo) |
| 27 ORIG_PWD="$(pwd)" | 28 ORIG_PWD="$(pwd)" |
| 28 TARGETS="arm64-darwin-gcc | 29 TARGETS="arm64-darwin-gcc |
| 29 armv7-darwin-gcc | 30 armv7-darwin-gcc |
| 30 armv7s-darwin-gcc | 31 armv7s-darwin-gcc |
| 31 x86-iphonesimulator-gcc | 32 x86-iphonesimulator-gcc |
| 32 x86_64-iphonesimulator-gcc" | 33 x86_64-iphonesimulator-gcc" |
| 33 | 34 |
| 34 # Configures for the target specified by $1, and invokes make with the dist | 35 # Configures for the target specified by $1, and invokes make with the dist |
| 35 # target using $DIST_DIR as the distribution output directory. | 36 # target using $DIST_DIR as the distribution output directory. |
| 36 build_target() { | 37 build_target() { |
| 37 local target="$1" | 38 local target="$1" |
| 38 local old_pwd="$(pwd)" | 39 local old_pwd="$(pwd)" |
| 39 | 40 |
| 40 vlog "***Building target: ${target}***" | 41 vlog "***Building target: ${target}***" |
| 41 | 42 |
| 42 mkdir "${target}" | 43 mkdir "${target}" |
| 43 cd "${target}" | 44 cd "${target}" |
| 44 eval "../../${LIBVPX_SOURCE_DIR}/configure" --target="${target}" \ | 45 eval "${LIBVPX_SOURCE_DIR}/configure" --target="${target}" \ |
| 45 --disable-docs ${EXTRA_CONFIGURE_ARGS} ${devnull} | 46 --disable-docs ${EXTRA_CONFIGURE_ARGS} ${devnull} |
| 46 export DIST_DIR | 47 export DIST_DIR |
| 47 eval make -j ${MAKE_JOBS} dist ${devnull} | 48 eval make -j ${MAKE_JOBS} dist ${devnull} |
| 48 cd "${old_pwd}" | 49 cd "${old_pwd}" |
| 49 | 50 |
| 50 vlog "***Done building target: ${target}***" | 51 vlog "***Done building target: ${target}***" |
| 51 } | 52 } |
| 52 | 53 |
| 53 # Returns the preprocessor symbol for the target specified by $1. | 54 # Returns the preprocessor symbol for the target specified by $1. |
| 54 target_to_preproc_symbol() { | 55 target_to_preproc_symbol() { |
| 55 target="$1" | 56 target="$1" |
| 56 case "${target}" in | 57 case "${target}" in |
| 57 arm64-*) | 58 arm64-*) |
| 58 echo "__aarch64__" | 59 echo "__aarch64__" |
| 59 ;; | 60 ;; |
| 60 armv6-*) | |
| 61 echo "__ARM_ARCH_6__" | |
| 62 ;; | |
| 63 armv7-*) | 61 armv7-*) |
| 64 echo "__ARM_ARCH_7A__" | 62 echo "__ARM_ARCH_7A__" |
| 65 ;; | 63 ;; |
| 66 armv7s-*) | 64 armv7s-*) |
| 67 echo "__ARM_ARCH_7S__" | 65 echo "__ARM_ARCH_7S__" |
| 68 ;; | 66 ;; |
| 69 x86-*) | 67 x86-*) |
| 70 echo "__i386__" | 68 echo "__i386__" |
| 71 ;; | 69 ;; |
| 72 x86_64-*) | 70 x86_64-*) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 vlog " $(echo ${lib} | awk -F / '{print $2, $NF}')" | 166 vlog " $(echo ${lib} | awk -F / '{print $2, $NF}')" |
| 169 done | 167 done |
| 170 | 168 |
| 171 # TODO(tomfinegan): Verify that expected targets are included within | 169 # TODO(tomfinegan): Verify that expected targets are included within |
| 172 # VPX.framework/VPX via lipo -info. | 170 # VPX.framework/VPX via lipo -info. |
| 173 } | 171 } |
| 174 | 172 |
| 175 # Trap function. Cleans up the subtree used to build all targets contained in | 173 # Trap function. Cleans up the subtree used to build all targets contained in |
| 176 # $TARGETS. | 174 # $TARGETS. |
| 177 cleanup() { | 175 cleanup() { |
| 176 local readonly res=$? |
| 178 cd "${ORIG_PWD}" | 177 cd "${ORIG_PWD}" |
| 179 | 178 |
| 179 if [ $res -ne 0 ]; then |
| 180 elog "build exited with error ($res)" |
| 181 fi |
| 182 |
| 180 if [ "${PRESERVE_BUILD_OUTPUT}" != "yes" ]; then | 183 if [ "${PRESERVE_BUILD_OUTPUT}" != "yes" ]; then |
| 181 rm -rf "${BUILD_ROOT}" | 184 rm -rf "${BUILD_ROOT}" |
| 182 fi | 185 fi |
| 183 } | 186 } |
| 184 | 187 |
| 185 iosbuild_usage() { | 188 iosbuild_usage() { |
| 186 cat << EOF | 189 cat << EOF |
| 187 Usage: ${0##*/} [arguments] | 190 Usage: ${0##*/} [arguments] |
| 188 --help: Display this message and exit. | 191 --help: Display this message and exit. |
| 192 --extra-configure-args <args>: Extra args to pass when configuring libvpx. |
| 189 --jobs: Number of make jobs. | 193 --jobs: Number of make jobs. |
| 190 --preserve-build-output: Do not delete the build directory. | 194 --preserve-build-output: Do not delete the build directory. |
| 191 --show-build-output: Show output from each library build. | 195 --show-build-output: Show output from each library build. |
| 196 --targets <targets>: Override default target list. Defaults: |
| 197 ${TARGETS} |
| 192 --verbose: Output information about the environment and each stage of the | 198 --verbose: Output information about the environment and each stage of the |
| 193 build. | 199 build. |
| 194 EOF | 200 EOF |
| 195 } | 201 } |
| 196 | 202 |
| 203 elog() { |
| 204 echo "${0##*/} failed because: $@" 1>&2 |
| 205 } |
| 206 |
| 197 vlog() { | 207 vlog() { |
| 198 if [ "${VERBOSE}" = "yes" ]; then | 208 if [ "${VERBOSE}" = "yes" ]; then |
| 199 echo "$@" | 209 echo "$@" |
| 200 fi | 210 fi |
| 201 } | 211 } |
| 202 | 212 |
| 203 trap cleanup EXIT | 213 trap cleanup EXIT |
| 204 | 214 |
| 205 # Parse the command line. | 215 # Parse the command line. |
| 206 while [ -n "$1" ]; do | 216 while [ -n "$1" ]; do |
| 207 case "$1" in | 217 case "$1" in |
| 208 --extra-configure-args) | 218 --extra-configure-args) |
| 209 EXTRA_CONFIGURE_ARGS="$2" | 219 EXTRA_CONFIGURE_ARGS="$2" |
| 210 shift | 220 shift |
| 211 ;; | 221 ;; |
| 212 --help) | 222 --help) |
| 213 iosbuild_usage | 223 iosbuild_usage |
| 214 exit | 224 exit |
| 215 ;; | 225 ;; |
| 216 --jobs) | 226 --jobs) |
| 217 MAKE_JOBS="$2" | 227 MAKE_JOBS="$2" |
| 218 shift | 228 shift |
| 219 ;; | 229 ;; |
| 220 --preserve-build-output) | 230 --preserve-build-output) |
| 221 PRESERVE_BUILD_OUTPUT=yes | 231 PRESERVE_BUILD_OUTPUT=yes |
| 222 ;; | 232 ;; |
| 223 --show-build-output) | 233 --show-build-output) |
| 224 devnull= | 234 devnull= |
| 225 ;; | 235 ;; |
| 236 --targets) |
| 237 TARGETS="$2" |
| 238 shift |
| 239 ;; |
| 226 --verbose) | 240 --verbose) |
| 227 VERBOSE=yes | 241 VERBOSE=yes |
| 228 ;; | 242 ;; |
| 229 *) | 243 *) |
| 230 iosbuild_usage | 244 iosbuild_usage |
| 231 exit 1 | 245 exit 1 |
| 232 ;; | 246 ;; |
| 233 esac | 247 esac |
| 234 shift | 248 shift |
| 235 done | 249 done |
| 236 | 250 |
| 237 if [ "${VERBOSE}" = "yes" ]; then | 251 if [ "${VERBOSE}" = "yes" ]; then |
| 238 cat << EOF | 252 cat << EOF |
| 239 BUILD_ROOT=${BUILD_ROOT} | 253 BUILD_ROOT=${BUILD_ROOT} |
| 240 DIST_DIR=${DIST_DIR} | 254 DIST_DIR=${DIST_DIR} |
| 241 EXTRA_CONFIGURE_ARGS=${EXTRA_CONFIGURE_ARGS} | 255 EXTRA_CONFIGURE_ARGS=${EXTRA_CONFIGURE_ARGS} |
| 242 FRAMEWORK_DIR=${FRAMEWORK_DIR} | 256 FRAMEWORK_DIR=${FRAMEWORK_DIR} |
| 243 HEADER_DIR=${HEADER_DIR} | 257 HEADER_DIR=${HEADER_DIR} |
| 244 MAKE_JOBS=${MAKE_JOBS} | 258 MAKE_JOBS=${MAKE_JOBS} |
| 245 PRESERVE_BUILD_OUTPUT=${PRESERVE_BUILD_OUTPUT} | 259 PRESERVE_BUILD_OUTPUT=${PRESERVE_BUILD_OUTPUT} |
| 246 LIBVPX_SOURCE_DIR=${LIBVPX_SOURCE_DIR} | 260 LIBVPX_SOURCE_DIR=${LIBVPX_SOURCE_DIR} |
| 247 LIPO=${LIPO} | 261 LIPO=${LIPO} |
| 248 ORIG_PWD=${ORIG_PWD} | 262 ORIG_PWD=${ORIG_PWD} |
| 249 TARGETS="${TARGETS}" | 263 TARGETS="${TARGETS}" |
| 250 EOF | 264 EOF |
| 251 fi | 265 fi |
| 252 | 266 |
| 253 build_framework "${TARGETS}" | 267 build_framework "${TARGETS}" |
| 268 echo "Successfully built '${FRAMEWORK_DIR}' for:" |
| 269 echo " ${TARGETS}" |
| OLD | NEW |