external: Update commit IDs and scripts

Update to top-of-tree glslang, plus the spirv dependencies
specified by glslang's known_good.json file.

Modify the LVL update_external_sources.* scripts to invoke
glslang's update_glslang_sources.py script as part of the checkout
process.

Add .gitattributes file to force CRLF on .bat files.

Enhance LVL's CMakeLists.txt for new SPIRV_TOOLS_OPT_* variables.

Add SPIRV-Tools-opt to linker.

Adjust some comments.

Change-Id: I8e782c15cade4260528ab055361208af137204fa
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..87dbeff
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,16 @@
+# See https://git-scm.com/docs/gitattributes
+# See https://help.github.com/articles/dealing-with-line-endings/
+
+# default behavior, if core.autocrlf is unset.
+* text=auto
+
+# files to be converted to native line endings on checkout.
+*.cpp text
+*.h text
+
+# files to always have CRLF line endings on checkout.
+*.bat text eol=crlf
+
+# files to always have CR line endings on checkout.
+*.sh text eol=cr
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b4abd2..ba1a0c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,6 +92,7 @@
     set (BINDATA_DIR Bin)
     set (LIBSOURCE_DIR Lib)
 else()
+    # is WIN32
     option(DISABLE_BUILD_PATH_DECORATION "Disable the decoration of the gslang and SPIRV-Tools build path with MSVC build type info" OFF)
     option(DISABLE_BUILDTGT_DIR_DECORATION "Disable the decoration of the gslang and SPIRV-Tools build path with target info" OFF)
 
@@ -119,11 +120,12 @@
 option(BUILD_DEMOS "Build demos" ON)
 option(BUILD_VKJSON "Build vkjson" ON)
 option(CUSTOM_GLSLANG_BIN_ROOT "Use the user defined GLSLANG_BINARY_ROOT" OFF)
-option(CUSTOM_SPIRV_TOOLS_BIN_ROOT "Use the user defined SPIRV_TOOLS_BINARY_ROOT" OFF)
+option(CUSTOM_SPIRV_TOOLS_BIN_ROOT "Use the user defined SPIRV_TOOLS*BINARY_ROOT paths" OFF)
 
 #Choose natural default paths for glslang and SPIRV-Tools binaries to support custom definition by the user on the CMake command line or in the GUI
 set(GLSLANG_BINARY_ROOT "${CMAKE_BINARY_DIR}/../glslang" CACHE STRING "User defined path to the glslang binaries for this project")
 set(SPIRV_TOOLS_BINARY_ROOT "${CMAKE_BINARY_DIR}/../SPIRV-Tools" CACHE STRING "User defined path to the SPIRV-Tools binaries for this project")
+set(SPIRV_TOOLS_OPT_BINARY_ROOT "${CMAKE_BINARY_DIR}/../SPIRV-Tools/opt" CACHE STRING "User defined path to the SPIRV-Tools-opt binaries for this project")
 
 # Define a variable for a default root location to the gslang, SPIRV-Tools and other external sources and cache it to allow the user to customize it as needed
 set(EXTERNAL_SOURCE_ROOT "${CMAKE_SOURCE_DIR}/external" CACHE STRING "Root path to external sources such as glslang and SPIRV-Tools")
@@ -160,12 +162,16 @@
     if(CUSTOM_SPIRV_TOOLS_BIN_ROOT)
         set (SPIRV_TOOLS_SEARCH_PATH "${SPIRV_TOOLS_BINARY_ROOT}/${BUILDTGT_DIR}/source/${RELEASE_DECORATION}")
         set (SPIRV_TOOLS_DEBUG_SEARCH_PATH "${SPIRV_TOOLS_BINARY_ROOT}/${BUILDTGT_DIR}/source/${DEBUG_DECORATION}")
