FFmpeg-Builds/build.sh

106 lines
3.1 KiB
Bash
Raw Normal View History

2020-09-02 16:07:59 +00:00
#!/bin/bash
set -xe
shopt -s globstar
2020-09-02 16:07:59 +00:00
cd "$(dirname "$0")"
2020-09-02 23:03:23 +00:00
source util/vars.sh
2020-09-02 16:07:59 +00:00
get_output() {
(
SELF="$1"
source $1
2020-09-03 17:31:29 +00:00
if ffbuild_enabled; then
ffbuild_$2 || exit 0
else
ffbuild_un$2 || exit 0
fi
2020-09-02 16:07:59 +00:00
)
}
2020-09-02 23:03:23 +00:00
source "variants/${TARGET}-${VARIANT}.sh"
2020-09-02 16:07:59 +00:00
2020-09-27 21:11:10 +00:00
for addin in ${ADDINS[*]}; do
source "addins/${addin}.sh"
done
2020-09-05 14:25:25 +00:00
export FFBUILD_PREFIX="$(docker run --rm "$IMAGE" bash -c 'echo $FFBUILD_PREFIX')"
2020-09-04 15:05:12 +00:00
for script in scripts.d/**/*.sh; do
2020-09-03 20:49:43 +00:00
FF_CONFIGURE+=" $(get_output $script configure)"
FF_CFLAGS+=" $(get_output $script cflags)"
FF_CXXFLAGS+=" $(get_output $script cxxflags)"
FF_LDFLAGS+=" $(get_output $script ldflags)"
FF_LDEXEFLAGS+=" $(get_output $script ldexeflags)"
2020-09-06 19:55:59 +00:00
FF_LIBS+=" $(get_output $script libs)"
2020-09-02 16:07:59 +00:00
done
2020-09-03 20:49:43 +00:00
FF_CONFIGURE="$(xargs <<< "$FF_CONFIGURE")"
FF_CFLAGS="$(xargs <<< "$FF_CFLAGS")"
FF_CXXFLAGS="$(xargs <<< "$FF_CXXFLAGS")"
FF_LDFLAGS="$(xargs <<< "$FF_LDFLAGS")"
FF_LDEXEFLAGS="$(xargs <<< "$FF_LDEXEFLAGS")"
2020-09-06 19:55:59 +00:00
FF_LIBS="$(xargs <<< "$FF_LIBS")"
2020-09-03 18:08:50 +00:00
TESTFILE="uidtestfile"
rm -f "$TESTFILE"
docker run --rm -v "$PWD:/uidtestdir" "$IMAGE" touch "/uidtestdir/$TESTFILE"
DOCKERUID="$(stat -c "%u" "$TESTFILE")"
rm -f "$TESTFILE"
[[ "$DOCKERUID" != "$(id -u)" ]] && UIDARGS=( -u "$(id -u):$(id -g)" ) || UIDARGS=()
2020-09-02 23:03:23 +00:00
rm -rf ffbuild
mkdir ffbuild
2020-09-02 16:07:59 +00:00
2021-11-13 16:41:55 +00:00
FFMPEG_REPO="${FFMPEG_REPO:-https://github.com/FFmpeg/FFmpeg.git}"
FFMPEG_REPO="${FFMPEG_REPO_OVERRIDE:-$FFMPEG_REPO}"
GIT_BRANCH="${GIT_BRANCH:-master}"
GIT_BRANCH="${GIT_BRANCH_OVERRIDE:-$GIT_BRANCH}"
BUILD_SCRIPT="$(mktemp)"
trap "rm -f -- '$BUILD_SCRIPT'" EXIT
cat <<EOF >"$BUILD_SCRIPT"
2020-09-02 16:07:59 +00:00
set -xe
2020-09-02 23:03:23 +00:00
cd /ffbuild
rm -rf ffmpeg prefix
2020-09-02 16:07:59 +00:00
2021-11-13 16:41:55 +00:00
git clone --filter=blob:none --branch='$GIT_BRANCH' '$FFMPEG_REPO' ffmpeg
2020-09-02 16:07:59 +00:00
cd ffmpeg
2020-09-02 23:03:23 +00:00
./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS $FF_CONFIGURE \
--extra-cflags='$FF_CFLAGS' --extra-cxxflags='$FF_CXXFLAGS' \
--extra-ldflags='$FF_LDFLAGS' --extra-ldexeflags='$FF_LDEXEFLAGS' --extra-libs='$FF_LIBS' \
--extra-version="\$(date +%Y%m%d)"
make -j\$(nproc) V=1
make install install-doc
2020-09-02 16:07:59 +00:00
EOF
2020-09-02 23:03:23 +00:00
[[ -t 1 ]] && TTY_ARG="-t" || TTY_ARG=""
docker run --rm -i $TTY_ARG "${UIDARGS[@]}" -v $PWD/ffbuild:/ffbuild -v "$BUILD_SCRIPT":/build.sh "$IMAGE" bash /build.sh
2020-09-02 23:03:23 +00:00
mkdir -p artifacts
2020-09-03 15:42:23 +00:00
ARTIFACTS_PATH="$PWD/artifacts"
2020-09-30 12:34:34 +00:00
BUILD_NAME="ffmpeg-$(./ffbuild/ffmpeg/ffbuild/version.sh ffbuild/ffmpeg)-${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}"
2020-09-03 16:03:26 +00:00
2020-09-03 16:15:02 +00:00
mkdir -p "ffbuild/pkgroot/$BUILD_NAME"
2020-09-03 16:03:26 +00:00
package_variant ffbuild/prefix "ffbuild/pkgroot/$BUILD_NAME"
2020-09-02 23:03:23 +00:00
2021-08-26 06:31:30 +00:00
[[ -n "$LICENSE_FILE" ]] && cp "ffbuild/ffmpeg/$LICENSE_FILE" "ffbuild/pkgroot/$BUILD_NAME/LICENSE.txt"
2020-09-03 15:42:23 +00:00
cd ffbuild/pkgroot
if [[ "${TARGET}" == win* ]]; then
OUTPUT_FNAME="${BUILD_NAME}.zip"
zip -9 -r "${ARTIFACTS_PATH}/${OUTPUT_FNAME}" "$BUILD_NAME"
else
OUTPUT_FNAME="${BUILD_NAME}.tar.xz"
tar cJf "${ARTIFACTS_PATH}/${OUTPUT_FNAME}" "$BUILD_NAME"
fi
2020-09-03 15:42:23 +00:00
cd -
2020-09-02 23:05:56 +00:00
rm -rf ffbuild
2020-09-30 12:38:49 +00:00
if [[ -n "$GITHUB_ACTIONS" ]]; then
echo "build_name=${BUILD_NAME}" >> "$GITHUB_OUTPUT"
echo "${OUTPUT_FNAME}" > "${ARTIFACTS_PATH}/${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}.txt"
2020-09-30 12:38:49 +00:00
fi