mirror of
https://github.com/levogevo/ffmpeg-builder.git
synced 2026-01-15 19:06:17 +00:00
fix build chains
This commit is contained in:
40
lib/build.sh
40
lib/build.sh
@@ -381,20 +381,21 @@ do_build() {
|
|||||||
# save the metadata for a build to skip re-building identical builds
|
# save the metadata for a build to skip re-building identical builds
|
||||||
local oldMetadataFile="${TMP_DIR}/${build}-old-metadata"
|
local oldMetadataFile="${TMP_DIR}/${build}-old-metadata"
|
||||||
local newMetadataFile="${TMP_DIR}/${build}-new-metadata"
|
local newMetadataFile="${TMP_DIR}/${build}-new-metadata"
|
||||||
|
local ffmpegOldMetadataFile="${TMP_DIR}/ffmpeg-old-metadata"
|
||||||
|
|
||||||
# add build function, version, url, and top-level env to metadata
|
# add build function, version, url, and top-level env to metadata
|
||||||
type "build_${build}" >"${oldMetadataFile}"
|
type "build_${build}" >"${newMetadataFile}"
|
||||||
echo "ver: ${ver}" >>"${oldMetadataFile}"
|
echo "ver: ${ver}" >>"${newMetadataFile}"
|
||||||
echo "url: ${url}" >>"${oldMetadataFile}"
|
echo "url: ${url}" >>"${newMetadataFile}"
|
||||||
for envName in "${BUILD_ENV_NAMES[@]}"; do
|
for envName in "${BUILD_ENV_NAMES[@]}"; do
|
||||||
COLOR=OFF dump_arr "${envName}" >>"${oldMetadataFile}"
|
COLOR=OFF dump_arr "${envName}" >>"${newMetadataFile}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# only ffmpeg cares about ENABLE and has special function
|
# only ffmpeg cares about ENABLE and has special function
|
||||||
if [[ ${build} == 'ffmpeg' ]]; then
|
if [[ ${build} == 'ffmpeg' ]]; then
|
||||||
# shellcheck disable=SC2153
|
# shellcheck disable=SC2153
|
||||||
echo "ENABLE=${ENABLE}" >>"${oldMetadataFile}"
|
echo "ENABLE=${ENABLE}" >>"${newMetadataFile}"
|
||||||
type add_project_versioning_to_ffmpeg >>"${oldMetadataFile}"
|
type add_project_versioning_to_ffmpeg >>"${newMetadataFile}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# prepare build
|
# prepare build
|
||||||
@@ -403,14 +404,14 @@ do_build() {
|
|||||||
for patch in "${PATCHES_DIR}/${build}"/*.patch; do
|
for patch in "${PATCHES_DIR}/${build}"/*.patch; do
|
||||||
test -f "${patch}" || continue
|
test -f "${patch}" || continue
|
||||||
echo_if_fail patch -p1 -i "${patch}" || return 1
|
echo_if_fail patch -p1 -i "${patch}" || return 1
|
||||||
echo "patch:${patch}" >>"${oldMetadataFile}"
|
echo "patch:${patch}" >>"${newMetadataFile}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# rebuild if metadata is different
|
# rebuild if new metadata is different
|
||||||
local oldMetadata="$(<"${oldMetadataFile}")"
|
local newMetadata="$(<"${newMetadataFile}")"
|
||||||
local newMetadata=''
|
local oldMetadata=''
|
||||||
test -f "${newMetadataFile}" && newMetadata="$(<"${newMetadataFile}")"
|
test -f "${oldMetadataFile}" && oldMetadata="$(<"${oldMetadataFile}")"
|
||||||
if [[ ${oldMetadata} != "${newMetadata}" ]]; then
|
if [[ ${oldMetadata} != "${newMetadata}" || -n ${REQUIRES_REBUILD} ]]; then
|
||||||
echo_info -n "building ${build} "
|
echo_info -n "building ${build} "
|
||||||
# build in background
|
# build in background
|
||||||
local timeBefore=${EPOCHSECONDS}
|
local timeBefore=${EPOCHSECONDS}
|
||||||
@@ -429,13 +430,20 @@ do_build() {
|
|||||||
popd >/dev/null || return 1
|
popd >/dev/null || return 1
|
||||||
test ${retval} -eq 0 || return ${retval}
|
test ${retval} -eq 0 || return ${retval}
|
||||||
echo_pass "built ${build} in $((EPOCHSECONDS - timeBefore)) seconds"
|
echo_pass "built ${build} in $((EPOCHSECONDS - timeBefore)) seconds"
|
||||||
|
|
||||||
|
# set new to old for later builds
|
||||||
|
cp "${newMetadataFile}" "${oldMetadataFile}"
|
||||||
|
|
||||||
|
# force ffmpeg to rebuild since one of the libraries has changed
|
||||||
|
if [[ ${build} != 'ffmpeg' && -f ${ffmpegOldMetadataFile} ]]; then
|
||||||
|
rm "${ffmpegOldMetadataFile}"
|
||||||
|
fi
|
||||||
|
# indicate that build chain will require rebuild
|
||||||
|
REQUIRES_REBUILD=1
|
||||||
else
|
else
|
||||||
popd >/dev/null || return 1
|
popd >/dev/null || return 1
|
||||||
echo_info "re-using identical previous build for ${build}"
|
echo_info "re-using identical previous build for ${build}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update build metadata
|
|
||||||
cp "${oldMetadataFile}" "${newMetadataFile}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FB_FUNC_NAMES+=('build')
|
FB_FUNC_NAMES+=('build')
|
||||||
@@ -446,6 +454,8 @@ build() {
|
|||||||
|
|
||||||
for build in ${ENABLE}; do
|
for build in ${ENABLE}; do
|
||||||
do_build "${build}" || return 1
|
do_build "${build}" || return 1
|
||||||
|
# reset whether build chain requires a rebuild
|
||||||
|
unset REQUIRES_REBUILD
|
||||||
done
|
done
|
||||||
do_build ffmpeg || return 1
|
do_build ffmpeg || return 1
|
||||||
local ffmpegBin="${PREFIX}/bin/ffmpeg"
|
local ffmpegBin="${PREFIX}/bin/ffmpeg"
|
||||||
|
|||||||
@@ -218,6 +218,10 @@ is_darwin() {
|
|||||||
line_contains "$(print_os)" darwin
|
line_contains "$(print_os)" darwin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_windows() {
|
||||||
|
line_contains "$(print_os)" windows
|
||||||
|
}
|
||||||
|
|
||||||
print_os() {
|
print_os() {
|
||||||
# cached response
|
# cached response
|
||||||
if [[ -n ${FB_OS} ]]; then
|
if [[ -n ${FB_OS} ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user