Skip to content

Commit 86daa19

Browse files
committed
iOS enable libdav1d
1 parent f455ec9 commit 86daa19

File tree

8 files changed

+219
-138
lines changed

8 files changed

+219
-138
lines changed

apple/compile-any.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SHELL_DIR="$PWD"
3030

3131
function usage() {
3232
echo " useage:"
33-
echo " $0 [ios|macos] [build|lipo|clean] [all|ffmpeg|libyuv|openssl|opus|dav1d] [arm64|x86_64|all] [opts...]"
33+
echo " $0 [ios|macos] [build|rebuild|lipo|clean] [all|ffmpeg|libyuv|openssl|opus|dav1d] [arm64|x86_64|all] [opts...]"
3434
}
3535

3636
if [[ "$PLAT" != 'ios' && "$PLAT" != 'macos' ]]; then
@@ -55,7 +55,7 @@ if [[ -z "$ARCH" || "$ARCH" == 'all' ]]; then
5555
fi
5656

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

apple/compile-cfgs/list_ios.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
libyuv openssl opus ffmpeg
1+
libyuv openssl opus dav1d ffmpeg

apple/do-compile/any.sh

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ env_assert "LIB_NAME"
2929
echo "ARGV:$*"
3030
echo "===check env end==="
3131

32-
do_lipo_lib () {
32+
do_lipo_lib() {
3333
local LIB_FILE=$1
3434
local archs="$2"
3535
local LIPO_FLAGS=
36-
for arch in $archs
37-
do
36+
for arch in $archs; do
3837
local ARCH_LIB_FILE="$XC_PRODUCT_ROOT/$LIB_NAME-$arch/lib/$LIB_FILE"
3938
if [ -f "$ARCH_LIB_FILE" ]; then
4039
LIPO_FLAGS="$LIPO_FLAGS $ARCH_LIB_FILE"
@@ -48,18 +47,16 @@ do_lipo_lib () {
4847
xcrun lipo -info $XC_UNI_PROD_DIR/$LIB_NAME/lib/$LIB_FILE
4948
}
5049

51-
do_lipo_all () {
50+
do_lipo_all() {
5251
local archs="$1"
5352
rm -rf $XC_UNI_PROD_DIR/$LIB_NAME
5453
mkdir -p $XC_UNI_PROD_DIR/$LIB_NAME/lib
5554
echo "lipo archs: $archs"
56-
for lib in $LIPO_LIBS
57-
do
55+
for lib in $LIPO_LIBS; do
5856
do_lipo_lib "$lib.a" "$archs"
5957
done
6058

61-
for arch in $archs
62-
do
59+
for arch in $archs; do
6360
local ARCH_INC_DIR="$XC_PRODUCT_ROOT/$LIB_NAME-$arch/include"
6461
local ARCH_OUT_DIR="$XC_UNI_PROD_DIR/$LIB_NAME/include"
6562
if [[ -d "$ARCH_INC_DIR" && ! -d "$ARCH_OUT_DIR" ]]; then
@@ -99,8 +96,7 @@ function do_compile() {
9996

10097
function resolve_dep() {
10198
echo "[*] check depends bins: ${LIB_DEPENDS_BIN}"
102-
for b in ${LIB_DEPENDS_BIN}
103-
do
99+
for b in ${LIB_DEPENDS_BIN}; do
104100
install_depends "$b"
105101
done
106102
echo "===================="
@@ -120,34 +116,40 @@ function main() {
120116
local opt="$XC_OPTS"
121117

122118
case "$cmd" in
123-
'clean')
124-
for arch in $archs
125-
do
126-
do_clean $arch
127-
done
128-
rm -rf $XC_UNI_PROD_DIR/$LIB_NAME
129-
echo 'done.'
119+
'clean')
120+
for arch in $archs; do
121+
do_clean $arch
122+
done
123+
rm -rf $XC_UNI_PROD_DIR/$LIB_NAME
124+
echo 'done.'
130125
;;
131-
'lipo')
132-
do_lipo_all "$archs"
126+
'lipo')
127+
do_lipo_all "$archs"
133128
;;
134-
'build')
135-
resolve_dep
136-
for arch in $archs
137-
do
138-
init_env $arch
139-
do_compile $arch "$opt"
140-
echo
141-
done
142-
143-
do_lipo_all "$archs"
129+
'build')
130+
resolve_dep
131+
for arch in $archs; do
132+
init_env $arch
133+
do_compile $arch "$opt"
134+
echo
135+
done
136+
137+
do_lipo_all "$archs"
144138
;;
145-
*)
146-
echo "Usage:"
147-
echo " $0 [build|lipo|clean] [x86_64|arm64]"
148-
exit 1
139+
'rebuild')
140+
echo '---clean for rebuild-----------------'
141+
XC_CMD='clean'
142+
main 1>/dev/null
143+
echo '---build for rebuild-----------------'
144+
XC_CMD='build'
145+
main
146+
;;
147+
*)
148+
echo "Usage:"
149+
echo " $0 [build|lipo|clean] [x86_64|arm64]"
150+
exit 1
149151
;;
150152
esac
151153
}
152154

