-
Notifications
You must be signed in to change notification settings - Fork 43
/
build.sh
executable file
·329 lines (274 loc) · 11.9 KB
/
build.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/sh
# Option feature set to FALSE if not required and TRUE if required
ENABLE_FFPLAY=FALSE
ENABLE_TOPAZ=FALSE
ENABLE_AVISYNTHPLUS=FALSE
BUILD_FROM_MAIN=TRUE
# set true for dependant features, export those needed in ffmpeg build script
if [[ "${ENABLE_TOPAZ}" == "TRUE" ]]
then
export ENABLE_TOPAZ=TRUE
echo You have enabled Topaz Video AI support.
echo This execuatable can not be re-distributed under the terms of the GPL
echo and hence is for your private use only.
echo Using the Topaz Video AI filters requires an activate Topaz Video AI licence.
echo and install of the Application with the models you wish to use.
echo To use the Topaz Video AI filters you must set the environment variable TVAI_MODEL_DIR
echo and log into Topaz using the login commanda
echo
echo export TVAI_MODEL_DIR="/Applications/Topaz Video AI.app/Contents/Resources/models"
echo export TVAI_MODEL_DATA_DIR="/Applications/Topaz Video AI.app/Contents/Resources/models"
echo
echo If you have logged out of your Topaz account you can log in using
echo out/bin/login topaz_account_email_address topaz_account_password
echo
fi
if [[ "${ENABLE_FFPLAY}" == "TRUE" ]]
then
export ENABLE_FFPLAY=TRUE
fi
if [[ "${ENABLE_AVISYNTHPLUS}" == "TRUE" ]]
then
export ENABLE_AVISYNTHPLUS=TRUE
echo "Enabling AviSynthPlus will meaan this binary is not longer staticly built."
echo "To use AviSynthPlus you will need to run from the tool/lib directory or a directory with a link to the tool/lib/libavisynth.dylib file"
echo
fi
if [[ "${BUILD_FROM_MAIN}" == "TRUE" ]]
then
export BUILD_FROM_MAIN=TRUE
echo "Enabling Build from main."
echo "This will build ffmpeg and x265 from their respective source repositories."
echo "This will this will get you the latest and greatest, but increases the chances the build will fail"
echo
fi
# get rid of macports - libiconv
export PATH=`echo $PATH | sed 's/:/\n/g' | grep -v '/opt/local' | xargs | tr ' ' ':'`
which sed
ACTION=$1
if [[ -z "${ACTION}" ]]
then
echo "No action set, all failures wil stop the script"
elif [[ "${ACTION}" == "clean" ]]
then
echo "Action set to clean, existing build folders will have make clean run"
elif [[ "${ACTION}" == "skip" ]]
then
echo "Action set to clean, existing build folders will be skipped"
else
echo "Action set to ${ACTION}, unknow option should be clean or skip"
exit 1
fi
export ACTION=$ACTION
# some folder names
BASE_DIR="$( cd "$( dirname "$0" )" > /dev/null 2>&1 && pwd )"
echo "base directory is ${BASE_DIR}"
SCRIPT_DIR="${BASE_DIR}/build"
echo "script directory is ${SCRIPT_DIR}"
TEST_DIR="${BASE_DIR}/test"
echo "test directory is ${TEST_DIR}"
WORKING_DIR="$( pwd )"
echo "working directory is ${WORKING_DIR}"
TOOL_DIR="$WORKING_DIR/tool"
echo "tool directory is ${TOOL_DIR}"
OUT_DIR="$WORKING_DIR/out"
echo "output directory is ${OUT_DIR}"
export PKG_CONFIG_PATH=${TOOL_DIR}/lib/pkgconfig
# load functions
. $SCRIPT_DIR/functions.sh
# prepare workspace
echoSection "prepare workspace"
mkdir "$TOOL_DIR"
checkStatusAndAction $? "unable to create tool directory"
PATH="$TOOL_DIR/bin:$PATH"
mkdir "$OUT_DIR"
checkStatusAndAction $? "unable to create output directory"
# detect CPU threads (nproc for linux, sysctl for osx)
CPUS=1
CPUS_NPROC="$(nproc 2> /dev/null)"
if [ $? -eq 0 ]
then
CPUS=$CPUS_NPROC
else
CPUS_SYSCTL="$(sysctl -n hw.ncpu 2> /dev/null)"
if [ $? -eq 0 ]
then
CPUS=$CPUS_SYSCTL
fi
fi
echo "use ${CPUS} cpu threads"
COMPILATION_START_TIME=$(currentTimeInSeconds)
#START_TIME=$(currentTimeInSeconds)
#echoSection "compile autoconf"
#$SCRIPT_DIR/build-autoconf.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "2.71" > "$WORKING_DIR/build-autoconf.log" 2>&1
#checkStatus $? "build autoconf"
#echoDurationInSections $START_TIME
# start build
#START_TIME=$(currentTimeInSeconds)
#echoSection "compile nasm"
#$SCRIPT_DIR/build-nasm.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "2.14.02" > "$WORKING_DIR/build-nasm.log" 2>&1
#checkStatus $? "build nasm"
#echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile cmake"
$SCRIPT_DIR/build-cmake.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "3.20" "3.20.2" > "$WORKING_DIR/build-cmake.log" 2>&1
checkStatus $? "build cmake"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile pkg-config"
$SCRIPT_DIR/build-pkg-config.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "0.29.2" > "$WORKING_DIR/build-pkg-config.log" 2>&1
checkStatus $? "build pkg-config"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile FriBidi"
$SCRIPT_DIR/build-fribidi.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "1.0.10" > "$WORKING_DIR/build-fribidi.log" 2>&1
checkStatus $? "build FriBidi"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile zlib"
$SCRIPT_DIR/build-zlib.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxxx" > "$WORKING_DIR/build-zlib.log" 2>&1
checkStatus $? "build zlib"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile libpng"
$SCRIPT_DIR/build-libpng.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxxxx" > "$WORKING_DIR/build-libpng.log" 2>&1
checkStatus $? "build libpng"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile brotli"
$SCRIPT_DIR/build-brotli.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxxxx" > "$WORKING_DIR/build-brotli.log" 2>&1
checkStatus $? "build brotli"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile freetype"
$SCRIPT_DIR/build-freetype.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "VER-2-11-1" > "$WORKING_DIR/build-freetype.log" 2>&1
checkStatus $? "build freetype"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile harfbuzz"
$SCRIPT_DIR/build-harfbuzz.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxx" > "$WORKING_DIR/build-harfbuzz.log" 2>&1
checkStatus $? "build harfbuzz"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile libass"
$SCRIPT_DIR/build-libass.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "0.15.1" > "$WORKING_DIR/build-libass.log" 2>&1
checkStatus $? "build libass"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile fdk-aac"
$SCRIPT_DIR/build-fdk-aac.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "2.0.2" > "$WORKING_DIR/build-fdk-aac.log" 2>&1
checkStatus $? "build fdk-aac"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile x265"
$SCRIPT_DIR/build-x265.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "3.6" > "$WORKING_DIR/build-x265.log" 2>&1
checkStatus $? "build x265"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile svt-av1"
$SCRIPT_DIR/build-svt-av1.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxx" > "$WORKING_DIR/build-svt-av1.log" 2>&1
checkStatus $? "build svt-av1"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile ogg"
$SCRIPT_DIR/build-ogg.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxx" > "$WORKING_DIR/build-ogg.log" 2>&1
checkStatus $? "build ogg"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile vorbis"
$SCRIPT_DIR/build-vorbis.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxx" > "$WORKING_DIR/build-vorbis.log" 2>&1
checkStatus $? "build vorbis"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile aom"
$SCRIPT_DIR/build-aom.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "2.0.0" > "$WORKING_DIR/build-aom.log" 2>&1
checkStatus $? "build aom"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile openh264"
#$SCRIPT_DIR/build-openh264.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "2.1.1" > "$WORKING_DIR/build-openh264.log" 2>&1
$SCRIPT_DIR/build-openh264.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "2.3.0" > "$WORKING_DIR/build-openh264.log" 2>&1
checkStatus $? "build openh264"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile x264"
$SCRIPT_DIR/build-x264.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" > "$WORKING_DIR/build-x264.log" 2>&1
checkStatus $? "build x264"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile vpx"
$SCRIPT_DIR/build-vpx.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "1.9.0" > "$WORKING_DIR/build-vpx.log" 2>&1
checkStatus $? "build vpx"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile lame (mp3)"
$SCRIPT_DIR/build-lame.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "3.100" > "$WORKING_DIR/build-lame.log" 2>&1
checkStatus $? "build lame"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile opus"
$SCRIPT_DIR/build-opus.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "v1.5.1" > "$WORKING_DIR/build-opus.log" 2>&1
checkStatus $? "build opus"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile fontconfig"
$SCRIPT_DIR/build-fontconfig.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxx" > "$WORKING_DIR/build-fontconfig.log" 2>&1
checkStatus $? "build fontconfig"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile libbluray"
$SCRIPT_DIR/build-libbluray.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxx" > "$WORKING_DIR/build-libbluray.log" 2>&1
checkStatus $? "build libbluray"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile libwebp"
$SCRIPT_DIR/build-libwebp.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxx" > "$WORKING_DIR/build-libwebp.log" 2>&1
checkStatus $? "build libwebp"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile openssl"
$SCRIPT_DIR/build-openssl.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxx" > "$WORKING_DIR/build-openssl.log" 2>&1
checkStatus $? "build openssl"
echoDurationInSections $START_TIME
START_TIME=$(currentTimeInSeconds)
echoSection "compile libsrt"
$SCRIPT_DIR/build-libsrt.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxx" > "$WORKING_DIR/build-libsrt.log" 2>&1
checkStatus $? "build srt"
echoDurationInSections $START_TIME
if [[ "${ENABLE_FFPLAY}" == "TRUE" ]]
then
START_TIME=$(currentTimeInSeconds)
echoSection "compile sdl2"
$SCRIPT_DIR/build-sdl2.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "xxxx" > "$WORKING_DIR/build-sdl2.log" 2>&1
checkStatus $? "build sdl2"
echoDurationInSections $START_TIME
fi
if [[ "${ENABLE_AVISYNTHPLUS}" == "TRUE" ]]
then
START_TIME=$(currentTimeInSeconds)
echoSection "compile AviSythnPlus"
$SCRIPT_DIR/build-avisynth.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$CPUS" "v3.7.2" > "$WORKING_DIR/build-avisynth.log" 2>&1
checkStatus $? "build AviSythnPlus"
echoDurationInSections $START_TIME
fi
START_TIME=$(currentTimeInSeconds)
if [[ "${ENABLE_TOPAZ}" == "TRUE" ]]
then
echoSection "compile ffmpeg with topaz"
$SCRIPT_DIR/build-ffmpeg-topaz.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$OUT_DIR" "$CPUS" "7.0.0.3" > "$WORKING_DIR/build-ffmpeg-topaz.log" 2>&1
else
echoSection "compile ffmpeg"
$SCRIPT_DIR/build-ffmpeg.sh "$SCRIPT_DIR" "$WORKING_DIR" "$TOOL_DIR" "$OUT_DIR" "$CPUS" "7.0.2" > "$WORKING_DIR/build-ffmpeg.log" 2>&1
fi
checkStatus $? "build ffmpeg"
echoDurationInSections $START_TIME
echo "compilation finished successfully"
echoDurationInSections $COMPILATION_START_TIME
echoSection "bundle result"
cd "$OUT_DIR/bin/"
checkStatus $? "change directory"
zip -9 -r "$WORKING_DIR/ffmpeg-success.zip" *
echoSection "run tests"
$TEST_DIR/test.sh "$SCRIPT_DIR" "$TEST_DIR" "$WORKING_DIR" "$OUT_DIR" > "$WORKING_DIR/test.log" 2>&1
checkStatus $? "test"
echo "tests executed successfully"