2020-09-02 16:07:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -xe
|
2021-04-06 02:42:56 +00:00
|
|
|
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
|
|
|
|
2021-04-06 02:42:56 +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)"
|
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")"
|
2020-09-06 19:55:59 +00:00
|
|
|
FF_LIBS="$(xargs <<< "$FF_LIBS")"
|
2020-09-03 18:08:50 +00:00
|
|
|
|
2020-10-05 15:34:37 +00:00
|
|
|
TESTFILE="uidtestfile"
|
|
|
|
rm -f "$TESTFILE"
|
2021-05-12 17:50:12 +00:00
|
|
|
docker run --rm -v "$PWD:/uidtestdir" "$IMAGE" touch "/uidtestdir/$TESTFILE"
|
2020-10-05 15:34:37 +00:00
|
|
|
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
|
|
|
|
2020-10-05 15:34:37 +00:00
|
|
|
docker run --rm -i "${UIDARGS[@]}" -v $PWD/ffbuild:/ffbuild "$IMAGE" bash -s <<EOF
|
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
|
|
|
|
2020-09-23 10:08:43 +00:00
|
|
|
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
|
2020-09-02 16:07:59 +00:00
|
|
|
cd ffmpeg
|
2020-09-03 15:02:15 +00:00
|
|
|
git checkout $GIT_BRANCH
|
2020-09-02 23:03:23 +00:00
|
|
|
|
2021-05-13 15:35:45 +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-libs='$FF_LIBS'
|
|
|
|
make -j\$(nproc) V=1
|
2021-05-12 17:50:12 +00:00
|
|
|
make install install-doc
|
2020-09-02 16:07:59 +00:00
|
|
|
EOF
|
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
|
|
|
|
2020-09-03 15:42:23 +00:00
|
|
|
cd ffbuild/pkgroot
|
2021-05-12 17:50:12 +00:00
|
|
|
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 "::set-output name=build_name::${BUILD_NAME}"
|
2021-05-12 17:50:12 +00:00
|
|
|
echo "${OUTPUT_FNAME}" > "${ARTIFACTS_PATH}/${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}.txt"
|
2020-09-30 12:38:49 +00:00
|
|
|
fi
|