-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·93 lines (74 loc) · 2.52 KB
/
build.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
#!/bin/bash
set -e
shopt -s globstar
cd "$(dirname "$0")"
source util/vars.sh
get_output() {
(
SELF="$1"
source $1
if ffbuild_enabled; then
ffbuild_$2 || exit 0
else
ffbuild_un$2 || exit 0
fi
)
}
source "variants/${TARGET}-${VARIANT}.sh"
for addin in ${ADDINS[*]}; do
source "addins/${addin}.sh"
done
for script in scripts.d/**/*.sh; do
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_LIBS+=" $(get_output $script libs)"
done
FF_CONFIGURE="$(xargs <<< "$FF_CONFIGURE")"
FF_CFLAGS="$(xargs <<< "$FF_CFLAGS")"
FF_CXXFLAGS="$(xargs <<< "$FF_CXXFLAGS")"
FF_LDFLAGS="$(xargs <<< "$FF_LDFLAGS")"
FF_LIBS="$(xargs <<< "$FF_LIBS")"
if ! docker info --format '{{.SecurityOptions}}' | grep -qE '(^|\s)name=rootless($|\s)'; then
UIDARGS=(-u "$(id -u):$(id -g)")
fi
rm -rf ffbuild
mkdir ffbuild
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"
set -xe
cd /ffbuild
rm -rf ffmpeg prefix
git clone --filter=tree:0 --branch='$GIT_BRANCH' --single-branch '$FFMPEG_REPO' ffmpeg
cd ffmpeg
if [[ -n "$GITHUB_ACTIONS" ]]; then
git checkout "$FFMPEG_COMMIT"
fi
./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)
make install
EOF
[[ -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
mkdir -p artifacts
ARTIFACTS_PATH="$PWD/artifacts"
FFMPEG_VERSION="$(./ffbuild/ffmpeg/ffbuild/version.sh ffbuild/ffmpeg)"
BUILD_NAME="ffmpeg-${FFMPEG_VERSION//-g/-git-}-${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}"
mkdir -p "ffbuild/pkgroot/$BUILD_NAME"
package_variant ffbuild/prefix "ffbuild/pkgroot/$BUILD_NAME"
if [[ -n "$GITHUB_ACTIONS" ]]; then
cd ffbuild/pkgroot
tar -I 'zstdmt -9 --long' -cf "${ARTIFACTS_PATH}/${BUILD_NAME}.tar.zst" "$BUILD_NAME"
cd -
else
mv "ffbuild/pkgroot/$BUILD_NAME" "${ARTIFACTS_PATH}"
fi
rm -rf ffbuild