Skip to content

Commit

Permalink
tvos
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jan 1, 2024
1 parent a4174a4 commit 9dc17ad
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 15 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ jobs:
fail-fast: false
matrix:
config: [default,lite,lite-lto] # lto reduce about 300KB for lite build
target: [macOS,iOS,iOSSimulator,macCatalyst]
target: [macOS,iOS,iOSSimulator,macCatalyst,tvOS,tvOSSimulator]
exclude:
- config: default
target: iOSSimulator
- config: default
target: macCatalyst
- config: default
target: iOS
- config: default
target: tvOS
- config: default
target: tvOSSimulator
steps:
- uses: actions/checkout@v4
- name: Create Build Environment
Expand All @@ -50,11 +54,8 @@ jobs:
shell: bash
run: |
export FFSRC=$PWD/ffmpeg-${FF_VERSION}
[ "${TARGET_OS}" = iOS ] && export USER_OPT="--enable-wolfssl"
[[ "${TARGET_OS}" == "iOS" || "${TARGET_OS}" == "tvOS"* ]] && export USER_OPT="--enable-wolfssl"
./avbuild.sh ${TARGET_OS}
if [[ "${TARGET_OS}" == "iOS"* ]]; then
find sdk-* -name "*.dylib" -delete
fi
- name: Make SDK
shell: bash
run: ./tools/ci-after-build.sh
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ How: https://github.com/wang-bin/avbuild/wiki

### Download prebuilt packages

