-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathparse-arguments.sh
executable file
·164 lines (155 loc) · 4.27 KB
/
parse-arguments.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
#!/usr/bin/env bash
# This script parses arguments that were passed to ffmpeg-android-maker.sh
# and exports a bunch of varables that are used elsewhere.
# Local variables with default values (except ABIS_TO_BUILD).
# Can be overridden with specific arguments.
# See the end of this file for more description.
ABIS_TO_BUILD=()
API_LEVEL=21
SOURCE_TYPE=TAR
SOURCE_VALUE=7.1.1
EXTERNAL_LIBRARIES=()
FFMPEG_GPL_ENABLED=false
# All FREE libraries that are supported
SUPPORTED_LIBRARIES_FREE=(
"libaom"
"libdav1d"
"libmp3lame"
"libopus"
"libtwolame"
"libspeex"
"libvpx"
"libwebp"
"libfreetype"
"libfribidi"
"mbedtls"
"libbluray"
"libxml2"
)
# All GPL libraries that are supported
SUPPORTED_LIBRARIES_GPL=(
"libx264"
"libx265"
)
for argument in "$@"; do
case $argument in
# Build for only specified ABIs (separated by comma)
--target-abis=* | -abis=*)
IFS=',' read -ra ABIS <<<"${argument#*=}"
for abi in "${ABIS[@]}"; do
case $abi in
x86 | x86_64 | armeabi-v7a | arm64-v8a)
ABIS_TO_BUILD+=("$abi")
;;
arm)
ABIS_TO_BUILD+=("armeabi-v7a")
;;
arm64)
ABIS_TO_BUILD+=("arm64-v8a")
;;
*)
echo "Unknown ABI: $abi"
;;
esac
done
;;
# Use this value as Android platform version during compilation.
--android-api-level=* | -android=*)
API_LEVEL="${argument#*=}"
;;
# Checkout the particular tag in the FFmpeg's git repository
--source-git-tag=*)
SOURCE_TYPE=GIT_TAG
SOURCE_VALUE="${argument#*=}"
;;
# Checkout the particular branch in the FFmpeg's git repository
--source-git-branch=*)
SOURCE_TYPE=GIT_BRANCH
SOURCE_VALUE="${argument#*=}"
;;
# Download the particular tar archive by its version
--source-tar=*)
SOURCE_TYPE=TAR
SOURCE_VALUE="${argument#*=}"
;;
# Arguments below enable certain external libraries to build into FFmpeg
--enable-libaom | -aom)
EXTERNAL_LIBRARIES+=("libaom")
;;
--enable-libdav1d | -dav1d)
EXTERNAL_LIBRARIES+=("libdav1d")
;;
--enable-libmp3lame | -mp3lame | -lame)
EXTERNAL_LIBRARIES+=("libmp3lame")
;;
--enable-libopus | -opus)
EXTERNAL_LIBRARIES+=("libopus")
;;
--enable-libwebp | -webp)
EXTERNAL_LIBRARIES+=("libwebp")
;;
--enable-libwavpack | -wavpack)
EXTERNAL_LIBRARIES+=("libwavpack")
;;
--enable-libtwolame | -twolame)
EXTERNAL_LIBRARIES+=("libtwolame")
;;
--enable-libspeex | -speex)
EXTERNAL_LIBRARIES+=("libspeex")
;;
--enable-libvpx | -vpx)
EXTERNAL_LIBRARIES+=("libvpx")
;;
--enable-libfreetype | -freetype)
EXTERNAL_LIBRARIES+=("libfreetype")
;;
--enable-libfribidi | -fribidi)
EXTERNAL_LIBRARIES+=("libfribidi")
;;
--enable-libx264 | -x264)
EXTERNAL_LIBRARIES+=("libx264")
FFMPEG_GPL_ENABLED=true
;;
--enable-libx265 | -x265)
EXTERNAL_LIBRARIES+=("libx265")
FFMPEG_GPL_ENABLED=true
;;
--enable-mbedtls | -mbedtls)
EXTERNAL_LIBRARIES+=("mbedtls")
;;
--enable-libbluray | -bluray)
EXTERNAL_LIBRARIES+=("libbluray")
;;
--enable-libxml2 | -xml2)
EXTERNAL_LIBRARIES+=("libxml2")
;;
--enable-all-free | -all-free)
EXTERNAL_LIBRARIES+=" ${SUPPORTED_LIBRARIES_FREE[@]}"
;;
--enable-all-gpl | -all-gpl)
EXTERNAL_LIBRARIES+=" ${SUPPORTED_LIBRARIES_GPL[@]}"
FFMPEG_GPL_ENABLED=true
;;
*)
echo "Unknown argument $argument"
;;
esac
shift
done
# if ABIS_TO_BUILD list is empty, then fill it with all supported ABIs
# The x86 is the first, because it is more likely to have Text Relocations.
# In this case the rest ABIs will not be assembled at all.
if [ ${#ABIS_TO_BUILD[@]} -eq 0 ]; then
ABIS_TO_BUILD=("x86" "x86_64" "armeabi-v7a" "arm64-v8a")
fi
# The FFmpeg will be build for ABIs in this list
export FFMPEG_ABIS_TO_BUILD=${ABIS_TO_BUILD[@]}
# Saving the information FFmpeg's source code downloading
export FFMPEG_SOURCE_TYPE=$SOURCE_TYPE
export FFMPEG_SOURCE_VALUE=$SOURCE_VALUE
# A list of external libraries to build into the FFmpeg
# Elements from this list are used for strings substitution
export FFMPEG_EXTERNAL_LIBRARIES=${EXTERNAL_LIBRARIES[@]}
# Desired Android API level to use during compilation
# Will be replaced with 21 for 64bit ABIs if the value is less than 21
export DESIRED_ANDROID_API_LEVEL=${API_LEVEL}