mirror of
https://github.com/levogevo/ffmpeg-builder.git
synced 2026-01-15 19:06:17 +00:00
fix add_project_versioning_to_ffmpeg
This commit is contained in:
39
lib/build.sh
39
lib/build.sh
@@ -570,35 +570,40 @@ build_libc() (
|
||||
)
|
||||
add_project_versioning_to_ffmpeg() {
|
||||
local optFile
|
||||
optFile="$(command ls ./**/ffmpeg_opt.c)"
|
||||
local fname='ffmpeg_opt.c'
|
||||
optFile="$(command ls ./**/"${fname}")"
|
||||
if [[ ! $? -eq 0 || ${optFile} == '' || ! -f ${optFile} ]]; then
|
||||
echo_fail "could not find ffmpeg_opt.c to add project versioning"
|
||||
echo_fail "could not find ${fname} to add project versioning"
|
||||
fi
|
||||
|
||||
local lineNum=0
|
||||
local searchFor='Universal media converter\n'
|
||||
local foundUsageStart=0
|
||||
local newOptFile="${TMP_DIR}/${fname}"
|
||||
test -f "${newOptFile}" && rm "${newOptFile}"
|
||||
while read -r line; do
|
||||
lineNum=$((lineNum + 1))
|
||||
if line_contains "${line}" "${searchFor}"; then
|
||||
foundUsageStart=1
|
||||
continue
|
||||
fi
|
||||
# if we found the line previously, add the versioning
|
||||
if [[ ${foundUsageStart} -eq 1 ]]; then
|
||||
if line_starts_with "${line}" '}'; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done <"${optFile}"
|
||||
|
||||
echo_info "found ${line} on ${lineNum}"
|
||||
for info in "${FFMPEG_BUILDER_INFO[@]}"; do
|
||||
local newline=" av_log(NULL, AV_LOG_INFO, \"${info}\n\");"
|
||||
insert_line "${newline}" "${lineNum}" "${optFile}" || return 1
|
||||
local newline="av_log(NULL, AV_LOG_INFO, \"${info}\n\");"
|
||||
echo "${newline}" >>"${newOptFile}"
|
||||
lineNum=$((lineNum + 1))
|
||||
done
|
||||
newline=" av_log(NULL, AV_LOG_INFO, \"\n\");"
|
||||
insert_line "${newline}" "${lineNum}" "${optFile}" || return 1
|
||||
newline="av_log(NULL, AV_LOG_INFO, \"\n\");"
|
||||
echo "${newline}" >>"${newOptFile}"
|
||||
foundUsageStart=0
|
||||
fi
|
||||
fi
|
||||
# find the line we are searching for
|
||||
if line_contains "${line}" "${searchFor}"; then
|
||||
foundUsageStart=1
|
||||
fi
|
||||
# start building the new file
|
||||
echo "${line}" >>"${newOptFile}"
|
||||
done <"${optFile}"
|
||||
|
||||
cp "${newOptFile}" "${optFile}" || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -162,16 +162,3 @@ line_starts_with() {
|
||||
is_darwin() {
|
||||
line_contains "$(print_os)" darwin
|
||||
}
|
||||
|
||||
insert_line() {
|
||||
local line="$1"
|
||||
local lineNum="$2"
|
||||
local file="$3"
|
||||
ed -s "${file}" <<EOF
|
||||
${lineNum}i
|
||||
${line}
|
||||
.
|
||||
w
|
||||
q
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ check_compile_opts_override() {
|
||||
declare -n defOptVal="DEFAULT_${opt}"
|
||||
declare -n optVal="${opt}"
|
||||
# use given value if not overridden
|
||||
if [[ -n ${optVal} && ${optVal} != "${defOptVal}" ]]; then
|
||||
if [[ -v optVal && ${optVal} != "${defOptVal}" ]]; then
|
||||
echo_info "setting given value for ${opt}=${optVal}"
|
||||
declare -g "${opt}=${optVal}"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user