This repository has been archived by the owner on Jul 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
/
update_external_sources.sh
executable file
·174 lines (154 loc) · 4.86 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
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
#!/bin/bash
# Update source for glslang
set -e
if [[ $(uname) == "Linux" || $(uname) =~ "CYGWIN" ]]; then
CURRENT_DIR="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
CORE_COUNT=$(nproc || echo 4)
elif [[ $(uname) == "Darwin" ]]; then
CURRENT_DIR="$(dirname "$(python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' ${BASH_SOURCE[0]})")"
CORE_COUNT=$(sysctl -n hw.ncpu || echo 4)
fi
echo CURRENT_DIR=$CURRENT_DIR
echo CORE_COUNT=$CORE_COUNT
REVISION_DIR="$CURRENT_DIR/external_revisions"
git submodule update --init --recursive
# Use tr -d to remove line endings
GLSLANG_GITURL=$(cat "${REVISION_DIR}/glslang_giturl" | tr -d "\n\r")
GLSLANG_REVISION=$(cat "${REVISION_DIR}/glslang_revision" | tr -d "\n\r")
echo "GLSLANG_GITURL=${GLSLANG_GITURL}"
echo "GLSLANG_REVISION=${GLSLANG_REVISION}"
BUILDDIR=${CURRENT_DIR}
BASEDIR="$BUILDDIR/external"
function create_glslang () {
rm -rf "${BASEDIR}"/glslang
echo "Creating local glslang repository (${BASEDIR}/glslang)."
mkdir -p "${BASEDIR}"/glslang
cd "${BASEDIR}"/glslang
git clone ${GLSLANG_GITURL} .
git checkout ${GLSLANG_REVISION}
./update_glslang_sources.py
}
function update_glslang () {
echo "Updating ${BASEDIR}/glslang"
cd "${BASEDIR}"/glslang
git fetch --all
git checkout --force ${GLSLANG_REVISION}
./update_glslang_sources.py
}
function build_glslang () {
echo "Building ${BASEDIR}/glslang"
cd "${BASEDIR}"/glslang
mkdir -p build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install ..
make -j $CORE_COUNT
make install
}
function create_moltenvk () {
rm -rf "${BASEDIR}"/MoltenVK
echo "Creating local MoltenVK repository (${BASEDIR}/MoltenVK)."
mkdir -p "${BASEDIR}"/MoltenVK
cd "${BASEDIR}"/MoltenVK
git clone --recurse-submodules https://github.com/KhronosGroup/MoltenVK.git "${BASEDIR}"/MoltenVK
}
function update_moltenvk () {
echo "Updating ${BASEDIR}/MoltenVK"
cd "${BASEDIR}"/MoltenVK
git pull
}
function build_moltenvk () {
echo "Building ${BASEDIR}/MoltenVK"
cd "${BASEDIR}"/MoltenVK
./fetchDependencies --v-lvl-root "${BUILDDIR}" --glslang-root "${BASEDIR}/glslang"
xcodebuild -project MoltenVKPackaging.xcodeproj \
GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS MVK_LOGGING_ENABLED=0' \
-scheme "MoltenVK (Release)" build
}
INCLUDE_GLSLANG=false
INCLUDE_MOLTENVK=false
NO_SYNC=false
NO_BUILD=false
USE_IMPLICIT_COMPONENT_LIST=true
# Parse options
while [[ $# > 0 ]]
do
option="$1"
case $option in
# options to specify build of glslang components
-g|--glslang)
INCLUDE_GLSLANG=true
USE_IMPLICIT_COMPONENT_LIST=false
echo "Building glslang ($option)"
;;
# options to specify build of moltenvk components
-m|--moltenvk)
if [[ $(uname) == "Darwin" ]]; then
INCLUDE_MOLTENVK=true
USE_IMPLICIT_COMPONENT_LIST=false
echo "Building MoltenVK ($option)"
fi
;;
# options to specify build of spirv-tools components
-s|--spirv-tools)
echo "($option) is deprecated and is no longer necessary"
;;
# option to specify skipping sync from git
--no-sync)
NO_SYNC=true
echo "Skipping sync ($option)"
;;
# option to specify skipping build
--no-build)
NO_BUILD=true
echo "Skipping build ($option)"
;;
*)
echo "Unrecognized option: $option"
echo "Usage: update_external_sources.sh [options]"
echo " Available options:"
echo " -g | --glslang # enable glslang component"
if [[ $(uname) == "Darwin" ]]; then
echo " -m | --moltenvk # enable moltenvk component"
fi
echo " --no-sync # skip sync from git"
echo " --no-build # skip build"
echo " If any component enables are provided, only those components are enabled."
echo " If no component enables are provided, all components are enabled."
echo " Sync uses git to pull a specific revision."
echo " Build configures CMake, builds Release."
exit 1
;;
esac
shift
done
if [ ${USE_IMPLICIT_COMPONENT_LIST} == "true" ]; then
echo "Building glslang"
INCLUDE_GLSLANG=true
if [[ $(uname) == "Darwin" ]]; then
echo "Building MoltenVK"
INCLUDE_MOLTENVK=true
fi
fi
if [ ${INCLUDE_GLSLANG} == "true" ]; then
if [ ${NO_SYNC} == "false" ]; then
if [ ! -d "${BASEDIR}/glslang" -o ! -d "${BASEDIR}/glslang/.git" -o -d "${BASEDIR}/glslang/.svn" ]; then
create_glslang
fi
update_glslang
fi
if [ ${NO_BUILD} == "false" ]; then
build_glslang
fi
fi
if [ ${INCLUDE_MOLTENVK} == "true" ]; then
if [ ${NO_SYNC} == "false" ]; then
if [ ! -d "${BASEDIR}/MoltenVK" -o ! -d "${BASEDIR}/MoltenVK/.git" ]; then
create_moltenvk
fi
update_moltenvk
fi
if [ ${NO_BUILD} == "false" ]; then
echo "Building moltenvk"
build_moltenvk
fi
fi