-
Notifications
You must be signed in to change notification settings - Fork 461
/
build_source.sh
executable file
·383 lines (340 loc) · 11 KB
/
build_source.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#!/usr/bin/env bash
# Stop execution on any error
# Note: we can override this in the Dockerfile RUN command with an || true.
# which is useful for debugging
set -e
manifestJsonFile="/tmp/workdir/generated_build_manifest.json"
manifestJsonVersionsFile="/tmp/workdir/generated_build_versions_manifest.json"
OS_NAME=$(uname -s)
is_ubuntu=false
is_alpine=false
if [[ "$OS_NAME" == "Linux" ]]; then
if grep -q "Ubuntu" /etc/os-release; then
is_ubuntu=true
elif grep -q "Alpine Linux" /etc/alpine-release; then
is_alpine=true
fi
fi
######################### Callback build functions #########################
build_libopencore-amr() {
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_libx264() {
./configure --prefix="${PREFIX}" --enable-shared --enable-pic --disable-cli
make
make install
}
build_libx265() {
cd build/linux
sed -i "/-DEXTRA_LIB/ s/$/ -DCMAKE_INSTALL_PREFIX=\${PREFIX}/" multilib.sh
sed -i "/^cmake/ s/$/ -DENABLE_CLI=OFF/" multilib.sh
./multilib.sh
make -C 8bit install
}
build_libogg() {
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_libopus() {
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_libvorbis() {
./configure --prefix="${PREFIX}" --with-ogg="${PREFIX}" --enable-shared
make
make install
# https://gitlab.xiph.org/xiph/vorbis
# cmake -G YOUR-PROJECT-GENERATOR -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX="${PREFIX}" .
# make
# make install
}
build_libvpx() {
local data=$(jq -r '.[] | select(.library_name == "libvpx")' $manifestJsonFile)
local dir=$(echo "$data" | jq -r '.build_dir')
local vpx_version=$(jq -r '.["libvpx"]' $manifestJsonVersionsFile)
if [ -n "$vpx_version" ] && [[ "$vpx_version" != "null" ]]; then
echo "Building [libvpx-${vpx_version}] in [${dir}]"
else
echo "Error: libvpx version is empty or unset"
fi
version="v${vpx_version}"
git -C libvpx pull 2> /dev/null || git clone --branch ${version} --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
pwd
./configure --prefix="${PREFIX}" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --enable-pic --enable-shared --as=yasm
make
make install
}
build_libwebp() {
./configure --prefix="${PREFIX}" --enable-shared && \
make && \
make install
}
build_libmp3lame() {
./configure --prefix="${PREFIX}" --bindir="${PREFIX}/bin" --enable-shared --enable-nasm --disable-frontend && \
make && \
make install
}
build_libxvid() {
# read doc/INSTALL
cd build/generic
./configure --help
echo "Now guess"
./configure --prefix="${PREFIX}" --bindir="${PREFIX}/bin --enable-shared"
make
make install
}
build_libfdk-aac() {
autoreconf -fiv && \
./configure --prefix="${PREFIX}" --enable-shared
make
make install
}
build_openjpeg() {
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${PREFIX}" . && \
make && \
make install
}
build_freetype() {
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
build_libvidstab() {
cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" . && \
make && \
make install
}
build_fribidi() {
# Currently broken, need to fix
# sed -i 's/^SUBDIRS =.*/SUBDIRS=gen.tab charset lib bin/' Makefile.am
# ./bootstrap --no-config --auto
./configure --prefix="${PREFIX}" --disable-static --enable-shared
make -j1
make install
}
build_fontconfig() {
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
build_libass() {
./autogen.sh && \
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
build_kvazaar() {
# ./autogen.sh && \
./configure --prefix="${PREFIX}" --disable-static --enable-shared && \
make && \
make install
}
# aom is a git clone ( to get source, so not in the loop using the callback function)
build_aom() {
local data=$(jq -r '.[] | select(.library_name == "aom")' $manifestJsonFile)
local dir=$(echo "$data" | jq -r '.build_dir')
local aom_version=$(jq -r '.["aom"]' $manifestJsonVersionsFile) # Access value with key "aom"
if [ -n "$aom_version" ] && [[ "$aom_version" != "null" ]]; then
echo "Building [aom-${aom_version}] in [${dir}]"
else
echo "Error: aom version is empty or unset"
fi
version="v${aom_version}"
git clone --branch ${version} --depth 1 https://aomedia.googlesource.com/aom ${dir} && \
cd ${dir} && \
mkdir -p ./aom_build && \
cd ./aom_build && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DBUILD_SHARED_LIBS=1 -DENABLE_NASM=on .. && \
make && \
make install
}
build_nvidia-codec-headers() {
local dir=${1}
# git clone https://github.com/FFmpeg/nv-codec-headers ${dir}
# git checkout n${NVIDIA_HEADERS_VERSION}
make PREFIX="${PREFIX}"
make install PREFIX="${PREFIX}"
}
build_libsvtav1() {
cd Build && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF .. \
make && \
make install
}
build_xorg-macros() {
dir=${1}
./configure --srcdir=${dir} --prefix="${PREFIX}" && \
make && \
make install
}
build_xproto() {
dir=${1}
cp /usr/share/misc/config.guess . && \
./configure --srcdir=${dir} --prefix="${PREFIX}" && \
make && \
make install
}
build_libxau() {
dir=${1}
./configure --srcdir=${dir} --prefix="${PREFIX}" && \
make && \
make install
}
build_libpthread-stubs() {
./configure --prefix="${PREFIX}" && \
make && \
make install
}
build_libxml2() {
./autogen.sh --prefix="${PREFIX}" --with-ftp=no --with-http=no --with-python=no && \
make && \
make install
}
build_libbluray() {
## libbluray - Requires libxml, freetype, and fontconfig
./configure --prefix="${PREFIX}" --disable-examples --disable-bdjava-jar --disable-static --enable-shared && \
make && \
make install
}
build_libzmq() {
./autogen.sh && \
./configure --prefix="${PREFIX}" && \
make && \
make install
}
# another special, code clone situation ( actually currently using the tarball build approach )
build_libpng() {
local dir = "/tmp/png"
# local libpng_version=$(jq -r '.["libpng"]' $manifestJsonVersionsFile) # Access value with key "libpng"
# git clone https://git.code.sf.net/p/libpng/code ${dir} -b v${libpng_version} --depth 1 && \
./autogen.sh && \
./configure --prefix="${PREFIX}" && \
make check && \
make install
}
build_libaribb24() {
autoreconf -fiv && \
./configure CFLAGS="-I${PREFIX}/include -fPIC" --prefix="${PREFIX}" && \
make && \
make install
}
build_zimg() {
./autogen.sh && \
./configure --prefix="${PREFIX}" --enable-shared && \
make && \
make install
}
# Dependancy on libogg
build_libtheora() {
if [ "$is_ubuntu" = true ]; then
cp /usr/share/misc/config.guess .
fi
./configure --prefix="${PREFIX}" --with-ogg="${PREFIX}" --enable-shared --disable-examples
make
make install
}
build_libsrt() {
# requires libssl-dev
cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" . && \
make && \
make install
}
build_libvmaf() {
# https://github.com/Netflix/vmaf/issues/788#issuecomment-756098059
mkdir ./libvmaf/build
cd ./libvmaf/build
meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=static --prefix "${PREFIX}" .. && \
# meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=shared --prefix "${PREFIX}" ..
ninja
ninja install
}
build_ffmpeg() {
# Here is a list of things that we enable in the ffmpeg build: that are not in the
# track configuration guide: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu#FFmpeg
# --enable-fontconfig
# --enable-libaribb24
# --enable-libbluray
# --enable-libkvazaar
# --enable-libopencore-amrnb
# --enable-libopencore-amrwb
# --enable-libopenjpeg
# --enable-libsrt
# --enable-libtheora
# --enable-libvmaf
# --enable-libwebp
# --enable-libxvid
# --enable-libzimg
# --enable-libzmq
# --enable-openssl
# --enable-postproc
# --enable-small
# --enable-version3
# export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
./configure %%FFMPEG_CONFIG_FLAGS%% && \
make && \
make install && \
make tools/zmqsend && cp tools/zmqsend ${PREFIX}/bin/ && \
make distclean && \
hash -r && \
cd tools && \
make qt-faststart && cp qt-faststart ${PREFIX}/bin/
}
######################### Helper functions #########################
extract_tarball() {
local tarball_name=$1
# grab the extension of the tarball
local extension="${tarball_name##*.}"
# tar extraction args: -z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
if [ "$extension" == "gz" ]; then
tar -zx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "bz2" ]; then
tar -jx --strip-components=1 -f ${tarball_name}
elif [ "$extension" == "xz" ]; then
tar -Jx --strip-components=1 -f ${tarball_name}
else
echo "Error while extract_tarball, got an unknown extension: $extension"
fi
}
build_support_libraries() {
local librariesRaw="$(jq -r '.[] | .library_name' $manifestJsonFile)"
local libs=( $librariesRaw )
for i in "${!libs[@]}"; do
lib_name=${libs[$i]}
# handle the clone source case's ( there are only two )
# if [ "$lib_name" == "libsvtav1" ]; then
# echo "-------------------- Running callback: build_aom --------------------"
# echo "Building 'aom' before we build $lib_name"
# build_aom
# fi
# ffmpeg is in the lib_name string then the callback name is build_ffmpeg
callback_lib_name=${lib_name}
if [[ "$lib_name" == *"ffmpeg"* ]]; then
# take out the version numbers
callback_lib_name="ffmpeg"
fi
local data=$(jq -r '.[] | select(.library_name == "'${lib_name}'")' $manifestJsonFile)
build_dir=$(echo "$data" | jq -r '.build_dir')
tarball_name=$(echo "$data" | jq -r '.tarball_name')
sha256sum=$(echo "$data" | jq -r '.sha256sum')
echo "Building $lib_name: from ${build_dir}/$tarball_name"
cd $build_dir
extract_tarball $tarball_name
if [ -n "$sha256sum" ] && [[ "$sha256sum" != "null" ]]; then
echo "Checking sha256sum for $tarball_name"
echo $sha256sum | sha256sum --check
fi
# make a callback function to build the library
# if anything fails, we will exit with a non-zero status
echo "-------------------- Running callback: build_${lib_name} --------------------"
build_${callback_lib_name} ${build_dir}
echo "Finished building $lib_name removing build directory [${build_dir}]"
cd /tmp/workdir
rm -rf $build_dir
done
}
build_support_libraries