-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure.sh
executable file
·175 lines (160 loc) · 5.99 KB
/
configure.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
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
#!/usr/bin/env bash
set -e
BASEDIR=$PWD
BUILD_TYPE=Release
VULKAN_LIBRARY=""
VULKAN_INCLUDE_PATH=""
TRACE_BUILD=OFF
TOOLCHAIN_FILE=""
SYSROOT=""
C_FLAGS=""
CXX_FLAGS=""
INSTALL_PREFIX="/usr/local"
BUILD_FOLDER=build
CROSS_COMPILATION_ARM=false
USE_SURFACE=XCB
OS_FLAGS=""
#########################################################
####################### GLOVE ###########################
#########################################################
function buildGlove() {
mkdir -p $BUILD_FOLDER
cd $BUILD_FOLDER
cmake $OS_FLAGS \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DVULKAN_LIBRARY=$VULKAN_LIBRARY \
-DUSE_SURFACE=$USE_SURFACE \
-DVULKAN_INCLUDE_PATH=$VULKAN_INCLUDE_PATH \
-DTRACE_BUILD=$TRACE_BUILD \
-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_FILE \
-DCMAKE_SYSROOT=$SYSROOT \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-DCMAKE_C_FLAGS=$C_FLAGS \
-DCMAKE_CXX_FLAGS=$CXX_FLAGS \
--no-warn-unused-cli ..
cd ..
}
if [ "$#" == 0 ]; then
echo "Building GLOVE"
else
# Parse options
while [[ $# > 0 ]]
do
option="$1"
case $option in
# option to cross compile
-a|--arm-compile)
CROSS_COMPILATION_ARM=true
BUILD_FOLDER=cross_${BUILD_FOLDER}
TOOLCHAIN_FILE=$BASEDIR/CMake/toolchain-arm.cmake
INSTALL_PREFIX=""
echo "Cross compiling for ARM"
;;
# option to build in Debug mode
-d|--debug)
BUILD_TYPE=Debug
BUILD_FOLDER=${BUILD_FOLDER}_debug
echo "Building in Debug mode"
;;
# option to handle warnings as errors
-e|--werror)
C_FLAGS="-Werror"
CXX_FLAGS="-Werror"
echo "Turn all compilation warnings into errors"
;;
# option to set install path
-i|--install-prefix)
shift
INSTALL_PREFIX=$1
if [ ! "${INSTALL_PREFIX:0:1}" == "/" ]; then
INSTALL_PREFIX=$BASEDIR/$1
fi
echo "Setting installation prefix to $INSTALL_PREFIX"
;;
# option to set sysroot
-s|--sysroot)
shift
SYSROOT=$1
echo "Setting SYSROOT"
;;
# option to activate GL & Vulkan logs
-t|--trace-build)
TRACE_BUILD=ON
echo "Activating logs"
;;
# option to set Vulkan include path
-u|--vulkan-include-path)
shift
VULKAN_INCLUDE_PATH=$1
echo "Setting Vulkan include path"
;;
# option to set Vulkan loader
-v|--vulkan-loader)
shift
VULKAN_LIBRARY=$1
echo "Setting Vulkan loader"
;;
# option to set surface
-f|--use-surface)
shift
if [ $1 == "XCB" ] || [ $1 == "WAYLAND" ] || [ $1 == "ANDROID" ] || [ $1 == "NATIVE" ] || [ $1 == "MACOS" ]; then
USE_SURFACE=$1
echo "Setting windowing system to $USE_SURFACE"
else
echo "Wrong surface argument $1 provided (Options are: XCB, WAYLAND, ANDROID and NATIVE). Using $USE_SURFACE."
fi
;;
*)
echo "Unrecognized option: $option"
echo "Try the following:"
echo " -a | --arm-compile # cross build for ARM platform (default OFF)"
echo " -d | --debug # build in Debug mode (default Release)"
echo " -e | --werror # handle warnings as errors (default OFF)"
echo " -f | --use-surface # set windowing system (Options: XCB, ANDROID, NATIVE, WINDOWS, MACOS) (default XCB)"
echo " -i | --install-prefix (dir) # set custom installation prefix path"
echo " -s | --sysroot (dir) # set sysroot for cross compilation"
echo " -t | --trace-build # activate logs (default OFF)"
echo " -u | --vulkan-include-path (dir) # set custom Vulkan include path"
echo " -v | --vulkan-loader (lib) # set custom Vulkan loader library"
exit 1
;;
esac
shift
done
fi
DYN_LIB_EXTENSION=".so"
if [ "$(uname)" == "Darwin" ]; then
DYN_LIB_EXTENSION=".dylib"
OS_FLAGS="-G Xcode "
fi
if [ ! -d "$BASEDIR/External/glslang" ] || [ ! -d "$BASEDIR/External/glslang/.git" ]; then
echo -e "\e[0;31mExternal sources are missing. Run './update_external_sources.sh'.\e[0m"
exit 1
fi
if [ -n "$VULKAN_LIBRARY" ] && { [ ! -e $VULKAN_LIBRARY ] || echo $VULKAN_LIBRARY | grep -q -v $DYN_LIB_EXTENSION ; }; then
echo -e "\e[0;31mCannot find Vulkan loader '$VULKAN_LIBRARY'.\e[0m"
exit 1
fi
if [ -n "$VULKAN_INCLUDE_PATH" ] && [ ! -d $VULKAN_INCLUDE_PATH ]; then
echo -e "\e[0;31mCannot find Vulkan include path '$VULKAN_INCLUDE_PATH'.\e[0m"
exit 1
fi
if [ ! -d $INSTALL_PREFIX ]; then
echo -e "\e[0;31mCannot find '$INSTALL_PREFIX' path to install the libraries.\e[0m"
exit 1
fi
if [ $CROSS_COMPILATION_ARM == "true" ]; then
if [ -z "$SYSROOT" ] || [ ! -d $SYSROOT ]; then
echo -e "\e[0;31mCannot find '$SYSROOT' path for sysroot.\e[0m"
exit 1
fi
if [ -z "$INSTALL_PREFIX" ]; then
echo -e "\e[0;31mSet custom installation path (use '-i' option).\e[0m"
exit 1
fi
if [ ! -d "$BASEDIR/External/glslang" ] || [ ! -d "$BASEDIR/External/googletest/cross_build" ]; then
echo -e "\e[0;31mExternal sources are not cross-compiled. Run './update_external_sources.sh -s $SYSROOT -i $INSTALL_PREFIX'.\e[0m"
exit 1
fi
fi
buildGlove