2 # Update source for glslang
6 if [[ $(uname) == "Linux" || $(uname) =~ "CYGWIN" ]]; then
7 CURRENT_DIR="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
8 CORE_COUNT=$(nproc || echo 4)
9 elif [[ $(uname) == "Darwin" ]]; then
10 CURRENT_DIR="$(dirname "$(python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' ${BASH_SOURCE[0]})")"
11 CORE_COUNT=$(sysctl -n hw.ncpu || echo 4)
13 echo CURRENT_DIR=$CURRENT_DIR
14 echo CORE_COUNT=$CORE_COUNT
16 REVISION_DIR="$CURRENT_DIR/external_revisions"
18 # Use tr -d to remove line endings
19 GLSLANG_GITURL=$(cat "${REVISION_DIR}/glslang_giturl" | tr -d "\n\r")
20 GLSLANG_REVISION=$(cat "${REVISION_DIR}/glslang_revision" | tr -d "\n\r")
22 echo "GLSLANG_GITURL=${GLSLANG_GITURL}"
23 echo "GLSLANG_REVISION=${GLSLANG_REVISION}"
25 BUILDDIR=${CURRENT_DIR}
26 BASEDIR="$BUILDDIR/external"
28 function create_glslang () {
29 rm -rf "${BASEDIR}"/glslang
30 echo "Creating local glslang repository (${BASEDIR}/glslang)."
31 mkdir -p "${BASEDIR}"/glslang
32 cd "${BASEDIR}"/glslang
33 git clone ${GLSLANG_GITURL} .
34 git checkout ${GLSLANG_REVISION}
35 ./update_glslang_sources.py
38 function update_glslang () {
39 echo "Updating ${BASEDIR}/glslang"
40 cd "${BASEDIR}"/glslang
42 git checkout --force ${GLSLANG_REVISION}
43 ./update_glslang_sources.py
46 function build_glslang () {
47 echo "Building ${BASEDIR}/glslang"
48 cd "${BASEDIR}"/glslang
51 cmake -D CMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install ..
56 function create_moltenvk () {
57 rm -rf "${BASEDIR}"/MoltenVK
58 echo "Creating local MoltenVK repository (${BASEDIR}/MoltenVK)."
59 mkdir -p "${BASEDIR}"/MoltenVK
60 cd "${BASEDIR}"/MoltenVK
61 git clone --recurse-submodules https://github.com/KhronosGroup/MoltenVK.git "${BASEDIR}"/MoltenVK
64 function update_moltenvk () {
65 echo "Updating ${BASEDIR}/MoltenVK"
66 cd "${BASEDIR}"/MoltenVK
70 function build_moltenvk () {
71 echo "Building ${BASEDIR}/MoltenVK"
72 cd "${BASEDIR}"/MoltenVK/External
74 cd "${BASEDIR}"/MoltenVK
75 xcodebuild -project MoltenVKPackaging.xcodeproj \
76 GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS MVK_LOGGING_ENABLED=0' \
77 -scheme "MoltenVK (Release)" build
81 INCLUDE_MOLTENVK=false
84 USE_IMPLICIT_COMPONENT_LIST=true
92 # options to specify build of glslang components
95 USE_IMPLICIT_COMPONENT_LIST=false
96 echo "Building glslang ($option)"
98 # options to specify build of moltenvk components
100 if [[ $(uname) == "Darwin" ]]; then
101 INCLUDE_MOLTENVK=true
102 USE_IMPLICIT_COMPONENT_LIST=false
103 echo "Building MoltenVK ($option)"
106 # options to specify build of spirv-tools components
108 echo "($option) is deprecated and is no longer necessary"
110 # option to specify skipping sync from git
113 echo "Skipping sync ($option)"
115 # option to specify skipping build
118 echo "Skipping build ($option)"
121 echo "Unrecognized option: $option"
122 echo "Usage: update_external_sources.sh [options]"
123 echo " Available options:"
124 echo " -g | --glslang # enable glslang component"
125 if [[ $(uname) == "Darwin" ]]; then
126 echo " -m | --moltenvk # enable moltenvk component"
128 echo " --no-sync # skip sync from git"
129 echo " --no-build # skip build"
130 echo " If any component enables are provided, only those components are enabled."
131 echo " If no component enables are provided, all components are enabled."
132 echo " Sync uses git to pull a specific revision."
133 echo " Build configures CMake, builds Release."
140 if [ ${USE_IMPLICIT_COMPONENT_LIST} == "true" ]; then
141 echo "Building glslang"
143 if [[ $(uname) == "Darwin" ]]; then
144 echo "Building MoltenVK"
145 INCLUDE_MOLTENVK=true
149 if [ ${INCLUDE_GLSLANG} == "true" ]; then
150 if [ ${NO_SYNC} == "false" ]; then
151 if [ ! -d "${BASEDIR}/glslang" -o ! -d "${BASEDIR}/glslang/.git" -o -d "${BASEDIR}/glslang/.svn" ]; then
156 if [ ${NO_BUILD} == "false" ]; then
161 if [ ${INCLUDE_MOLTENVK} == "true" ]; then
162 if [ ${NO_SYNC} == "false" ]; then
163 if [ ! -d "${BASEDIR}/MoltenVK" -o ! -d "${BASEDIR}/MoltenVK/.git" ]; then
168 if [ ${NO_BUILD} == "false" ]; then
169 echo "Building moltenvk"