forked from ezEngine/ezEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerate.sh
executable file
·113 lines (93 loc) · 2.97 KB
/
Generate.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
#!/bin/bash -e
# read arguments
opts=$(getopt \
--longoptions help,clang,setup,no-cmake,build-type: \
--name "$(basename "$0")" \
--options "" \
-- "$@"
)
eval set --$opts
RunCMake=true
BuildType="Dev"
while [[ $# -gt 0 ]]; do
case "$1" in
--help)
echo "Usage: $(basename $0) [--setup] [--clang] [--no-cmake] [--build-type Debug|Dev|Shipping]"
echo " --setup Run first time setup. This installs dependencies and makes sure the git repository is setup correctly."
echo " --clang Use clang instead of gcc"
echo " --no-cmake Do not invoke cmake (usefull when only --setup is needed)"
echo " --build-type Which build type cmake should be invoked with Debug|Dev|Shipping"
exit 0
;;
--clang)
UseClang=true
shift 1
;;
--setup)
Setup=true
shift 1
;;
--no-cmake)
RunCMake=false
shift 1
;;
--build-type)
BuildType=$2
shift 2
;;
*)
break
;;
esac
done
if [ "$BuildType" != "Debug" -a "$BuildType" != "Dev" -a "$BuildType" != "Release" ]; then
>&2 echo "The build-type '${BuildType}' is not supported. Only Debug, Dev and Release are supported values."
exit 1
fi
if [ ! -f "/etc/issue" ]; then
>&2 echo "/etc/issue does not exist. Failed distribution detection"
exit 1
fi
Issue=$(cat /etc/issue)
UbuntuPattern="Ubuntu ([0-9][0-9])"
MintPattern="Linux Mint ([0-9][0-9])"
if [[ $Issue =~ $UbuntuPattern ]]; then
Distribution="Ubuntu"
Version=${BASH_REMATCH[1]}
elif [[ $Issue =~ $MintPattern ]]; then
Distribution="Mint"
Version=${BASH_REMATCH[1]}
fi
if [ "$Distribution" = "Ubuntu" -a "$Version" = "22" ] || [ "$Distribution" = "Mint" -a "$Version" = "21" ] ; then
packages=(cmake build-essential ninja-build qtbase5-dev libqt5svg5-dev libqt5x11extras5-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev uuid-dev qtbase5-private-dev mold libfreetype-dev libtinfo5)
if [ "$UseClang" = true ]; then
packages+=(clang-14 libstdc++-12-dev)
c_compiler=clang-14
cxx_compiler=clang++-14
else
packages+=(gcc-12 g++-12)
c_compiler=gcc-12
cxx_compiler=g++-12
fi
else
>&2 echo "Your Distribution or Distribution version is not supported by this script"
>&2 echo "Currently supported are:"
>&2 echo " * Ubuntu 22"
>&2 echo " * Linux Mint 21"
exit 1
fi
if [ "$Setup" = true ]; then
git submodule update --init
echo "Attempting to install the following packages through the package manager:"
echo ${packages[@]}
sudo apt install ${packages[@]}
fi
CompilerShort=gcc
if [ "$UseClang" = true ]; then
CompilerShort=clang
fi
if [ "$RunCMake" = true ]; then
BuildDir="build-${BuildType}-${CompilerShort}"
cmake -B $BuildDir -S . -G Ninja -DCMAKE_CXX_COMPILER=$cxx_compiler -DCMAKE_C_COMPILER=$c_compiler -DEZ_EXPERIMENTAL_EDITOR_ON_LINUX=ON -DEZ_BUILD_EXPERIMENTAL_VULKAN=ON -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
echo -e "\nRun 'ninja -C ${BuildDir}' to build"
fi