aboutsummaryrefslogtreecommitdiffstats
path: root/coin/provisioning/common/unix/install-ffmpeg-ios.sh
blob: d3d59849b77f973fddc78a357f9f262f2c424740 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

# This script will build and install FFmpeg static libs
set -ex

# shellcheck source=../unix/InstallFromCompressedFileFromURL.sh
source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh"
# shellcheck source=../unix/SetEnvVar.sh
source "${BASH_SOURCE%/*}/../unix/SetEnvVar.sh"

version="n6.1.1"
sha1="59e0c3c4cc48e9c60073495f8c045329bb21f446"
url_public="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$version.tar.gz"
url_cached="http://ci-files01-hki.ci.qt.io/input/ffmpeg/$version.tar.gz"
ffmpeg_name="FFmpeg-$version"

target_dir="$HOME"
ffmpeg_source_dir="$target_dir/$ffmpeg_name"
prefix="/usr/local/ios/ffmpeg"

if [ ! -d "$ffmpeg_source_dir" ];
then
   InstallFromCompressedFileFromURL "$url_cached" "$url_public" "$sha1" "$target_dir" "$app_prefix"
fi

ffmpeg_config_options=$(cat "${BASH_SOURCE%/*}/../shared/ffmpeg_config_options.txt")

build_ffmpeg_ios() {
  local target_arch=$1

  if [ "$target_arch" == "x86_64" ]; then
     target_sdk="iphonesimulator"
     target_arch="x86_64"
     minos="-mios-simulator-version-min=13.0"
  else
     target_sdk="iphoneos"
     target_arch="arm64"
     minos="-miphoneos-version-min=13.0"
  fi

  local build_dir="$ffmpeg_source_dir/build_ios/$target_arch"
  sudo mkdir -p "$build_dir"
  pushd "$build_dir"

  sudo $ffmpeg_source_dir/configure $ffmpeg_config_options \
    --sysroot="$(xcrun --sdk "$target_sdk" --show-sdk-path)" \
  --enable-cross-compile \
  --enable-optimizations \
  --prefix=$prefix \
  --arch=$target_arch \
  --cc="xcrun --sdk ${target_sdk} clang -arch $target_arch" \
  --cxx="xcrun --sdk ${target_sdk} clang++ -arch $target_arch" \
  --ar="$(xcrun --sdk ${target_sdk} --find ar)" \
  --ranlib="$(xcrun --sdk ${target_sdk} --find ranlib)" \
  --strip="$(xcrun --sdk ${target_sdk} --find strip)" \
  --nm="$(xcrun --sdk ${target_sdk} --find nm)" \
  --target-os=darwin \
  --extra-cflags="$minos" \
  --extra-cxxflags="$minos" \
  --enable-cross-compile \
  --enable-swscale \
  --enable-pthreads \
  --disable-audiotoolbox

  sudo make install DESTDIR="$build_dir/installed" -j
  popd
}

build_ffmpeg_ios "x86_64"
build_ffmpeg_ios "arm64"
sudo "${BASH_SOURCE%/*}/../macos/makeuniversal.sh" "$ffmpeg_source_dir/build_ios/x86_64/installed" "$ffmpeg_source_dir/build_ios/arm64/installed"
SetEnvVar "FFMPEG_DIR_IOS" $prefix