Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·145 lines (125 loc) · 6.17 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·145 lines (125 loc) · 6.17 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
ROOT_DIR="$(pwd)"
ARCHS="arm64 x86_64"
SOURCES_DIR="${ROOT_DIR}/sources"
BUILD_DIR="${ROOT_DIR}/build"
INSTALL_DIR="${ROOT_DIR}/install"
# ---------------------------------------------------------------------------
# Argument parsing
# ---------------------------------------------------------------------------
ARCH_FILTER="${1:-all}" # "all", "arm64", or "x86_64"
[ $# -gt 0 ] && shift # guarded: bare `shift` returns non-zero and trips `set -e`
PACKAGE_FILTER="$*" # optional: one or more package names (e.g. "ffmpeg mpv")
if [ "$ARCH_FILTER" != "all" ] && [ "$ARCH_FILTER" != "arm64" ] && [ "$ARCH_FILTER" != "x86_64" ]; then
echo "Usage: $0 [all|arm64|x86_64] [package ...]" >&2
exit 1
fi
if [ "$ARCH_FILTER" != "all" ]; then
ARCHS="$ARCH_FILTER"
fi
# Export so child build-*.sh inherit the filtered list, not common.sh's default.
export ARCHS
# ---------------------------------------------------------------------------
# Check required build tools
# ---------------------------------------------------------------------------
check_tool() {
command -v "$1" >/dev/null 2>&1 || { echo "ERROR: $1 not found" >&2; exit 1; }
}
check_tool meson
check_tool ninja
check_tool nasm
check_tool cmake
check_tool pkg-config
check_tool perl
check_tool aclocal
# ---------------------------------------------------------------------------
# Create directory tree
# ---------------------------------------------------------------------------
# For full build, install folder is cleared before building
if [ -z "$PACKAGE_FILTER" ]; then
for arch in $ARCHS; do
rm -rf "${INSTALL_DIR}/${arch}"
done
fi
mkdir -p "$SOURCES_DIR" "$BUILD_DIR"
for arch in $ARCHS; do
mkdir -p "${INSTALL_DIR}/${arch}"
done
# ---------------------------------------------------------------------------
# Build helper
# ---------------------------------------------------------------------------
_BOLD="\033[1m"
_CYAN="\033[36m"
_GREEN="\033[32m"
_RESET="\033[0m"
if [ -n "$PACKAGE_FILTER" ]; then
_PACKAGE_TOTAL=$(echo "$PACKAGE_FILTER" | wc -w | tr -d ' ')
else
_PACKAGE_TOTAL=$(grep -c '^run buildscripts/build-' "$0")
fi
_PACKAGE_COUNT=0
_START_TIME=$SECONDS
# run <script> — skips if PACKAGE_FILTER is set and doesn't match the package name
run() {
local script="$1"
local name="${script#buildscripts/build-}" # strip leading path and "build-"
name="${name%.sh}" # strip .sh
if [ -n "$PACKAGE_FILTER" ]; then
case " $PACKAGE_FILTER " in
*" $name "*) ;;
*) return 0 ;;
esac
fi
_PACKAGE_COUNT=$(( _PACKAGE_COUNT + 1 ))
printf "\n${_BOLD}${_CYAN}╔══ [%d/%d] %s${_RESET}\n" \
"$_PACKAGE_COUNT" "$_PACKAGE_TOTAL" "$name" >&2
rm -rf "${BUILD_DIR}/${name}"
bash "$script"
printf "${_BOLD}${_GREEN}╚══ done: %s${_RESET}\n\n\n" "$name" >&2
}
# ---------------------------------------------------------------------------
# Build in dependency order (Layer 1 → 4)
# ---------------------------------------------------------------------------
# --- Layer 1: Leaf libraries + encoders/decoders ---
run buildscripts/build-freetype.sh # font rendering
run buildscripts/build-fribidi.sh # unicode bidirectional algorithm
run buildscripts/build-libunibreak.sh # unicode line/work break algorithm
run buildscripts/build-luajit.sh # lua compiler required by mpv scripting
run buildscripts/build-mujs.sh # javascript interpreter, used by mpv scripting
run buildscripts/build-uchardet.sh # character encoding detector, used by mpv
run buildscripts/build-little-cms2.sh # ICC color profile library
run buildscripts/build-libudfread.sh # UDF filesystem reader required by libbluray
run buildscripts/build-lz4.sh # compression algorithm used by libarchive
run buildscripts/build-zstd.sh # compression algorithm used by libarchive
run buildscripts/build-zimg.sh # image scaling algorithm used by mpv's zscale filter
run buildscripts/build-openssl.sh # TLS backend for FFmpeg (https, including TLS 1.3); linked statically
run buildscripts/build-libbs2b.sh # binaural audio filter
run buildscripts/build-libsoxr.sh # high-quality resampling
## encoders
run buildscripts/build-jpeg-turbo.sh # provides libjpeg, used by mpv to encode jpeg screenshots
run buildscripts/build-libwebp.sh # WebP screenshots
run buildscripts/build-svt-av1.sh # AV1 encoder for AVIF screenshot
run buildscripts/build-libjxl.sh # JPEG XL screenshots; uses bundled brotli, highway, lcms2
## decoders
run buildscripts/build-dav1d.sh # AV1 decoder
run buildscripts/build-speex.sh # Speex audio format decoding support
run buildscripts/build-libogg.sh # base library for Ogg bitstream format
run buildscripts/build-libvorbis.sh # Ogg Vorbis audio decoder; depends on libogg
run buildscripts/build-libaribcaption.sh # ARIB STD-B24 caption decoder (Japanese broadcast subtitles); uses CoreText
# --- Layer 2: Libraries with Layer 1 dependencies ---
run buildscripts/build-harfbuzz.sh # text shaping engine; depends on freetype
run buildscripts/build-fontconfig.sh # font configuration and matching; depends on freetype
run buildscripts/build-libarchive.sh # reading archive files used by mpv; depends on lz4, zstd
run buildscripts/build-rubberband.sh # audio pitch/tempo, used by both mpv and FFmpeg
run buildscripts/build-libssh.sh # SSH/SFTP client for FFmpeg's sftp:// protocol; depends on openssl
# --- Layer 3: Core media libraries ---
run buildscripts/build-libbluray.sh # depends on fontconfig, freetype, libudfread
run buildscripts/build-libplacebo.sh # depends on little-cms2
run buildscripts/build-libass.sh # depends on freetype, fribidi, harfbuzz, fontconfig, libunibreak
run buildscripts/build-ffmpeg.sh # depends on all Layer 1+2 libs above
# --- Layer 4: mpv ---
run buildscripts/build-mpv.sh
_ELAPSED=$(( SECONDS - _START_TIME ))
echo "Built ${_PACKAGE_COUNT}/${_PACKAGE_TOTAL} packages in $(( _ELAPSED / 60 ))m $(( _ELAPSED % 60 ))s. Installed to ${INSTALL_DIR}/<arch>/"