-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathheader.sh
147 lines (125 loc) · 3.1 KB
/
header.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
138
139
140
141
142
143
144
145
146
#!/bin/bash
# Caution: this script is for ubuntu 16.04 or newer
# This script does nothing; it's the header of all others build-plugins scripts.
# on the form plugin-*.sh
set -e
. ../config.txt
export CFLAGS="-pipe -O3 -Wno-attributes -fPIC -fvisibility=hidden -fno-strict-aliasing $(pkg-config --cflags vapoursynth) -I/usr/include/compute"
export CXXFLAGS="$CFLAGS -Wno-reorder"
export LDFLAGS="-L$VSPREFIX/lib"
max_attempts=3
retry_git_clone() {
local repo_url="$1"
local target_dir="$2"
local attempts=0
while true; do
if [ "$attempts" -ge "$max_attempts" ]; then
echo "Maximum number of clone attempts reached. Exiting."
exit 1
fi
if [ -n "$target_dir" ]; then
if git clone --depth 1 --recursive "$repo_url.git" "$target_dir"; then
break
else
attempts=$((attempts +1))
echo "clone attempt $attempts failed. Retrying in 5 seconds..."
sleep 5
fi
else
if git clone --depth 1 --recursive "$repo_url.git"; then
break
else
attempts=$((attempts +1))
echo "clone attempt $attempts failed. Retrying in 5 seconds..."
sleep 5
fi
fi
done
}
install_nnedi3_weights ()
{
p="$VSPREFIX/vsplugins"
f="$p/nnedi3_weights.bin"
sum="27f382430435bb7613deb1c52f3c79c300c9869812cfe29079432a9c82251d42"
if [ ! -f $f ] || [ "$(sha256sum -b $f | head -c64)" != "$sum" ]; then
mkdir -p $p
rm -f $f
wget -O $f https://github.com/dubhater/vapoursynth-nnedi3/raw/master/src/nnedi3_weights.bin
fi
}
ghdl ()
{
retry_git_clone https://github.com/$1 build
cd build
}
strip_copy ()
{
chmod a-x $1
strip $1
nm -D --extern-only $1 | grep -q 'T VapourSynthPluginInit'
mkdir -p "$VSPREFIX/vsplugins"
cp -f $1 $VSPREFIX/vsplugins/
}
finish ()
{
strip_copy $1
cd ..
rm -rf _build
}
build ()
{
if [ -f meson.build ]; then
meson setup build
ninja -C build -j$JOBS
elif [ -f waf ]; then
python3 ./waf configure
python3 ./waf build -j$JOBS
else
if [ ! -e configure -a -f configure.ac ]; then
autoreconf -if
fi
if [ -e configure ]; then
chmod a+x configure
if grep -q -- '--extra-cflags' configure && grep -q -- '--extra-cxxflags' configure ; then
./configure --extra-cflags="$CFLAGS" --extra-cxxflags="$CXXFLAGS" --extra-ldflags="$LDFLAGS" || cat config.log
elif grep -q -- '--extra-cflags' configure ; then
./configure --extra-cflags="$CFLAGS" --extra-ldflags="$LDFLAGS" || cat config.log
elif grep -q -- '--extra-cxxflags' configure ; then
./configure --extra-cxxflags="$CXXFLAGS" --extra-ldflags="$LDFLAGS" || cat config.log
else
./configure || cat config.log
fi
fi
make -j$JOBS X86=1
fi
if [ -e .libs/${1}.so ]; then
finish .libs/${1}.so
elif [ -e build/${1}.so ]; then
finish build/${1}.so
else
finish ${1}.so
fi
}
mkgh ()
{
ghdl $1
build $2
}
mkghv ()
{
ghdl $1
cd vapoursynth
build $2
}
ghc ()
{
retry_git_clone https://github.com/$1 build
cd build
git -c advice.detachedHead=false checkout $2
git reset --hard
}
mkghc ()
{
ghc $1 $3
build $2
}