forked from zhongfly/mpv-winbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
181 lines (159 loc) · 6.68 KB
/
build.sh
File metadata and controls
181 lines (159 loc) · 6.68 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
set -x
main() {
gitdir=$(pwd)
clang_root=$(pwd)/clang_root
buildroot=$(pwd)
srcdir=$(pwd)/src_packages
local target=$1
compiler=$2
simple_package=$3
prepare
if [ "$target" == "64-v4" ]; then
package "64-v4"
elif [ "$target" == "64-nvl" ]; then
package "64-nvl"
elif [ "$target" == "aarch64-armv9.2-a" ]; then
package "aarch64-armv9.2-a"
elif [ "$target" == "all" ]; then
package "64-v4"
package "64-nvl"
package "aarch64-armv9.2-a"
fi
rm -rf ./release/mpv-packaging-master
}
package() {
local bit=$1
if [ $bit == "64-v4" ]; then
local arch="x86_64"
local gcc_arch="-DMARCH=tigerlake"
local arch_level="-v4"
elif [ $bit == "64-nvl" ]; then
local arch="x86_64"
local gcc_arch="-DMARCH=novalake"
local arch_level="-nvl"
elif [ $bit == "aarch64-armv9.2-a" ]; then
local arch="aarch64"
local gcc_arch="-DMARCH=cortex-x925"
local arch_level="-armv9.2-a"
fi
build $bit $arch $gcc_arch $arch_level
zip $bit $arch $arch_level
sudo rm -rf $buildroot/build$bit/mpv-*
sudo chmod -R a+rwx $buildroot/build$bit
}
build() {
local bit=$1
local arch=$2
local gcc_arch=$3
local arch_level=$4
export PATH="/usr/local/fuchsia-clang/bin:$PATH"
wget https://github.com/Andarwinux/mpv-winbuild/releases/download/pgo/pgo.profdata
wget https://github.com/Andarwinux/mimalloc/raw/refs/heads/dev2/bin/minject.exe
if [ "$compiler" == "clang" ]; then
clang_option=(-DCMAKE_INSTALL_PREFIX=$clang_root -DMINGW_INSTALL_PREFIX=$buildroot/build$bit/install/$arch-w64-mingw32)
pgo_option=(-DCLANG_PACKAGES_PGO=USE -DCLANG_PACKAGES_PROFDATA_FILE="./pgo.profdata")
fi
if [ "$arch" == "x86_64" ]; then
if [ "$arch_level" == "-v4" ]; then
arch_option=(-DMARCH_NAME=-v4)
elif [ "$arch_level" == "-nvl" ]; then
arch_option=(-DMARCH_NAME=-nvl)
fi
else
arch_option=(-DMARCH_NAME="-armv9.2-a")
fi
cmake --fresh -DTARGET_ARCH=$arch-w64-mingw32 $gcc_arch -DCOMPILER_TOOLCHAIN=$compiler "${clang_option[@]}" "${pgo_option[@]}" "${arch_option[@]}" $extra_option -DENABLE_LEGACY_MPV=ON -DENABLE_CCACHE=ON -DQT_DISABLE_CCACHE=ON -DSINGLE_SOURCE_LOCATION=$srcdir -G Ninja -H$gitdir -B$buildroot/build$bit
ninja -C $buildroot/build$bit download || true
ninja -C $buildroot/build$bit update || true
ninja -C $buildroot/build$bit update
ninja -C $buildroot/build$bit mpv-fullclean
ninja -C $buildroot/build$bit download
ninja -C $buildroot/build$bit patch
ninja -C $buildroot/build$bit qbittorrent
ninja -C $buildroot/build$bit curl mediainfo mimalloc
ninja -C $buildroot/build$bit mpv mpv-menu-plugin mpv-debug-plugin mpc-qt
sudo wine ./minject.exe $buildroot/build$bit/mpv-*/mpv.exe --inplace -y
sudo wine ./minject.exe $buildroot/build$bit/mpv-*/mpv-legacy.exe --inplace -y
sudo wine ./minject.exe $buildroot/build$bit/install/$arch-w64-mingw32/bin/ffmpeg.exe --inplace -y
sudo wine ./minject.exe $buildroot/build$bit/install/$arch-w64-mingw32/bin/curl.exe --inplace -y
sudo wine ./minject.exe $buildroot/build$bit/install/$arch-w64-mingw32/bin/mujs.exe --inplace -y
sudo wine ./minject.exe $buildroot/build$bit/install/$arch-w64-mingw32/bin/mediainfo.exe --inplace -y
sudo wine ./minject.exe $buildroot/build$bit/install/$arch-w64-mingw32/bin/qbittorrent.exe --inplace -y
sudo wine ./minject.exe $buildroot/build$bit/install/$arch-w64-mingw32/bin/mpc-qt.exe --inplace -y
llvm-strip -s $buildroot/build$bit/mpv-*/mpv.exe
llvm-strip -s $buildroot/build$bit/mpv-*/mpv-legacy.exe
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/ffmpeg.exe
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/curl.exe
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/mujs.exe
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/mediainfo.exe
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/qbittorrent.exe
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/mpc-qt.exe
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/mimalloc.dll
llvm-strip -s $buildroot/build$bit/install/$arch-w64-mingw32/bin/vulkan-1.dll
if [ "$arch" == "x86_64" ]; then
cp $buildroot/build$bit/install/$arch-w64-mingw32/bin/mimalloc{-redirect,}.dll $buildroot/build$bit/mpv-$arch$arch_level*/
cp $buildroot/build$bit/install/$arch-w64-mingw32/bin/vulkan-1.dll $buildroot/build$bit/mpv-$arch$arch_level*/
elif [ "$arch" == "aarch64" ]; then
cp $buildroot/build$bit/install/$arch-w64-mingw32/bin/mimalloc{-redirect-arm64,}.dll $buildroot/build$bit/mpv-$arch$arch_level*/
cp $buildroot/build$bit/install/$arch-w64-mingw32/bin/vulkan-1.dll $buildroot/build$bit/mpv-$arch$arch_level*/
fi
if [ -n "$(find $buildroot/build$bit -maxdepth 1 -type d -name "mpv*$arch*" -print -quit)" ] ; then
echo "Successfully compiled $bit-bit. Continue"
else
echo "Failed compiled $bit-bit. Stop"
exit 1
fi
ninja -C $buildroot/build$bit ccache-recomp
}
zip() {
local bit=$1
local arch=$2
local arch_level=$3
mv $buildroot/build$bit/mpv-* $gitdir/release
if [ "$simple_package" != "true" ]; then
cd $gitdir/release/mpv-packaging-master
cp -r ./mpv-root/* ../mpv-$arch$arch_level*
fi
cd $gitdir/release
for dir in ./mpv*$arch$arch_level*; do
if [ -d $dir ]; then
7z a -m0=lzma2 -mx=9 -ms=on $dir.7z $dir/* -x!*.7z
rm -rf $dir
fi
done
cd ..
}
download_mpv_package() {
local package_url="https://codeload.github.com/AndarwinuxT/mpv-packaging/zip/master"
if [ -e mpv-packaging.zip ]; then
echo "Package exists. Check if it is newer.."
remote_commit=$(git ls-remote https://github.com/AndarwinuxT/mpv-packaging.git master | awk '{print $1;}')
local_commit=$(unzip -z mpv-packaging.zip | tail +2)
if [ "$remote_commit" != "$local_commit" ]; then
wget -qO mpv-packaging.zip $package_url
fi
else
wget -qO mpv-packaging.zip $package_url
fi
unzip -o mpv-packaging.zip
}
prepare() {
mkdir -p ./release
if [ "$simple_package" != "true" ]; then
cd ./release
download_mpv_package
cd ./mpv-packaging-master
cd ../..
fi
}
while getopts t:c:s:e: flag
do
case "${flag}" in
t) target=${OPTARG};;
c) compiler=${OPTARG};;
s) simple_package=${OPTARG};;
e) extra_option=${OPTARG};;
esac
done
main "${target:-all-64}" "${compiler:-gcc}" "${simple_package:-false}"