-
Notifications
You must be signed in to change notification settings - Fork 15
/
BuildVVC.sh
executable file
·131 lines (115 loc) · 3.06 KB
/
BuildVVC.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
#!/bin/bash
OS=$(uname)
DISTRO=""
# Detect Linux distribution
if [ "$OS" = "Linux" ]; then
if [ -f /etc/os-release ]; then
DISTRO=$(awk -F= '/^ID=/{print $2}' /etc/os-release)
fi
fi
echo "Martin Eesmaa / VVC Compiler (vvenc and vvdec)"
if [ "$OS" = "Linux" ]; then
echo "You're running on $OS with distribution $DISTRO of bash script version to compile VVC binaries"
else
echo "You're running on $OS of bash script version to compile VVC binaries"
fi
echo "Checking and installing required packages..."
setup_debian() {
sudo apt update && sudo apt upgrade -y
sudo apt install build-essential cmake git -y
}
setup_fedora() {
sudo dnf update -y
sudo dnf install cmake gcc gcc-c++ make git -y
}
setup_arch() {
sudo pacman -Syu --noconfirm
sudo pacman -S --noconfirm base-devel cmake git
}
setup_gentoo() {
sudo emerge --sync
sudo emerge cmake git
}
setup_macos() {
echo "Please make sure Xcode is installed in your Applications."
if ! command -v brew &> /dev/null; then
echo "Homebrew is not installed. Please install Homebrew and rerun the script."
exit 1
fi
if ! brew list | grep -q cmake; then
echo "Installing cmake..."
brew install cmake
fi
}
setup_msys64() {
pacman -Syu --noconfirm
pacman -S --noconfirm base-devel cmake git
}
setup_freebsd() {
pkg update && pkg upgrade -y
pkg install -y cmake git gmake
}
build_repos() {
for clone in vvenc vvdec; do
if [ ! -d $clone ]; then
git clone --depth=1 https://github.com/fraunhoferhhi/$clone
else
git -C $clone pull
fi
done
for REPO in vvenc vvdec; do
cd $REPO
mkdir -p build && cd build
if [ "$OS" = "Darwin" ]; then
CORES=$(sysctl -n hw.ncpu || echo 1)
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -j $CORES
else
CORES=$(nproc || echo 1)
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-static" ..
cmake --build . -j $CORES
fi
cd -
done
echo "Please see the build files starting with (vvenc/vvdec)/bin/release-static."
}
# Main script execution
case "$OS" in
Linux)
case "$DISTRO" in
debian|ubuntu)
setup_debian
;;
fedora)
setup_fedora
;;
arch)
setup_arch
;;
gentoo)
setup_gentoo
;;
*)
echo "Unsupported Linux distribution: $DISTRO"
exit 1
;;
esac
;;
Darwin)
setup_macos
;;
MSYS_NT*|MINGW64*)
setup_msys64
;;
FreeBSD)
setup_freebsd
;;
*)
echo "Unsupported OS: $OS"
echo "Supports Windows MSYS64, macOS, Linux & FreeBSD"
echo "May coming soon for some platforms..."
exit 1
;;
esac
build_repos
read -p "Finished building vvenc & vvdec. Press [Enter] to continue..."