From 72e8fa4612b7ad85799e0c9992dcc5ada5316230 Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Sat, 9 Oct 2021 15:14:44 +0100 Subject: [PATCH] allow overriding sdk version while building apple platforms, improves #168 --- .github/workflows/ios-build-scripts.yml | 25 ++++++++++++++++-- .github/workflows/macos-build-scripts.yml | 25 ++++++++++++++++-- .github/workflows/tvos-build-scripts.yml | 25 ++++++++++++++++-- ios.sh | 10 ++++++++ macos.sh | 5 ++++ scripts/function-apple.sh | 26 +++++++++---------- scripts/function-ios.sh | 6 ++++- scripts/function-macos.sh | 2 +- scripts/function-tvos.sh | 2 +- scripts/function.sh | 31 +++++++++++++++++++++++ scripts/main-ios.sh | 4 +-- scripts/main-macos.sh | 4 +-- scripts/main-tvos.sh | 4 +-- tvos.sh | 5 ++++ 14 files changed, 146 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ios-build-scripts.yml b/.github/workflows/ios-build-scripts.yml index 4450515..1613e88 100644 --- a/.github/workflows/ios-build-scripts.yml +++ b/.github/workflows/ios-build-scripts.yml @@ -3,8 +3,29 @@ name: ios build scripts on: [ push, pull_request ] jobs: - build-main-on-macos: - name: ios main + build-main-on-macos-bigsur: + name: ios main on big sur + runs-on: macos-11 + strategy: + matrix: + xcode: [ '12.5.1', '13.0' ] + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + - name: set up xcode + run: echo "export DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer" > ~/.xcode.for.ffmpeg.kit.sh + - name: run the build script + run: ./ios.sh --xcframework --enable-ios-audiotoolbox --enable-ios-avfoundation --enable-ios-bzip2 --enable-ios-libiconv --enable-ios-videotoolbox --enable-ios-zlib + - name: print build logs + if: ${{ always() }} + run: cat build.log + - name: print ffbuild logs + if: ${{ failure() }} + run: '[[ -f ./src/ffmpeg/ffbuild/config.log ]] && tail -50 ./src/ffmpeg/ffbuild/config.log' + build-main-on-macos-catalina: + name: ios main on catalina runs-on: macos-10.15 strategy: matrix: diff --git a/.github/workflows/macos-build-scripts.yml b/.github/workflows/macos-build-scripts.yml index 23d2537..4606f0f 100644 --- a/.github/workflows/macos-build-scripts.yml +++ b/.github/workflows/macos-build-scripts.yml @@ -3,8 +3,29 @@ name: macos build scripts on: [ push, pull_request ] jobs: - build-main-on-macos: - name: macos main + build-main-on-macos-bigsur: + name: macos main on big sur + runs-on: macos-11 + strategy: + matrix: + xcode: [ '12.5.1', '13.0' ] + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + - name: set up xcode + run: echo "export DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer" > ~/.xcode.for.ffmpeg.kit.sh + - name: run the build script + run: ./macos.sh --xcframework --enable-macos-audiotoolbox --enable-macos-avfoundation --enable-macos-bzip2 --enable-macos-coreimage --enable-macos-libiconv --enable-macos-opencl --enable-macos-opengl --enable-macos-videotoolbox --enable-macos-zlib + - name: print build logs + if: ${{ always() }} + run: cat build.log + - name: print ffbuild logs + if: ${{ failure() }} + run: '[[ -f ./src/ffmpeg/ffbuild/config.log ]] && tail -50 ./src/ffmpeg/ffbuild/config.log' + build-main-on-macos-catalina: + name: macos main on catalina runs-on: macos-10.15 strategy: matrix: diff --git a/.github/workflows/tvos-build-scripts.yml b/.github/workflows/tvos-build-scripts.yml index 041d5e8..6767cad 100644 --- a/.github/workflows/tvos-build-scripts.yml +++ b/.github/workflows/tvos-build-scripts.yml @@ -3,8 +3,29 @@ name: tvos build scripts on: [ push, pull_request ] jobs: - build-main-on-macos: - name: tvos main + build-main-on-macos-bigsur: + name: tvos main on big sur + runs-on: macos-11 + strategy: + matrix: + xcode: [ '12.5.1', '13.0' ] + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + - name: set up xcode + run: echo "export DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer" > ~/.xcode.for.ffmpeg.kit.sh + - name: run the build script + run: ./tvos.sh --xcframework --enable-tvos-bzip2 --enable-tvos-audiotoolbox --enable-tvos-libiconv --enable-tvos-videotoolbox --enable-tvos-zlib + - name: print build logs + if: ${{ always() }} + run: cat build.log + - name: print ffbuild logs + if: ${{ failure() }} + run: '[[ -f ./src/ffmpeg/ffbuild/config.log ]] && tail -50 ./src/ffmpeg/ffbuild/config.log' + build-main-on-macos-catalina: + name: tvos main on catalina runs-on: macos-10.15 strategy: matrix: diff --git a/ios.sh b/ios.sh index f6e5cf8..82ba165 100755 --- a/ios.sh +++ b/ios.sh @@ -123,6 +123,16 @@ while [ ! $# -eq 0 ]; do disable_arch "${DISABLED_ARCH}" ;; + --target=*) + TARGET=$(echo $1 | sed -e 's/^--[A-Za-z]*=//g') + + export IOS_MIN_VERSION=${TARGET} + ;; + --mac-catalyst-target=*) + TARGET=$(echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*=//g') + + export MAC_CATALYST_MIN_VERSION=${TARGET} + ;; *) print_unknown_option "$1" ;; diff --git a/macos.sh b/macos.sh index a7ecf01..0ebbaf5 100755 --- a/macos.sh +++ b/macos.sh @@ -123,6 +123,11 @@ while [ ! $# -eq 0 ]; do disable_arch "${DISABLED_ARCH}" ;; + --target=*) + TARGET=$(echo $1 | sed -e 's/^--[A-Za-z]*=//g') + + export MACOS_MIN_VERSION=${TARGET} + ;; *) print_unknown_option "$1" ;; diff --git a/scripts/function-apple.sh b/scripts/function-apple.sh index bc62a11..05bb2ec 100755 --- a/scripts/function-apple.sh +++ b/scripts/function-apple.sh @@ -31,16 +31,16 @@ disable_ios_architecture_not_supported_on_detected_sdk_version() { armv7 | armv7s | i386) # SUPPORTED UNTIL IOS SDK 10.3.1 - if [[ $(echo "$2 > 10.4" | bc) -eq 1 ]]; then - local SUPPORTED=0 - else + if [[ $(compare_versions "$2" "10.3.1") -le 0 ]]; then local SUPPORTED=1 + else + local SUPPORTED=0 fi ;; arm64e) # INTRODUCED IN IOS SDK 10.1 - if [[ $(echo "$2 > 10" | bc) -eq 1 ]]; then + if [[ $(compare_versions "$2" "10.1") -ge 1 ]]; then local SUPPORTED=1 else local SUPPORTED=0 @@ -48,8 +48,8 @@ disable_ios_architecture_not_supported_on_detected_sdk_version() { ;; x86-64-mac-catalyst) - # INTRODUCED IN IOS SDK 13 - if [[ $(echo "$2 > 12.4" | bc) -eq 1 ]]; then + # INTRODUCED IN IOS SDK 13.0 + if [[ $(compare_versions "$2" "13") -ge 1 ]]; then local SUPPORTED=1 else local SUPPORTED=0 @@ -57,8 +57,8 @@ disable_ios_architecture_not_supported_on_detected_sdk_version() { ;; arm64-*) - # INTRODUCED IN IOS SDK 14 - if [[ $(echo "$2 > 13.7" | bc) -eq 1 ]]; then + # INTRODUCED IN IOS SDK 14.0 + if [[ $(compare_versions "$2" "14") -ge 1 ]]; then local SUPPORTED=1 else local SUPPORTED=0 @@ -87,8 +87,8 @@ disable_tvos_architecture_not_supported_on_detected_sdk_version() { case ${ARCH_NAME} in arm64-simulator) - # INTRODUCED IN TVOS SDK 14 - if [[ $(echo "$2 > 13.4" | bc) -eq 1 ]]; then + # INTRODUCED IN TVOS SDK 14.0 + if [[ $(compare_versions "$2" "14") -ge 1 ]]; then local SUPPORTED=1 else local SUPPORTED=0 @@ -117,8 +117,8 @@ disable_macos_architecture_not_supported_on_detected_sdk_version() { case ${ARCH_NAME} in arm64) - # INTRODUCED IN MACOS SDK 11 - if [[ $(echo "$2 > 10.16" | bc) -eq 1 ]]; then + # INTRODUCED IN MACOS SDK 11.0 + if [[ $(compare_versions "$2" "11") -ge 1 ]]; then local SUPPORTED=1 else local SUPPORTED=0 @@ -1235,7 +1235,7 @@ get_min_version_cflags() { get_min_sdk_version() { case ${ARCH} in *-mac-catalyst) - echo "13.0" + echo "${MAC_CATALYST_MIN_VERSION}" ;; *) case ${FFMPEG_KIT_BUILD_TYPE} in diff --git a/scripts/function-ios.sh b/scripts/function-ios.sh index 7379070..d7b8d35 100755 --- a/scripts/function-ios.sh +++ b/scripts/function-ios.sh @@ -25,7 +25,7 @@ libraries are created under the prebuilt folder.\n" echo -e "Usage: ./$COMMAND [OPTION]...\n" echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" - display_help_options " -x, --xcframework\t\tbuild xcframework bundles instead of framework bundles and universal libraries" " -l, --lts build lts packages to support sdk 9.3+ devices" + display_help_options " -x, --xcframework\t\tbuild xcframework bundles instead of framework bundles and universal libraries" " -l, --lts build lts packages to support sdk 9.3+ devices" " --target=ios sdk version\t\t\toverride minimum deployment target" " --mac-catalyst-target=ios sdk version\toverride minimum deployment target for mac catalyst" display_help_licensing echo -e "Architectures:" @@ -60,6 +60,7 @@ libraries are created under the prebuilt folder.\n" enable_main_build() { export IOS_MIN_VERSION=12.1 + export MAC_CATALYST_MIN_VERSION=14.0 } enable_lts_build() { @@ -68,6 +69,9 @@ enable_lts_build() { # XCODE 7.3 HAS IOS SDK 9.3 export IOS_MIN_VERSION=9.3 + # MAC CATALYST IS INTRODUCED IN 13.0 + export MAC_CATALYST_MIN_VERSION=13.0 + # IOS SDK 9.3 SUPPORTS VIDEOTOOLBOX # HOWEVER, THE LATEST FFMPEG VERSION USES SDK 11.0 APIS # THEREFORE, VIDEOTOOLBOX IS DISABLED IN LTS RELEASES diff --git a/scripts/function-macos.sh b/scripts/function-macos.sh index 1c2b30b..5a226f6 100755 --- a/scripts/function-macos.sh +++ b/scripts/function-macos.sh @@ -17,7 +17,7 @@ When compilation ends, libraries are created under the prebuilt folder.\n" echo -e "Usage: ./$COMMAND [OPTION]...\n" echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" - display_help_options " -x, --xcframework\t\tbuild xcframework bundles instead of framework bundles and universal libraries" " -l, --lts build lts packages to support sdk 10.11+ devices" + display_help_options " -x, --xcframework\t\tbuild xcframework bundles instead of framework bundles and universal libraries" " -l, --lts build lts packages to support sdk 10.11+ devices" " --target=macos sdk version\toverride minimum deployment target" display_help_licensing echo -e "Architectures:" diff --git a/scripts/function-tvos.sh b/scripts/function-tvos.sh index fc2fb68..57ea64f 100755 --- a/scripts/function-tvos.sh +++ b/scripts/function-tvos.sh @@ -18,7 +18,7 @@ set explicitly. When compilation ends, libraries are created under the prebuilt echo -e "Usage: ./$COMMAND [OPTION]...\n" echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" - display_help_options " -x, --xcframework\t\tbuild xcframework bundles instead of framework bundles and universal libraries" " -l, --lts build lts packages to support sdk 9.2+ devices" + display_help_options " -x, --xcframework\t\tbuild xcframework bundles instead of framework bundles and universal libraries" " -l, --lts build lts packages to support sdk 9.2+ devices" " --target=tvos sdk version\toverride minimum deployment target" display_help_licensing echo -e "Architectures:" diff --git a/scripts/function.sh b/scripts/function.sh index db3a155..85b23c4 100755 --- a/scripts/function.sh +++ b/scripts/function.sh @@ -587,6 +587,9 @@ display_help_options() { if [ -n "$3" ]; then echo -e "$3" fi + if [ -n "$4" ]; then + echo -e "$4" + fi echo -e "" } @@ -1814,3 +1817,31 @@ create_file() { rm -f "$1" echo "" > "$1" 1>>"${BASEDIR}"/build.log 2>&1 } + +compare_versions() { + VERSION_PARTS_1=($(echo $1 | tr "." " ")) + VERSION_PARTS_2=($(echo $2 | tr "." " ")) + + for((i=0;(i<${#VERSION_PARTS_1[@]})&&(i<${#VERSION_PARTS_2[@]});i++)) + do + + if [[ ${VERSION_PARTS_1[$i]} -gt ${VERSION_PARTS_2[$i]} ]]; then + echo "1" + return; + elif [[ ${VERSION_PARTS_1[$i]} -lt ${VERSION_PARTS_2[$i]} ]]; then + echo "-1" + return; + fi + done + + if [[ ${#VERSION_PARTS_1[@]} -gt ${#VERSION_PARTS_2[@]} ]]; then + echo "1" + return; + elif [[ ${#VERSION_PARTS_1[@]} -lt ${#VERSION_PARTS_2[@]} ]]; then + echo "-1" + return; + else + echo "0" + return; + fi +} diff --git a/scripts/main-ios.sh b/scripts/main-ios.sh index f978ad0..1eb1ca6 100755 --- a/scripts/main-ios.sh +++ b/scripts/main-ios.sh @@ -23,8 +23,8 @@ fi # ENABLE COMMON FUNCTIONS source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1 -echo -e "\nBuilding ${ARCH} platform\n" -echo -e "\nINFO: Starting new build for ${ARCH} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1 +echo -e "\nBuilding ${ARCH} platform targeting iOS SDK ${IOS_MIN_VERSION} and Mac Catalyst ${MAC_CATALYST_MIN_VERSION}\n" +echo -e "\nINFO: Starting new build for ${ARCH} targeting iOS SDK ${IOS_MIN_VERSION} and Mac Catalyst ${MAC_CATALYST_MIN_VERSION} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1 # SET BASE INSTALLATION DIRECTORY FOR THIS ARCHITECTURE export LIB_INSTALL_BASE="${BASEDIR}/prebuilt/$(get_build_directory)" diff --git a/scripts/main-macos.sh b/scripts/main-macos.sh index ba8bf03..ac25bb7 100755 --- a/scripts/main-macos.sh +++ b/scripts/main-macos.sh @@ -23,8 +23,8 @@ fi # ENABLE COMMON FUNCTIONS source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1 -echo -e "\nBuilding ${ARCH} platform\n" -echo -e "\nINFO: Starting new build for ${ARCH} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1 +echo -e "\nBuilding ${ARCH} platform targeting macOS SDK ${MACOS_MIN_VERSION}\n" +echo -e "\nINFO: Starting new build for ${ARCH} targeting macOS SDK ${MACOS_MIN_VERSION} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1 # SET BASE INSTALLATION DIRECTORY FOR THIS ARCHITECTURE export LIB_INSTALL_BASE="${BASEDIR}/prebuilt/$(get_build_directory)" diff --git a/scripts/main-tvos.sh b/scripts/main-tvos.sh index c76c4fd..da6b876 100755 --- a/scripts/main-tvos.sh +++ b/scripts/main-tvos.sh @@ -23,8 +23,8 @@ fi # ENABLE COMMON FUNCTIONS source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1 -echo -e "\nBuilding ${ARCH} platform\n" -echo -e "\nINFO: Starting new build for ${ARCH} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1 +echo -e "\nBuilding ${ARCH} platform targeting tvOS SDK ${TVOS_MIN_VERSION}\n" +echo -e "\nINFO: Starting new build for ${ARCH} targeting tvOS SDK ${TVOS_MIN_VERSION} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1 # SET BASE INSTALLATION DIRECTORY FOR THIS ARCHITECTURE export LIB_INSTALL_BASE="${BASEDIR}/prebuilt/$(get_build_directory)" diff --git a/tvos.sh b/tvos.sh index b64ae30..51e9a91 100755 --- a/tvos.sh +++ b/tvos.sh @@ -123,6 +123,11 @@ while [ ! $# -eq 0 ]; do disable_arch "${DISABLED_ARCH}" ;; + --target=*) + TARGET=$(echo $1 | sed -e 's/^--[A-Za-z]*=//g') + + export TVOS_MIN_VERSION=${TARGET} + ;; *) print_unknown_option "$1" ;;