153-
main
155+
main

apple/do-compile/dav1d.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export CXX="$XCRUN_CXX"
4040

4141
if [[ $(uname -m) != "$XC_ARCH" || "$XC_FORCE_CROSS" ]]; then
4242
echo "[*] cross compile, on $(uname -m) compile $XC_PLAT $XC_ARCH."
43-
DAV1D_CFG_FLAGS="$DAV1D_CFG_FLAGS --cross-file package/crossfiles/$XC_ARCH-macos.meson"
43+
44+
DAV1D_CFG_FLAGS="$DAV1D_CFG_FLAGS --cross-file package/crossfiles/$XC_ARCH-$XC_PLAT.meson"
4445
fi
4546

4647
echo "----------------------"
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
From fb86212099423e0771d6ffd081b3d2325b6bb5ef Mon Sep 17 00:00:00 2001
2+
From: qianlongxu <qianlongxu@gmail.com>
3+
Date: Mon, 31 Jul 2023 13:34:23 +0800
4+
Subject: [PATCH] add macos corss file
5+
6+
---
7+
package/crossfiles/arm64-macos.meson | 30 +++++++++++++++++++++++++++
8+
package/crossfiles/x86_64-macos.meson | 30 +++++++++++++++++++++++++++
9+
2 files changed, 60 insertions(+)
10+
create mode 100644 package/crossfiles/arm64-macos.meson
11+
create mode 100644 package/crossfiles/x86_64-macos.meson
12+
13+
diff --git a/package/crossfiles/arm64-macos.meson b/package/crossfiles/arm64-macos.meson
14+
new file mode 100644
15+
index 0000000..c38935a
16+
--- /dev/null
17+
+++ b/package/crossfiles/arm64-macos.meson
18+
@@ -0,0 +1,30 @@
19+
+# This is a cross compilation file from OSX (x86_64) to M1
20+
+# Apple keeps changing the location and names of files so
21+
+# these might not work for you. Use the googels and xcrun.
22+
+
23+
+[binaries]
24+
+c = 'clang'
25+
+cpp = 'clang++'
26+
+objc = 'clang'
27+
+objcpp = 'clang++'
28+
+ar = 'ar'
29+
+strip = 'strip'
30+
+
31+
+[built-in options]
32+
+c_args = ['-arch', 'arm64', '-mmacosx-version-min=10.11', '-Os']
33+
+cpp_args = ['-arch', 'arm64', '-mmacosx-version-min=10.11', '-Os']
34+
+c_link_args = ['-arch', 'arm64', '-mmacosx-version-min=10.11', '-Os']
35+
+cpp_link_args = ['-arch', 'arm64', '-mmacosx-version-min=10.11', '-Os']
36+
+objc_args = ['-arch', 'arm64', '-mmacosx-version-min=10.11', '-Os']
37+
+objcpp_args = ['-arch', 'arm64', '-mmacosx-version-min=10.11', '-Os']
38+
+
39+
+[properties]
40+
+root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer'
41+
+has_function_printf = true
42+
+has_function_hfkerhisadf = false
43+
+
44+
+[host_machine]
45+
+system = 'darwin'
46+
+cpu_family = 'arm64'
47+
+cpu = 'arm64'
48+
+endian = 'little'
49+
\ No newline at end of file
50+
diff --git a/package/crossfiles/x86_64-macos.meson b/package/crossfiles/x86_64-macos.meson
51+
new file mode 100644
52+
index 0000000..287b822
53+
--- /dev/null
54+
+++ b/package/crossfiles/x86_64-macos.meson
55+
@@ -0,0 +1,30 @@
56+
+# This is a cross compilation file from OSX (M1) to x86_64
57+
+# Apple keeps changing the location and names of files so
58+
+# these might not work for you. Use the googels and xcrun.
59+
+
60+
+[binaries]
61+
+c = 'clang'
62+
+cpp = 'clang++'
63+
+objc = 'clang'
64+
+objcpp = 'clang++'
65+
+ar = 'ar'
66+
+strip = 'strip'
67+
+
68+
+[built-in options]
69+
+c_args = ['-arch', 'x86_64', '-mmacosx-version-min=10.11', '-Os']
70+
+cpp_args = ['-arch', 'x86_64', '-mmacosx-version-min=10.11', '-Os']
71+
+c_link_args = ['-arch', 'x86_64', '-mmacosx-version-min=10.11', '-Os']
72+
+cpp_link_args = ['-arch', 'x86_64', '-mmacosx-version-min=10.11', '-Os']
73+
+objc_args = ['-arch', 'x86_64', '-mmacosx-version-min=10.11', '-Os']
74+
+objcpp_args = ['-arch', 'x86_64', '-mmacosx-version-min=10.11', '-Os']
75+
+
76+
+[properties]
77+
+root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer'
78+
+has_function_printf = true
79+
+has_function_hfkerhisadf = false
80+
+
81+
+[host_machine]
82+
+system = 'darwin'
83+
+cpu_family = 'x86_64'
84+
+cpu = 'x86_64'
85+
+endian = 'little'
86+
\ No newline at end of file
87+
--
88+
2.39.2 (Apple Git-143)
89+

