-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-for-ios.sh
executable file
·202 lines (182 loc) · 4.44 KB
/
build-for-ios.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/sh
BASE_DIR=$(cd `dirname $0`; pwd)
SOURCE=$BASE_DIR/../XFFmpeg
OUTPUT_DIR=$BASE_DIR/output/ios
BINARY_DIR=$BASE_DIR/binary/ios/ffmpeg
DEPLOYMENT_TARGET="11.0"
ARCHS="arm64 x86_64"
if [ ! `which yasm` ]
then
echo 'Yasm not found'
if [ ! `which brew` ]
then
echo 'Homebrew not found. Trying to install...'
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \
|| exit 1
fi
echo 'Trying to install Yasm...'
brew install yasm || exit 1
fi
if [ ! `which gas-preprocessor.pl` ]
then
echo 'gas-preprocessor.pl not found. Trying to install...'
(curl -L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl \
-o /usr/local/bin/gas-preprocessor.pl \
&& chmod +x /usr/local/bin/gas-preprocessor.pl) \
|| exit 1
fi
CONFIGURE_FLAGS="--enable-cross-compile \
--disable-debug \
--disable-programs \
--disable-everything \
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
--disable-shared \
--disable-indevs \
--disable-outdevs \
--disable-devices \
--disable-postproc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-symver \
--disable-stripping \
--disable-muxers \
--disable-gpl \
--disable-version3 \
--disable-nonfree \
--enable-small \
--enable-static \
--enable-asm \
--enable-neon \
--enable-swresample \
--enable-swscale \
--enable-avdevice \
--enable-avfilter \
--enable-filters \
--enable-pthreads \
--enable-openssl \
--enable-network \
--enable-protocol=http \
--enable-protocol=https \
--enable-protocol=rtsp \
--enable-protocol=rtmp \
--enable-runtime-cpudetect \
--enable-protocol=file \
--enable-decoder=aac \
--enable-decoder=mp3 \
--enable-decoder=mjpeg \
--enable-decoder=h264 \
--enable-decoder=hevc \
--enable-decoder=mpeg4 \
--enable-videotoolbox \
--enable-audiotoolbox \
--enable-demuxer=flv \
--enable-demuxer=h264 \
--enable-demuxer=hevc \
--enable-demuxer=mp3 \
--enable-demuxer=aac \
--enable-demuxer=mpegvideo \
--enable-demuxer=m4v \
--enable-demuxer=mov \
--enable-demuxer=mjpeg \
--enable-demuxer=image2 \
--enable-muxer=image2 \
--enable-muxer=mp4 \
--enable-muxer=adts \
--enable-muxer=mjpeg \
--enable-muxer=h264 \
--enable-muxer=hevc \
--enable-encoder=mjpeg \
--enable-encoder=mpeg4 \
--enable-encoder=bmp \
--enable-encoder=aac \
--enable-encoder=aac_at \
--enable-encoder=h264_videotoolbox \
--enable-encoder=hevc_videotoolbox \
--enable-parser=aac \
--enable-parser=mpeg4video \
--enable-parser=mjpeg \
--enable-parser=h264 \
--enable-parser=hevc \
--enable-parser=mpeg4video \
--enable-hwaccels \
--enable-filter=colormatrix,rotate,color,format,scale,null,trim \
--enable-filter=crop,scale2ref,swapuv,allyuv,allrgb,aresample,metadata \
--enable-bsf=aac_adtstoasc \
--enable-bsf=h264_mp4toannexb \
--enable-bsf=hevc_mp4toannexb \
--enable-bsf=h264_metadata \
--enable-protocol=file \
"
function build
{
for ARCH in $ARCHS
do
echo "building $ARCH..."
cd $SOURCE
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET -fembed-bitcode"
if [ "$ARCH" = "arm64e" -o "$ARCH" = "arm64" ]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
# force "configure" to use "gas-preprocessor.pl" (FFmpeg 3.3)
if [ "$ARCH" = "arm64e" -o "$ARCH" = "arm64" ]
then
AS="gas-preprocessor.pl -arch aarch64 -- $CC"
else
AS="gas-preprocessor.pl -- $CC"
fi
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
SSL_DIR=$BASE_DIR/3rd/openssl/iOS-fat
SSL_INC=$SSL_DIR/include
SSL_LIB=$SSL_DIR/lib
ARCH_DIR=$BINARY_DIR/$ARCH
echo "SSL_INC: ${SSL_INC}"
echo "SSL_LIB: ${SSL_LIB}"
./configure \
--target-os=darwin \
--prefix=$ARCH_DIR \
--arch=$ARCH \
--cc="$CC" \
--as="$AS" \
--extra-cflags="-I$SSL_INC $CFLAGS -DHILIVE_XFFMPEG" \
--extra-ldflags="-L$SSL_LIB $LDFLAGS -lz -lm" \
$CONFIGURE_FLAGS
make clean
make -j 16
make install
cd $BASE_DIR
done
}
function merge
{
echo "merge libs..."
mkdir -p $OUTPUT_DIR/include
mkdir -p $OUTPUT_DIR/lib
set - $ARCHS
cd $BINARY_DIR/$1/lib
for LIB in *.a
do
echo lipo -create `find $BINARY_DIR -name $LIB` -output $OUTPUT_DIR/lib/$LIB 1>&2
lipo -create `find $BINARY_DIR -name $LIB` -output $OUTPUT_DIR/lib/$LIB || exit 1
done
cp -rf $BINARY_DIR/$1/include $OUTPUT_DIR
}
build
merge
echo Done