Home | History | Annotate | Download | only in vulkan-validation-layers
      1 #!/bin/bash
      2 # Update source for glslang, LunarGLASS, spirv-tools
      3 
      4 set -e
      5 
      6 GLSLANG_REVISION=$(cat $PWD/glslang_revision)
      7 SPIRV_TOOLS_REVISION=$(cat $PWD/spirv-tools_revision)
      8 echo "GLSLANG_REVISION=$GLSLANG_REVISION"
      9 echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION"
     10 
     11 BUILDDIR=$PWD
     12 BASEDIR=$BUILDDIR/..
     13 
     14 function create_glslang () {
     15    rm -rf $BASEDIR/glslang
     16    echo "Creating local glslang repository ($BASEDIR/glslang)."
     17    mkdir -p $BASEDIR/glslang
     18    cd $BASEDIR/glslang
     19    git clone https://github.com/KhronosGroup/glslang.git .
     20    git checkout $GLSLANG_REVISION
     21 }
     22 
     23 function update_glslang () {
     24    echo "Updating $BASEDIR/glslang"
     25    cd $BASEDIR/glslang
     26    git fetch --all
     27    git checkout $GLSLANG_REVISION
     28 }
     29 
     30 function create_spirv-tools () {
     31    rm -rf $BASEDIR/spirv-tools
     32    echo "Creating local spirv-tools repository ($BASEDIR/spirv-tools)."
     33    mkdir -p $BASEDIR/spirv-tools
     34    cd $BASEDIR/spirv-tools
     35    git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
     36    git checkout $SPIRV_TOOLS_REVISION
     37 }
     38 
     39 function update_spirv-tools () {
     40    echo "Updating $BASEDIR/spirv-tools"
     41    cd $BASEDIR/spirv-tools
     42    git fetch --all
     43    git checkout $SPIRV_TOOLS_REVISION
     44 }
     45 
     46 function build_glslang () {
     47    echo "Building $BASEDIR/glslang"
     48    cd $BASEDIR/glslang
     49    mkdir -p build
     50    cd build
     51    cmake -D CMAKE_BUILD_TYPE=Release ..
     52    cmake -D CMAKE_BUILD_TYPE=Release ..
     53    make
     54    make install
     55 }
     56 
     57 function build_spirv-tools () {
     58    echo "Building $BASEDIR/spirv-tools"
     59    cd $BASEDIR/spirv-tools
     60    mkdir -p build
     61    cd build
     62    cmake -D CMAKE_BUILD_TYPE=Release ..
     63    make -j $(nproc)
     64 }
     65 
     66 # If any options are provided, just compile those tools
     67 # If no options are provided, build everything
     68 INCLUDE_GLSLANG=false
     69 INCLUDE_SPIRV_TOOLS=false
     70 
     71 if [ "$#" == 0 ]; then
     72   echo "Building glslang, spirv-tools"
     73   INCLUDE_GLSLANG=true
     74   INCLUDE_SPIRV_TOOLS=true
     75 else
     76   # Parse options
     77   while [[ $# > 0 ]]
     78   do
     79     option="$1"
     80 
     81     case $option in
     82         # options to specify build of glslang components
     83         -g|--glslang)
     84         INCLUDE_GLSLANG=true
     85         echo "Building glslang ($option)"
     86         ;;
     87         # options to specify build of spirv-tools components
     88         -s|--spirv-tools)
     89         INCLUDE_SPIRV_TOOLS=true
     90         echo "Building spirv-tools ($option)"
     91         ;;
     92         *)
     93         echo "Unrecognized option: $option"
     94         echo "Try the following:"
     95         echo " -g | --glslang      # enable glslang"
     96         echo " -s | --spirv-tools  # enable spirv-tools"
     97         exit 1
     98         ;;
     99     esac
    100     shift
    101   done
    102 fi
    103 
    104 if [ $INCLUDE_GLSLANG == "true" ]; then
    105   if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then
    106      create_glslang
    107   fi
    108   update_glslang
    109   build_glslang
    110 fi
    111 
    112 
    113 if [ $INCLUDE_SPIRV_TOOLS == "true" ]; then
    114     if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then
    115        create_spirv-tools
    116     fi
    117     update_spirv-tools
    118     build_spirv-tools
    119 fi
    120