layers: Add push descriptor set layout create VUID
[platform/upstream/Vulkan-LoaderAndValidationLayers.git] / update_external_sources.sh
1 #!/bin/bash
2 # Update source for glslang
3
4 set -e
5
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)
12 fi
13 echo CURRENT_DIR=$CURRENT_DIR
14 echo CORE_COUNT=$CORE_COUNT
15
16 REVISION_DIR="$CURRENT_DIR/external_revisions"
17
18 GLSLANG_GITURL=$(cat "${REVISION_DIR}/glslang_giturl")
19 GLSLANG_REVISION=$(cat "${REVISION_DIR}/glslang_revision")
20
21 echo "GLSLANG_GITURL=${GLSLANG_GITURL}"
22 echo "GLSLANG_REVISION=${GLSLANG_REVISION}"
23
24 BUILDDIR=${CURRENT_DIR}
25 BASEDIR="$BUILDDIR/external"
26
27 function create_glslang () {
28    rm -rf "${BASEDIR}"/glslang
29    echo "Creating local glslang repository (${BASEDIR}/glslang)."
30    mkdir -p "${BASEDIR}"/glslang
31    cd "${BASEDIR}"/glslang
32    git clone ${GLSLANG_GITURL} .
33    git checkout ${GLSLANG_REVISION}
34    ./update_glslang_sources.py
35 }
36
37 function update_glslang () {
38    echo "Updating ${BASEDIR}/glslang"
39    cd "${BASEDIR}"/glslang
40    git fetch --all
41    git checkout --force ${GLSLANG_REVISION}
42    ./update_glslang_sources.py
43 }
44
45 function build_glslang () {
46    echo "Building ${BASEDIR}/glslang"
47    cd "${BASEDIR}"/glslang
48    mkdir -p build
49    cd build
50    cmake -D CMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install ..
51    make -j $CORE_COUNT
52    make install
53 }
54
55 INCLUDE_GLSLANG=false
56 NO_SYNC=false
57 NO_BUILD=false
58 USE_IMPLICIT_COMPONENT_LIST=true
59
60 # Parse options
61 while [[ $# > 0 ]]
62 do
63   option="$1"
64
65   case $option in
66       # options to specify build of glslang components
67       -g|--glslang)
68       INCLUDE_GLSLANG=true
69       USE_IMPLICIT_COMPONENT_LIST=false
70       echo "Building glslang ($option)"
71       ;;
72       # options to specify build of spirv-tools components
73       -s|--spirv-tools)
74       echo "($option) is deprecated and is no longer necessary"
75       ;;
76       # option to specify skipping sync from git
77       --no-sync)
78       NO_SYNC=true
79       echo "Skipping sync ($option)"
80       ;;
81       # option to specify skipping build
82       --no-build)
83       NO_BUILD=true
84       echo "Skipping build ($option)"
85       ;;
86       *)
87       echo "Unrecognized option: $option"
88       echo "Usage: update_external_sources.sh [options]"
89       echo "  Available options:"
90       echo "    -g | --glslang      # enable glslang component"
91       echo "    --no-sync           # skip sync from git"
92       echo "    --no-build          # skip build"
93       echo "  If any component enables are provided, only those components are enabled."
94       echo "  If no component enables are provided, all components are enabled."
95       echo "  Sync uses git to pull a specific revision."
96       echo "  Build configures CMake, builds Release."
97       exit 1
98       ;;
99   esac
100   shift
101 done
102
103 if [ ${USE_IMPLICIT_COMPONENT_LIST} == "true" ]; then
104   echo "Building glslang"
105   INCLUDE_GLSLANG=true
106 fi
107
108 if [ ${INCLUDE_GLSLANG} == "true" ]; then
109   if [ ${NO_SYNC} == "false" ]; then
110     if [ ! -d "${BASEDIR}/glslang" -o ! -d "${BASEDIR}/glslang/.git" -o -d "${BASEDIR}/glslang/.svn" ]; then
111        create_glslang
112     fi
113     update_glslang
114   fi
115   if [ ${NO_BUILD} == "false" ]; then
116     build_glslang
117   fi
118 fi