[![Totoal Downloads](https://img.shields.io/sourceforge/dt/avbuild)](https://sourceforge.net/projects/avbuild/files)


Lite build of FFmpeg master branch **(recommended)**:
Expand Down
63 changes: 55 additions & 8 deletions avbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo "https://github.com/wang-bin/avbuild"

THIS_NAME=${0##*/}
THIS_DIR=$PWD
PLATFORMS="ios|iossimulator|android|rpi|sunxi|vc|win|winrt|uwp|winphone|mingw"
PLATFORMS="ios|iossimulator|tvos|tvossimulator|android|rpi|sunxi|vc|win|winrt|uwp|winphone|mingw"
echo "Usage:"
test -d $PWD/FFmpeg || echo " export FFSRC=/path/to/ffmpeg"
cat<<HELP
Expand Down Expand Up @@ -1040,7 +1040,7 @@ setup_ios_env() {
disable_opt vulkan
EXTRA_CFLAGS+=" -I=/usr/include/libxml2"
grep -q install-name-dir $FFSRC/configure && TOOLCHAIN_OPT+=" --install_name_dir=@rpath"
LIB_OPT= #static only
LIB_OPT=--enable-shared
# clang -arch i386 -arch x86_64
## cc="xcrun -sdk iphoneos clang" or cc=`xcrun -sdk iphoneos --find clang`
local IOS_ARCH=$1
Expand All @@ -1062,7 +1062,8 @@ setup_ios_env() {
local VER_OS=iphoneos
local BITCODE_FLAGS=
local ios5_lib_dir=
if [[ "$IOS_ARCH" == "arm"* && "$OS" != *"simulator"* ]]; then
local Simulator=
if [[ "$OS" != *"simulator"* ]]; then
$enable_bitcode && BITCODE_FLAGS="-fembed-bitcode" # also works for new sdks
BITCODE_LFLAGS=$BITCODE_FLAGS
if [ "${IOS_ARCH:3:2}" == "64" ]; then
Expand All @@ -1082,6 +1083,7 @@ setup_ios_env() {
else
SYSROOT_SDK=iphonesimulator
VER_OS=ios-simulator
Simulator=Simulator
if [ "${IOS_ARCH}" == "x86_64" ]; then
ios_min=7.0
elif [ "${IOS_ARCH}" == "x86" ]; then
Expand All @@ -1103,16 +1105,58 @@ setup_ios_env() {
else
apple_sdk_version ">=" ios 10.0 && patch_clock_gettime=$(($FFMAJOR == 3 && $FFMINOR < 3 || $FFMAJOR < 3)) # my patch is in >3.2
fi
INSTALL_DIR=sdk-ios-$IOS_ARCH
INSTALL_DIR=sdk-ios$Simulator-$IOS_ARCH
mkdir -p $THIS_DIR/build_$INSTALL_DIR
[ -n "$ios5_lib_dir" ] && echo "export LIBRARY_PATH=$ios5_lib_dir" >$THIS_DIR/build_$INSTALL_DIR/.env.sh
cat>>$THIS_DIR/build_$INSTALL_DIR/.env.sh<<EOF
export PKG_CONFIG_PATH=${THIS_DIR}/tools/dep/iOS/lib/pkgconfig:${THIS_DIR}/tools/dep_gpl/iOS/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=${THIS_DIR}/tools/dep/iOS$Simulator/lib/pkgconfig:${THIS_DIR}/tools/dep_gpl/iOS$Simulator/lib/pkgconfig:$PKG_CONFIG_PATH
EOF
LIBWOLFSSL="${THIS_DIR}/tools/dep/iOS/lib/libwolfssl.a"
LIBWOLFSSL="${THIS_DIR}/tools/dep/iOS$Simulator/lib/libwolfssl.a"
cp -avf "$LIBWOLFSSL" $THIS_DIR/build_$INSTALL_DIR/libwolfssl.a
[ -f "$LIBWOLFSSL" ] && lipo -thin $IOS_ARCH "$LIBWOLFSSL" -output $THIS_DIR/build_$INSTALL_DIR/libwolfssl.a
}

setup_tvos_env() {
DEC_OPT=$DEC_OPT_MOBILE
DEMUX_OPT=$DEMUX_OPT_MOBILE
ENC_OPT=
MUX_OPT=
enable_opt videotoolbox libxml2
disable_opt avdevice
disable_opt vulkan
EXTRA_CFLAGS+=" -I=/usr/include/libxml2"
grep -q install-name-dir $FFSRC/configure && TOOLCHAIN_OPT+=" --install_name_dir=@rpath"
LIB_OPT=--enable-shared
local OS_ARCH=$1
local OS=$2
os_ver=${2##tvos}
os_ver=${os_ver/simulator/}
local os_min=11.0
local SYSROOT_SDK=appletvos
local VER_OS=tvos
local enable_bitcode=false
if [[ "$OS" != *"simulator"* ]]; then
$enable_bitcode && BITCODE_FLAGS="-fembed-bitcode" # also works for new sdks
else
SYSROOT_SDK=appletvsimulator
VER_OS=tvos-simulator
Simulator=Simulator
fi
: ${os_ver:=$os_min}
TOOLCHAIN_OPT+=" --enable-cross-compile --arch=$OS_ARCH --target-os=darwin --cc=clang --sysroot=\$(xcrun --sdk $SYSROOT_SDK --show-sdk-path)"
disable_opt programs
EXTRA_CFLAGS+=" -arch $OS_ARCH -m${VER_OS}-version-min=$os_ver $BITCODE_FLAGS" # -fvisibility=hidden -fvisibility-inlines-hidden"
EXTRA_LDFLAGS+=" -arch $OS_ARCH -m${VER_OS}-version-min=$os_ver $BITCODE_LFLAGS -Wl,-dead_strip" # -fvisibility=hidden -fvisibility-inlines-hidden"
INSTALL_DIR=sdk-tvos$Simulator-$OS_ARCH
mkdir -p $THIS_DIR/build_$INSTALL_DIR
cat>>$THIS_DIR/build_$INSTALL_DIR/.env.sh<<EOF
export PKG_CONFIG_PATH=${THIS_DIR}/tools/dep/tvOS$Simulator/lib/pkgconfig:${THIS_DIR}/tools/dep_gpl/tvOS$Simulator/lib/pkgconfig:$PKG_CONFIG_PATH
EOF
LIBWOLFSSL="${THIS_DIR}/tools/dep/tvOS$Simulator/lib/libwolfssl.a"
cp -avf "$LIBWOLFSSL" $THIS_DIR/build_$INSTALL_DIR/libwolfssl.a
[ -f "$LIBWOLFSSL" ] && lipo -thin $OS_ARCH "$LIBWOLFSSL" -output $THIS_DIR/build_$INSTALL_DIR/libwolfssl.a
}

setup_macos_env(){
local MACOS_VER=10.7
local MACOS_ARCH=
Expand Down Expand Up @@ -1180,6 +1224,7 @@ EOF
setup_maccatalyst_env(){
enable_opt videotoolbox libxml2
disable_opt avdevice appkit securetransport
disable_opt vulkan
EXTRA_CFLAGS+=" -I=/usr/include/libxml2"
grep -q install-name-dir $FFSRC/configure && TOOLCHAIN_OPT+=" --install_name_dir=@rpath"
local IOS_ARCH=$1
Expand Down Expand Up @@ -1225,6 +1270,7 @@ apple_sdk_version(){
#$2: os name used by xcrun (ios, macos, iphoneos, macosx ...)
#$3: version number (x.y)
local ios=iphoneos
local tvos=appletvos
local macos=macosx
local os=${!2}
os=${os:=$2}
Expand Down Expand Up @@ -1454,6 +1500,7 @@ config1(){
ios*) setup_ios_env $TAGET_ARCH_FLAG $1 ;;
osx*|macos*) setup_macos_env $TAGET_ARCH_FLAG $1 ;;
*catalyst*) setup_maccatalyst_env $TAGET_ARCH_FLAG $1 ;;
tvos*) setup_tvos_env $TAGET_ARCH_FLAG $1 ;;
mingw*) setup_mingw_env $TAGET_ARCH_FLAG ;;
vc|win*|uwp*) setup_win $TAGET_ARCH_FLAG $1 ;; # TODO: check cc
rpi*|raspberry*) setup_rpi_env $TAGET_ARCH_FLAG $1 ;;
Expand Down Expand Up @@ -1645,7 +1692,7 @@ build_all(){
local archs=($2)
[ -z "$archs" ] && {
echo ">>>>>no arch is set. setting default archs..."
[ "${os:0:3}" == "ios" ] && {
[[ "$os" == ios* || "$os" == tvos* ]] && {
echo $os | grep simulator >/dev/null && archs=(arm64 x86_64) || archs=(arm64)
}
[ "${os:0:7}" == "android" ] && archs=(armv7 arm64 x86 x86_64)
Expand Down Expand Up @@ -1728,7 +1775,7 @@ make_universal()
[ -z "$dirs" ] && return 0
[ ${#dirs[@]} -le 1 ] && return 0
# TODO: move to a new script
if [[ "$os" == ios* || "$os" == macos* || "$os" == osx* || "$os" == *catalyst* ]]; then
if [[ "$os" == ios* || "$os" == macos* || "$os" == osx* || "$os" == *catalyst* || "$os" == tvos* ]]; then
local OUT_DIR=sdk-$os
rm -rf $OUT_DIR
cd $THIS_DIR
Expand Down
7 changes: 6 additions & 1 deletion tools/ci-after-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ export XZ_OPT="-T0 -9e" # -9e. -8/9 will disable mt?
TAR=tar
# brew install gnu-tar. gtar result is 1/3 much smaller, but 1/2 slower, also no hidden files(GNUSparseFile.0). T0 is 2x faster than bsdtar
which gtar && TAR=gtar
if [[ "${TARGET_OS}" == "iOS"* || "${TARGET_OS}" == "tvOS"* ]]; then
find ffmpeg-${SUFFIX} -name "*.mri" -delete
$TAR Jcf ffmpeg-${SUFFIX}-shared.tar.xz --exclude="*.a" ffmpeg-${SUFFIX}
find ffmpeg-${SUFFIX} -name "*.dylib" -delete
fi
$TAR Jcf ffmpeg-${SUFFIX}{.tar.xz,}
ls -lh *.xz
[ "$GITHUB_EVENT_NAME" == "pull_request" ] && exit 0

echo "SF_USER_MAPPED: $SF_USER_MAPPED"
sshpass -p $SF_PW_MAPPED scp -o StrictHostKeyChecking=no ffmpeg-${SUFFIX}.tar.xz $SF_USER_MAPPED,avbuild@frs.sourceforge.net:/home/frs/project/a/av/avbuild/${TARGET_OS/mingw/windows-desktop}
sshpass -p $SF_PW_MAPPED scp -o StrictHostKeyChecking=no ffmpeg-${SUFFIX}*.tar.xz $SF_USER_MAPPED,avbuild@frs.sourceforge.net:/home/frs/project/a/av/avbuild/${TARGET_OS/mingw/windows-desktop}
2 changes: 1 addition & 1 deletion tools/ci-before-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fi

wget https://sourceforge.net/projects/avbuild/files/dep/dep.7z/download -O dep.7z
7z x -y dep.7z -o/tmp
find /tmp/dep/ClangCLx64 /tmp/dep/include /tmp/dep/linux*
find /tmp/dep
ln -sf /tmp/dep tools/

if [[ "$SYSROOT_CACHE_HIT" != "true" ]]; then
Expand Down

0 comments on commit 9dc17ad

Please sign in to comment.