-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_external_sources.sh
executable file
·118 lines (102 loc) · 2.85 KB
/
update_external_sources.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
#!/usr/bin/env bash
# Update source for glslang, googletest
set -e
BASEDIR=$PWD
EXT_DIR=$PWD/External
BUILD_FOLDER=build
INSTALL_PATH=""
TOOLCHAIN_FILE=""
SYSROOT=""
GLSLANG_REPOSITORY="https://github.com/KhronosGroup/glslang.git"
GOOGLETEST_REPOSITORY="https://github.com/google/googletest.git"
GLSLANG_REVISION=$(cat $EXT_DIR/glslang_revision)
GOOGLETEST_REVISION=$(cat $EXT_DIR/googletest_revision)
GLSLANG_FLAGS="-DENABLE_AMD_EXTENSIONS=OFF -DENABLE_NV_EXTENSIONS=OFF -DENABLE_OPT=OFF"
echo "GLSLANG_REVISION=$GLSLANG_REVISION"
echo "GOOGLETEST_REVISION=$GOOGLETEST_REVISION"
function create() {
PROJECT=$1
echo "Creating local glslang repository ($EXT_DIR/$PROJECT)."
rm -rf $EXT_DIR/$PROJECT
mkdir -p $EXT_DIR/$PROJECT
cd $EXT_DIR/$PROJECT
git clone $2 .
git checkout $3
}
function update() {
PROJECT=$1
echo "Updating $EXT_DIR/$PROJECT"
cd $EXT_DIR/$PROJECT
git fetch --all
git checkout --force $2
}
function build() {
PROJECT=$1
PROJECT_FLAGS=""
echo "Building $EXT_DIR/$PROJECT"
if [ -z "$INSTALL_PATH" ]; then
INSTALL_PREFIX="$EXT_DIR/$PROJECT"
else
INSTALL_PREFIX="$INSTALL_PATH"
fi
if [ $PROJECT == "glslang" ]; then
PROJECT_FLAGS=$GLSLANG_FLAGS
fi
echo "PROJECT_FLAGS:" $PROJECT_FLAGS
cd $EXT_DIR/$PROJECT
mkdir -p $BUILD_FOLDER
cd $BUILD_FOLDER
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_FILE \
-DCMAKE_SYSROOT=$SYSROOT \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
$PROJECT_FLAGS ..
make -j $(nproc)
make install
}
# Parse options
while [[ $# > 0 ]]
do
option="$1"
case $option in
# option to set install path
-i|--install-path)
shift
INSTALL_PATH=$1
;;
# option to set sysroot
-s|--sysroot)
shift
SYSROOT=$1
BUILD_FOLDER=cross_build
TOOLCHAIN_FILE=$BASEDIR/CMake/toolchain-arm.cmake
;;
*)
echo "Unrecognized option: $option"
echo "Try the following:"
echo " -i | --install-path (dir) # set custom installation path"
echo " -s | --sysroot (dir) # set sysroot for cross compilation"
exit 1
;;
esac
shift
done
if [ ! -d "$EXT_DIR/glslang" ] || [ ! -d "$EXT_DIR/glslang/.git" ]; then
create glslang $GLSLANG_REPOSITORY $GLSLANG_REVISION
fi
update glslang $GLSLANG_REVISION
build glslang
if [ ! -d "$EXT_DIR/googletest" ] || [ ! -d "$EXT_DIR/googletest/.git" ]; then
create googletest $GOOGLETEST_REPOSITORY $GOOGLETEST_REVISION
fi
update googletest $GOOGLETEST_REVISION
build googletest
if grep -q "openSUSE" /etc/os-release
then
cd External/googletest/
if [ ! -d lib ]; then
echo "createing link lib64 -> lib"
ln -sf lib64 lib
fi
cd -
fi