+        set (SPIRV_TOOLS_OPT_SEARCH_PATH "${SPIRV_TOOLS_OPT_BINARY_ROOT}/${BUILDTGT_DIR}/source/opt/${RELEASE_DECORATION}")
+        set (SPIRV_TOOLS_OPT_DEBUG_SEARCH_PATH "${SPIRV_TOOLS_OPT_BINARY_ROOT}/${BUILDTGT_DIR}/source/opt/${DEBUG_DECORATION}")
     else()
         set (SPIRV_TOOLS_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source/${RELEASE_DECORATION}")
         set (SPIRV_TOOLS_DEBUG_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source/${DEBUG_DECORATION}")
+        set (SPIRV_TOOLS_OPT_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source/opt/${RELEASE_DECORATION}")
+        set (SPIRV_TOOLS_OPT_DEBUG_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source/opt/${DEBUG_DECORATION}")
     endif()
 else()
-    #non windows
+    # not WIN32
     if(CUSTOM_GLSLANG_BIN_ROOT)
         set (GLSLANG_SEARCH_PATH "${GLSLANG_BINARY_ROOT}/install/lib"
                                  "${GLSLANG_BINARY_ROOT}/glslang"
@@ -180,8 +186,10 @@
 
     if(CUSTOM_SPIRV_TOOLS_BIN_ROOT)
         set (SPIRV_TOOLS_SEARCH_PATH "${SPIRV_TOOLS_BINARY_ROOT}/source" )
+        set (SPIRV_TOOLS_OPT_SEARCH_PATH "${SPIRV_TOOLS_OPT_BINARY_ROOT}/source/opt" )
     else()
         set (SPIRV_TOOLS_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source" "${CMAKE_SOURCE_DIR}/../x86_64/lib/spirv-tools" )
+        set (SPIRV_TOOLS_OPT_SEARCH_PATH "${EXTERNAL_SOURCE_ROOT}/spirv-tools/${BUILDTGT_DIR}/source/opt" "${CMAKE_SOURCE_DIR}/../x86_64/lib/spirv-tools" )
     endif()
 endif()
 
@@ -222,15 +230,19 @@
 find_library(SPIRV_TOOLS_LIB NAMES SPIRV-Tools
              HINTS ${SPIRV_TOOLS_SEARCH_PATH} )
 
+find_library(SPIRV_TOOLS_OPT_LIB NAMES SPIRV-Tools-opt
+             HINTS ${SPIRV_TOOLS_OPT_SEARCH_PATH} )
+
 if (WIN32)
-    add_library(glslang     STATIC IMPORTED)
-    add_library(OGLCompiler STATIC IMPORTED)
-    add_library(OSDependent STATIC IMPORTED)
-    add_library(HLSL        STATIC IMPORTED)
-    add_library(SPIRV       STATIC IMPORTED)
-    add_library(SPVRemapper       STATIC IMPORTED)
-    add_library(Loader      STATIC IMPORTED)
-    add_library(SPIRV-Tools STATIC IMPORTED)
+    add_library(glslang         STATIC IMPORTED)
+    add_library(OGLCompiler     STATIC IMPORTED)
+    add_library(OSDependent     STATIC IMPORTED)
+    add_library(HLSL            STATIC IMPORTED)
+    add_library(SPIRV           STATIC IMPORTED)
+    add_library(SPVRemapper     STATIC IMPORTED)
+    add_library(Loader          STATIC IMPORTED)
+    add_library(SPIRV-Tools-opt STATIC IMPORTED)
+    add_library(SPIRV-Tools     STATIC IMPORTED)
 
     find_library(GLSLANG_DLIB NAMES glslangd
                  HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
@@ -246,6 +258,8 @@
                  HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
     find_library(SPIRV_TOOLS_DLIB NAMES SPIRV-Tools
                  HINTS ${SPIRV_TOOLS_DEBUG_SEARCH_PATH} )
+    find_library(SPIRV_TOOLS_OPT_DLIB NAMES SPIRV-Tools-opt
+                 HINTS ${SPIRV_TOOLS_OPT_DEBUG_SEARCH_PATH} )
 
     set_target_properties(glslang PROPERTIES
                          IMPORTED_LOCATION       "${GLSLANG_LIB}"
@@ -268,12 +282,16 @@
     set_target_properties(SPIRV-Tools PROPERTIES
                          IMPORTED_LOCATION       "${SPIRV_TOOLS_LIB}"
                          IMPORTED_LOCATION_DEBUG "${SPIRV_TOOLS_DLIB}")
+    set_target_properties(SPIRV-Tools-opt PROPERTIES
+                         IMPORTED_LOCATION       "${SPIRV_TOOLS_OPT_LIB}"
+                         IMPORTED_LOCATION_DEBUG "${SPIRV_TOOLS_OPT_DLIB}")
 
-    set (GLSLANG_LIBRARIES glslang OGLCompiler OSDependent HLSL SPIRV SPVRemapper)
-    set (SPIRV_TOOLS_LIBRARIES SPIRV-Tools)
+    set (SPIRV_TOOLS_LIBRARIES SPIRV-Tools-opt SPIRV-Tools)
+    set (GLSLANG_LIBRARIES glslang OGLCompiler OSDependent HLSL SPIRV SPVRemapper ${SPIRV_TOOLS_LIBRARIES})
 else ()
-    set (GLSLANG_LIBRARIES ${GLSLANG_LIB} ${OGLCompiler_LIB} ${OSDependent_LIB} ${HLSL_LIB} ${SPIRV_LIB} ${SPIRV_REMAPPER_LIB})
-    set (SPIRV_TOOLS_LIBRARIES ${SPIRV_TOOLS_LIB})
+    # not WIN32
+    set (SPIRV_TOOLS_LIBRARIES ${SPIRV_TOOLS_OPT_LIB} ${SPIRV_TOOLS_LIB})
+    set (GLSLANG_LIBRARIES ${GLSLANG_LIB} ${OGLCompiler_LIB} ${OSDependent_LIB} ${HLSL_LIB} ${SPIRV_LIB} ${SPIRV_REMAPPER_LIB} ${SPIRV_TOOLS_LIBRARIES})
 endif()
 
 set (PYTHON_CMD ${PYTHON_EXECUTABLE})
diff --git a/external_revisions/glslang_revision b/external_revisions/glslang_revision
index dfc978c..ba5f996 100644
--- a/external_revisions/glslang_revision
+++ b/external_revisions/glslang_revision
@@ -1 +1 @@
-3a21c880500eac21cdf79bef5b80f970a55ac6af
+8b555f74583458b6b37ba5e6c1b23c2ecaf46668
diff --git a/external_revisions/spirv-tools_revision b/external_revisions/spirv-tools_revision
index 8070b79..874e1dd 100644
--- a/external_revisions/spirv-tools_revision
+++ b/external_revisions/spirv-tools_revision
@@ -1 +1 @@
-7e2d26c77b606b21af839b37fd21381c4a669f23
+99cd25c4139e0dc914ab8a5a3b75e6fed0ad1329
diff --git a/update_external_sources.bat b/update_external_sources.bat
index 3c4006c..aac541d 100644
--- a/update_external_sources.bat
+++ b/update_external_sources.bat
@@ -300,6 +300,7 @@
    cd %GLSLANG_DIR%
    git clone %GLSLANG_GITURL% .
    git checkout %GLSLANG_REVISION%
+   C:\Python27\python.exe .\update_glslang_sources.py
    if not exist %GLSLANG_DIR%\SPIRV (
       echo glslang source download failed!
       set errorCode=1
@@ -312,6 +313,7 @@
    cd %GLSLANG_DIR%
    git fetch --all
    git checkout %GLSLANG_REVISION%
+   C:\Python27\python.exe .\update_glslang_sources.py
 goto:eof
 
 :create_spirv-tools
diff --git a/update_external_sources.sh b/update_external_sources.sh
index 43ebeba..805d81b 100755
--- a/update_external_sources.sh
+++ b/update_external_sources.sh
@@ -39,6 +39,7 @@
    cd "${BASEDIR}"/glslang
    git clone ${GLSLANG_GITURL} .
    git checkout ${GLSLANG_REVISION}
+   ./update_glslang_sources.py
 }
 
 function update_glslang () {
@@ -46,6 +47,7 @@
    cd "${BASEDIR}"/glslang
    git fetch --all
    git checkout --force ${GLSLANG_REVISION}
+   ./update_glslang_sources.py
 }
 
 function create_spirv-tools () {