generated from zhongfly/mpv-winbuild
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
137 lines (123 loc) · 3.7 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
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
#!/bin/bash
set -x
main() {
gitdir=$(pwd)
buildroot=$(pwd)
srcdir=$(pwd)/src_packages
prepare
if [ "$1" == "32" ]; then
package "32"
elif [ "$1" == "64" ]; then
package "64"
elif [ "$1" == "64-v3" ]; then
package "64-v3"
elif [ "$1" == "all-64" ]; then
package "64"
package "64-v3"
else [ "$1" == "all" ];
package "32"
package "64"
package "64-v3"
fi
rm -rf ./release/mpv-packaging-master
}
package() {
local bit=$1
if [ $bit == "32" ]; then
local arch="i686"
elif [ $bit == "64" ]; then
local arch="x86_64"
elif [ $bit == "64-v3" ]; then
local arch="x86_64"
local gcc_arch="-DGCC_ARCH=x86-64-v3"
local x86_64_level="-v3"
fi
build $bit $arch $gcc_arch
zip $bit $arch $x86_64_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
declare -r target="$arch-w64-mingw32"
cmake -DTARGET_ARCH="$target" $gcc_arch -DALWAYS_REMOVE_BUILDFILES=ON -DSINGLE_SOURCE_LOCATION=$srcdir -DRUSTUP_LOCATION=$buildroot/install_rustup -G Ninja -H$gitdir -B$buildroot/build$bit
for i in vulkan vulkan-header libjxl libssh libopenmpt libzimg libplacebo libsrt mpv; do
ninja -C $buildroot/build$bit "$i-fullclean" || true
done
for (( i = 0 ; i < 3 ; i++ )); do
ninja -C $buildroot/build$bit download && break
sleep 10s
done
if [ ! -x "$buildroot/build$bit/install/bin/$target-c++" ]; then
declare -i i=0
while :; do
if ninja -C $buildroot/build$bit gcc; then
break
elif [ "$i" -ge "2" ]; then
exit 1
fi
sleep 10s
((i++))
done
fi
if [[ ! "$(ls -A $buildroot/install_rustup/.cargo/bin)" ]]; then
ninja -C $buildroot/build$bit rustup-fullclean
ninja -C $buildroot/build$bit rustup
fi
for (( i = 0 ; i < 3 ; i++ )); do
ninja -C $buildroot/build$bit update && break
sleep 10s
done
ninja -C $buildroot/build$bit ffmpeg || true
ninja -C $buildroot/build$bit mpv
if [ -d $buildroot/build$bit/mpv-$arch* ] ; then
echo "Successfully compiled $bit-bit. Continue"
else
echo "Failed compiled $bit-bit. Stop"
exit 1
fi
ninja -C $buildroot/build$bit cargo-clean
}
zip() {
local bit=$1
local arch=$2
local x86_64_level=$3
rm -rf $buildroot/build$bit/mpv-debug-*
mv $buildroot/build$bit/mpv-* $gitdir/release
cd ./release/mpv-packaging-master
cp -r ./mpv-root/* ./$arch/d3dcompiler_43.dll ../mpv-$arch$x86_64_level*
cd ..
for dir in ./mpv*$arch$x86_64_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/shinchiro/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/shinchiro/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
cd ./release
download_mpv_package
cd ./mpv-packaging-master
7z x -y ./d3dcompiler*.7z
rm -f ./mpv-root/updater.bat ./mpv-root/installer/updater.ps1
cd ../..
}
main "$1"