extra/patches/dav1d/0001-add-macos-x86_64-cross-file.patch

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
From 3e9f708e0dd45ab9212043c602e6ebbb67b02846 Mon Sep 17 00:00:00 2001
2+
From: qianlongxu <qianlongxu@gmail.com>
3+
Date: Mon, 31 Jul 2023 13:30:25 +0800
4+
Subject: [PATCH] add ios corss file
5+
6+
---
7+
package/crossfiles/arm64-ios.meson | 30 +++++++++++++++++++++++++++++
8+
package/crossfiles/x86_64-ios.meson | 30 +++++++++++++++++++++++++++++
9+
2 files changed, 60 insertions(+)
10+
create mode 100644 package/crossfiles/arm64-ios.meson
11+
create mode 100644 package/crossfiles/x86_64-ios.meson
12+
13+
diff --git a/package/crossfiles/arm64-ios.meson b/package/crossfiles/arm64-ios.meson
14+
new file mode 100644
15+
index 0000000..5eaa411
16+
--- /dev/null
17+
+++ b/package/crossfiles/arm64-ios.meson
18+
@@ -0,0 +1,30 @@
19+
+# This is a cross compilation file from OSX (x86_64) to M1
20+
+# Apple keeps changing the location and names of files so
21+
+# these might not work for you. Use the googels and xcrun.
22+
+
23+
+[binaries]
24+
+c = 'clang'
25+
+cpp = 'clang++'
26+
+objc = 'clang'
27+
+objcpp = 'clang++'
28+
+ar = 'ar'
29+
+strip = 'strip'
30+
+
31+
+[built-in options]
32+
+c_args = ['-arch', 'arm64', '-miphoneos-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk']
33+
+cpp_args = ['-arch', 'arm64', '-miphoneos-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk']
34+
+c_link_args = ['-arch', 'arm64', '-miphoneos-version-min=9.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk']
35+
+cpp_link_args = ['-arch', 'arm64', '-miphoneos-version-min=9.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk']
36+
+objc_args = ['-arch', 'arm64', '-miphoneos-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk']
37+
+objcpp_args = ['-arch', 'arm64', '-miphoneos-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk']
38+
+
39+
+[properties]
40+
+root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer'
41+
+has_function_printf = true
42+
+has_function_hfkerhisadf = false
43+
+
44+
+[host_machine]
45+
+system = 'darwin'
46+
+cpu_family = 'aarch64'
47+
+cpu = 'arm64'
48+
+endian = 'little'
49+
\ No newline at end of file
50+
diff --git a/package/crossfiles/x86_64-ios.meson b/package/crossfiles/x86_64-ios.meson
51+
new file mode 100644
52+
index 0000000..f84e0c6
53+
--- /dev/null
54+
+++ b/package/crossfiles/x86_64-ios.meson
55+
@@ -0,0 +1,30 @@
56+
+# This is a cross compilation file from OSX (M1) to x86_64
57+
+# Apple keeps changing the location and names of files so
58+
+# these might not work for you. Use the googels and xcrun.
59+
+
60+
+[binaries]
61+
+c = 'clang'
62+
+cpp = 'clang++'
63+
+objc = 'clang'
64+
+objcpp = 'clang++'
65+
+ar = 'ar'
66+
+strip = 'strip'
67+
+
68+
+[built-in options]
69+
+c_args = ['-arch', 'x86_64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
70+
+cpp_args = ['-arch', 'x86_64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
71+
+c_link_args = ['-arch', 'x86_64', '-mios-simulator-version-min=9.0', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
72+
+cpp_link_args = ['-arch', 'x86_64', '-mios-simulator-version-min=9.0', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
73+
+objc_args = ['-arch', 'x86_64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
74+
+objcpp_args = ['-arch', 'x86_64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
75+
+
76+
+[properties]
77+
+root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer'
78+
+has_function_printf = true
79+
+has_function_hfkerhisadf = false
80+
+
81+
+[host_machine]
82+
+system = 'darwin'
83+
+cpu_family = 'x86_64'
84+
+cpu = 'x86_64'
85+
+endian = 'little'
86+
\ No newline at end of file
87+
--
88+
2.39.2 (Apple Git-143)
89+

0 commit comments

Comments
 (0)