Skip to content

Commit

Permalink
make xcframework bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
debugly committed Jun 4, 2024
1 parent 84fc677 commit e48c88d
Show file tree
Hide file tree
Showing 21 changed files with 314 additions and 243 deletions.
50 changes: 9 additions & 41 deletions .github/workflows/opus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,17 @@ jobs:
ls | awk -F ' ' '{printf "echo %s\n echo -------------\ngit -C %s log -n 1 | cat\n",$0,$0}' | bash > ../tvos-src-log.md
- name: do compile macos libs
run: |
cd macos
./compile-any.sh build ${{ env.LIB_NAME }}
./compile-any.sh lipo ${{ env.LIB_NAME }}
./macos/compile-any.sh -a 'arm64 x86_64' -c build -l ${{ env.LIB_NAME }}
- name: do compile ios libs
run: |
cd ios
./compile-any.sh build ${{ env.LIB_NAME }}
./compile-any.sh lipo ${{ env.LIB_NAME }}
./ios/compile-any.sh -a 'arm64 x86_64_simulator' -c build -l ${{ env.LIB_NAME }}
- name: do compile tvos libs
run: |
cd tvos
./compile-any.sh build ${{ env.LIB_NAME }}
./compile-any.sh lipo ${{ env.LIB_NAME }}
- name: Zip macos libs
./tvos/compile-any.sh -a 'arm64 arm64_simulator' -c build -l ${{ env.LIB_NAME }}
- name: Zip apple xcframework
run: |
cd build/product/macos/universal
zip -rq macos-universal.zip ./*
- name: Zip ios libs
run: |
cd build/product/ios/universal
zip -rq ios-universal.zip ./*
- name: Zip tvos libs
run: |
cd build/product/tvos/universal
zip -rq tvos-universal.zip ./*
cd build/product/xcframework
zip -rq apple-xcframework.zip ./*
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -76,32 +62,14 @@ jobs:
release_name: ${{ env.LIB_NAME }}-${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
- name: Upload macos Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: build/product/macos/universal/macos-universal.zip
asset_name: "${{ env.LIB_NAME }}-macos-universal-${{ env.RELEASE_VERSION }}.zip"
asset_content_type: application/zip
- name: Upload ios Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: build/product/ios/universal/ios-universal.zip
asset_name: "${{ env.LIB_NAME }}-ios-universal-${{ env.RELEASE_VERSION }}.zip"
asset_content_type: application/zip
- name: Upload tvos Release Asset
- name: Upload Apple Plat Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: build/product/tvos/universal/tvos-universal.zip
asset_name: "${{ env.LIB_NAME }}-tvos-universal-${{ env.RELEASE_VERSION }}.zip"
asset_path: build/product/apple-xcframework.zip
asset_name: "${{ env.LIB_NAME }}-apple-xcframework-${{ env.RELEASE_VERSION }}.zip"
asset_content_type: application/zip
- name: Upload macos src md
uses: actions/upload-release-asset@v1
Expand Down
111 changes: 76 additions & 35 deletions apple/compile-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,79 +16,120 @@
#
#

PLAT=$1
CMD=$2
LIBS=$3
ARCH=$4
OPTS=$5

set -e

# 当前脚本所在目录
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
cd "$THIS_DIR"

function usage() {
echo " useage:"
echo " $0 [ios|macos|tvos] [build|rebuild|lipo|clean] [all|ffmpeg|libyuv|openssl|opus|bluray|dav1d|dvdread|freetype|fribidi|harfbuzz|unibreak|ass|ffmpeg] [arm64|x86_64|all] [opts...]"
function usage()
{
cat << EOF
usage: ./apple/compile-any.sh [options]
compile ijkplayer using libs for iOS and macOS and tvOS,such as libass、ffmpeg...
OPTIONS:
-h Show some help
-p Specify platform (ios,macos,tvos)
-c Specify cmd (build,clean,rebuild,lipo) rebuild=clean+build
-a Specify archs (x86_64,arm64,x86_64_simulator,arm64_simulator,all) all="x86_64,arm64,x86_64_simulator,arm64_simulator"
-l Specify which libs need 'cmd' (all|libyuv|openssl|opus|bluray|dav1d|dvdread|freetype|fribidi|harfbuzz|unibreak|ass|ffmpeg)
-d Enable debug mode (disable by default)
-t Force number of cores to be used
EOF
}

if [[ "$PLAT" != 'ios' && "$PLAT" != 'macos' && "$PLAT" != 'tvos' ]]; then
echo "plat must be: [ios|macos|tvos]"
usage
while getopts "hp:c:a:l:dt:" opt
do
#echo "opt:$opt,OPTIND:[$OPTIND],OPTARG:[$OPTARG]"
case $opt in
h)
usage
;;
p)
XC_PLAT="$OPTARG"
if [[ "$XC_PLAT" != 'ios' && "$XC_PLAT" != 'macos' && "$XC_PLAT" != 'tvos' ]]; then
echo "plat must be: [ios|macos|tvos]"
exit 1
fi
;;
c)
XC_CMD="$OPTARG"
;;
a)
XC_ALL_ARCHS="$OPTARG"
;;
l)
LIBS="$OPTARG"
;;
d)
XC_DEBUG='debug'
;;
t)
XC_THREAD="$OPTARG"
;;
esac
done

shift $((OPTIND-1))

if [[ -z "$XC_THREAD" ]];then
XC_THREAD=$(sysctl -n machdep.cpu.thread_count)
echo "support thread count:$XC_THREAD"
fi

if [[ -z "$XC_CMD" ]];then
echo "cmd can't be nil. use -c specify cmd"
exit 1
fi

source 'init-env.sh'
if [[ -z "$LIBS" ]];then
echo "libs can't be nil. use -l specify libs"
exit 1
fi

init_plat_env $PLAT
export XC_THREAD
export XC_PLAT
export XC_CMD
export XC_DEBUG

if [[ -z "$LIBS" || "$LIBS" == "all" ]]; then
if [[ "$LIBS" == "all" ]]; then
list='compile-cfgs/list.txt'
#use plat list
if [[ -f "compile-cfgs/list_${PLAT}.txt" ]]; then
list="compile-cfgs/list_${PLAT}.txt"
if [[ -f "compile-cfgs/list_${XC_PLAT}.txt" ]]; then
list="compile-cfgs/list_${XC_PLAT}.txt"
fi
LIBS=$(cat $list)
fi

if [[ -z "$ARCH" || "$ARCH" == 'all' ]]; then
ARCH="$XC_ALL_ARCHS"
fi

if [[ -z "$CMD" ]]; then
echo "cmd must be: [build|rebuild|lipo|clean]"
usage
exit 1
fi


export XC_CMD="$CMD"
export XC_TARGET_ARCHS="$ARCH"
export XC_OPTS="$OPTS"
export XC_VENDOR_LIBS="$LIBS"
export XC_ALL_ARCHS

source 'init-env.sh'
init_plat_env

echo '------------------------------------------'
echo "XC_PLAT : [$XC_PLAT]"
echo "XC_CMD : [$XC_CMD]"
echo "XC_VENDOR_LIBS : [$XC_VENDOR_LIBS]"
echo "XC_TARGET_ARCHS : [$ARCH]"
echo "XC_OPTS : [$XC_OPTS]"
echo "XC_ALL_ARCHS : [$XC_ALL_ARCHS]"
echo "XC_DEBUG : [$XC_DEBUG]"
echo "XC_FORCE_CROSS : [$XC_FORCE_CROSS]"
echo "XC_THREAD : [$XC_THREAD]"
echo '------------------------------------------'

START_STMP=$(date +%s)
# 循环编译所有的库
for lib in $LIBS
do
echo "===[$CMD $lib]===================="
echo "===[$XC_CMD $lib]===================="
source compile-cfgs/"$lib"

./do-compile/any.sh
if [[ $? -eq 0 ]];then
echo "🎉 Congrats"
echo "🚀 ${LIB_NAME} successfully $CMD."
echo "🚀 ${LIB_NAME} successfully $XC_CMD."
echo
fi
echo "===================================="
Expand Down
2 changes: 1 addition & 1 deletion apple/compile-cfgs/list_ios.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
libyuv openssl opus dav1d ffmpeg
openssl opus dav1d dvdread freetype fribidi harfbuzz unibreak ass ffmpeg
Loading

0 comments on commit e48c88d

Please sign in to comment.