-
Notifications
You must be signed in to change notification settings - Fork 571
/
Copy pathcommon.jl
146 lines (134 loc) · 4.23 KB
/
common.jl
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
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg
name = "FFMPEG"
version_string = "7.1" # when patch number is zero, they use X.Y format
version = VersionNumber(version_string)
# Collection of sources required to build FFMPEG
sources = [
ArchiveSource(
"https://ffmpeg.org/releases/ffmpeg-$(version_string).tar.xz",
"40973d44970dbc83ef302b0609f2e74982be2d85916dd2ee7472d30678a7abe6",
),
## FFmpeg 6.1.1 does not work with macos 10.13 or earlier.
ArchiveSource(
"https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.13.sdk.tar.xz",
"a3a077385205039a7c6f9e2c98ecdf2a720b2a819da715e03e0630c75782c1e4",
),
]
# Bash recipe for building across all platforms
# TODO: Theora once it's available
function script(; ffplay=false)
"FFPLAY=$(ffplay)\n" * raw"""
cd $WORKSPACE/srcdir
cd ffmpeg-*/
sed -i 's/-lflite"/-lflite -lasound"/' configure
if [[ "${target}" == *-linux-* ]]; then
export ccOS="linux"
elif [[ "${target}" == *-apple-* ]]; then
export ccOS="darwin"
elif [[ "${target}" == *-w32-* ]]; then
export ccOS="mingw32"
elif [[ "${target}" == *-w64-* ]]; then
export ccOS="mingw64"
elif [[ "${target}" == *-unknown-freebsd* ]]; then
export ccOS="freebsd"
else
export ccOS="linux"
fi
if [[ "${target}" == x86_64-* ]]; then
export ccARCH="x86_64"
elif [[ "${target}" == i686-* ]]; then
export ccARCH="i686"
elif [[ "${target}" == arm-* ]]; then
export ccARCH="arm"
elif [[ "${target}" == aarch64-* ]]; then
export ccARCH="aarch64"
elif [[ "${target}" == powerpc64le-* ]]; then
export ccARCH="powerpc64le"
else
export ccARCH="x86_64"
fi
if [[ "${target}" == x86_64-apple-darwin* ]]; then
export MACOSX_DEPLOYMENT_TARGET=10.13
pushd ${WORKSPACE}/srcdir/MacOSX10.*.sdk
rm -rf /opt/${target}/${target}/sys-root/System
cp -a usr/* "/opt/${target}/${target}/sys-root/usr/"
cp -a System "/opt/${target}/${target}/sys-root/"
popd
fi
export CUDA_ARGS=""
EXTRA_FLAGS=()
if [[ "${target}" == *-darwin* ]]; then
EXTRA_FLAGS+=(--objcc="${CC} -x objective-c")
fi
if [[ "${FFPLAY}" == "true" ]]; then
EXTRA_FLAGS+=("--enable-ffplay")
fi
# Remove `-march` flags
sed -i 's/cpuflags="-march=$cpu"/cpuflags=""/g' configure
./configure \
--enable-cross-compile \
--cross-prefix=/opt/${target}/bin/${target}- \
--arch=${ccARCH} \
--target-os=${ccOS} \
--cc="${CC}" \
--cxx="${CXX}" \
--dep-cc="${CC}" \
--ar=ar \
--nm=nm \
--sysinclude=${prefix}/include \
--pkg-config=$(which pkg-config) \
--pkg-config-flags=--static \
--prefix=$prefix \
--sysroot=/opt/${target}/${target}/sys-root \
--extra-libs=-lpthread \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--disable-static \
--enable-shared \
--enable-pic \
--disable-debug \
--disable-doc \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-encoders \
--enable-decoders \
--enable-muxers \
--enable-demuxers \
--enable-parsers \
--enable-openssl \
--disable-schannel \
--extra-cflags="-I${prefix}/include" \
--extra-ldflags="-L${libdir}" ${CUDA_ARGS} \
"${EXTRA_FLAGS[@]}"
make -j${nproc}
if [[ "${FFPLAY}" == "true" ]]; then
# Manually install only the FFplay binary
install -Dvm 755 "ffplay${exeext}" "${bindir}/ffplay${exeext}"
else
# Install all FFMPEG stuff: libraries, executables, header files, etc...
make install
fi
install_license LICENSE.md COPYING.*
"""
end
# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = supported_platforms()
# `libass_jll` is missing
filter!(p -> arch(p) != "armv6l", platforms)
# `libass_jll` is missing
filter!(p -> !(Sys.isfreebsd(p) && arch(p) == "aarch64"), platforms)
# `OpenSSL_jll` is missing
filter!(p -> arch(p) != "riscv64", platforms)
preferred_gcc_version = v"8"