@echo off
REM Update source for glslang, spirv-tools

REM Determine the appropriate CMake strings for the current version of Visual Studio
echo Determining VS version
python .\scripts\determine_vs_version.py > vsversion.tmp
set /p VS_VERSION=< vsversion.tmp
echo Detected Visual Studio Version as %VS_VERSION%

REM Cleanup the file we used to collect the VS version output since it's no longer needed.
del /Q /F vsversion.tmp

setlocal EnableDelayedExpansion
set errorCode=0
set BUILD_DIR=%~dp0
set BASE_DIR="%BUILD_DIR%external"
set REVISION_DIR="%BUILD_DIR%external_revisions"
set GLSLANG_DIR=%BASE_DIR%\glslang
set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools

REM // ======== Parameter parsing ======== //

   if "%1" == "" (
      echo usage: update_external_sources.bat [options]
      echo.
      echo Available options:
      echo   --sync-glslang      just pull glslang_revision
      echo   --sync-spirv-tools  just pull spirv-tools_revision
      echo   --build-glslang     pulls glslang_revision, configures CMake, builds Release and Debug
      echo   --build-spirv-tools pulls spirv-tools_revision, configures CMake, builds Release and Debug
      echo   --all               sync and build glslang, LunarGLASS, spirv-tools
      goto:finish
   )

   set sync-glslang=0
   set sync-spirv-tools=0
   set build-glslang=0
   set build-spirv-tools=0
   set check-glslang-build-dependencies=0

   :parameterLoop

      if "%1"=="" goto:parameterContinue

      if "%1" == "--sync-glslang" (
         set sync-glslang=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--sync-spirv-tools" (
         set sync-spirv-tools=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--build-glslang" (
         set sync-glslang=1
         set check-glslang-build-dependencies=1
         set build-glslang=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--build-spirv-tools" (
         set sync-spirv-tools=1
         REM glslang has the same needs as spirv-tools
         set check-glslang-build-dependencies=1
         set build-spirv-tools=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--all" (
         set sync-glslang=1
         set sync-spirv-tools=1
         set build-glslang=1
         set build-spirv-tools=1
         set check-glslang-build-dependencies=1
         shift
         goto:parameterLoop
      )

      echo Unrecognized options "%1"
      goto:error

   :parameterContinue

REM // ======== end Parameter parsing ======== //

REM // ======== Dependency checking ======== //
   REM git is required for all paths
   for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
   if not defined FOUND (
      echo Dependency check failed:
      echo   git.exe not found
      echo   Git for Windows can be downloaded here:  https://git-scm.com/download/win
      echo   Install and ensure git.exe makes it into your PATH
      set errorCode=1
   )

   if %check-glslang-build-dependencies% equ 1 (
      for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
      if not defined FOUND (
         echo Dependency check failed:
         echo   cmake.exe not found
         echo   Get CNake 2.8 for Windows here:  http://www.cmake.org/cmake/resources/software.html
         echo   Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
         set errorCode=1
      )
   )

   REM goto:main

REM // ======== end Dependency checking ======== //

:main

if %errorCode% neq 0 (goto:error)

REM Read the target versions from external file, which is shared with Linux script

if not exist %REVISION_DIR%\glslang_revision (
   echo.
   echo Missing glslang_revision file!  Place it in %REVSION_DIR% with target version in it.
   set errorCode=1
   goto:error
)

if not exist %REVISION_DIR%\spirv-tools_revision (
   echo.
   echo Missing spirv-tools_revision file!  Place it in %REVISION_DIR% with target version in it.
   set errorCode=1
   goto:error
)

if not exist %REVISION_DIR%\spirv-headers_revision (
   echo.
   echo Missing spirv-headers_revision file!  Place it in %REVISION_DIR% with target version in it.
   set errorCode=1
   goto:error
)

set /p GLSLANG_REVISION= < %REVISION_DIR%\glslang_revision
set /p SPIRV_TOOLS_REVISION= < %REVISION_DIR%\spirv-tools_revision
set /p SPIRV_HEADERS_REVISION= < %REVISION_DIR%\spirv-headers_revision
echo GLSLANG_REVISION=%GLSLANG_REVISION%
echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION%

echo Creating and/or updating glslang, spirv-tools in %BASE_DIR%

if %sync-glslang% equ 1 (
   if exist %GLSLANG_DIR% (
      rd /S /Q %GLSLANG_DIR%
   )
   if not exist %GLSLANG_DIR% (
      call:create_glslang
   )
   if %errorCode% neq 0 (goto:error)
   call:update_glslang
   if %errorCode% neq 0 (goto:error)
)

if %sync-spirv-tools% equ 1 (
   if exist %SPIRV_TOOLS_DIR% (
      rd /S /Q %SPIRV_TOOLS_DIR%
   )
   if %errorlevel% neq 0 (goto:error)
   if not exist %SPIRV_TOOLS_DIR% (
      call:create_spirv-tools
   )
   if %errorCode% neq 0 (goto:error)
   call:update_spirv-tools
   if %errorCode% neq 0 (goto:error)
)

if %build-glslang% equ 1 (
   call:build_glslang
   if %errorCode% neq 0 (goto:error)
)

if %build-spirv-tools% equ 1 (
   call:build_spirv-tools
   if %errorCode% neq 0 (goto:error)
)

echo.
echo Exiting
goto:finish

:error
echo.
echo Halting due to error
goto:finish

:finish
if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
endlocal
goto:eof

REM // ======== Functions ======== //

:create_glslang
   echo.
   echo Creating local glslang repository %GLSLANG_DIR%)
   mkdir %GLSLANG_DIR%
   cd %GLSLANG_DIR%
   git clone https://github.com/KhronosGroup/glslang.git .
   git checkout %GLSLANG_REVISION%
   if not exist %GLSLANG_DIR%\SPIRV (
      echo glslang source download failed!
      set errorCode=1
   )
goto:eof

:update_glslang
   echo.
   echo Updating %GLSLANG_DIR%
   cd %GLSLANG_DIR%
   git fetch --all
   git checkout %GLSLANG_REVISION%
goto:eof

:create_spirv-tools
   echo.
   echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
   mkdir %SPIRV_TOOLS_DIR%
   cd %SPIRV_TOOLS_DIR%
   git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
   git checkout %SPIRV_TOOLS_REVISION%
   if not exist %SPIRV_TOOLS_DIR%\source (
      echo spirv-tools source download failed!
      set errorCode=1
   )
   mkdir %SPIRV_TOOLS_DIR%\external
   mkdir %SPIRV_TOOLS_DIR%\external\spirv-headers
   cd %SPIRV_TOOLS_DIR%\external\spirv-headers
   git clone https://github.com/KhronosGroup/SPIRV-HEADERS.git .
   git checkout %SPIRV_HEADERS_REVISION%
   if not exist %SPIRV_TOOLS_DIR%\external\spirv-headers\README.md (
      echo spirv-headers download failed!
      set errorCode=1
   )
goto:eof

:update_spirv-tools
   echo.
   echo Updating %SPIRV_TOOLS_DIR%
   cd %SPIRV_TOOLS_DIR%
   git fetch --all
   git checkout %SPIRV_TOOLS_REVISION%
   cd %SPIRV_TOOLS_DIR%\external\spirv-headers
   git fetch --all
   git checkout %SPIRV_HEADERS_REVISION%
goto:eof

:build_glslang
   echo.
   echo Building %GLSLANG_DIR%
   cd  %GLSLANG_DIR%

   REM Cleanup any old directories lying around.
   if exist build32 (
      rmdir /s /q build32
   )
   if exist build (
      rmdir /s /q build
   )

   echo Making 32-bit glslang
   echo *************************
   mkdir build32
   set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
   cd %GLSLANG_BUILD_DIR%

   echo Generating 32-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
   cmake -G "Visual Studio %VS_VERSION%" -DCMAKE_INSTALL_PREFIX=install ..

   echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug
   msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
      echo.
      echo glslang 32-bit Debug build failed!
      set errorCode=1
   )
   echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release
   msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
      echo.
      echo glslang 32-bit Release build failed!
      set errorCode=1
   )

   cd ..

   echo Making 64-bit glslang
   echo *************************
   mkdir build
   set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
   cd %GLSLANG_BUILD_DIR%

   echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
   cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install ..

   echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
   msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
      echo.
      echo glslang 64-bit Debug build failed!
      set errorCode=1
   )
   echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
   msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
      echo.
      echo glslang 64-bit Release build failed!
      set errorCode=1
   )
goto:eof

:build_spirv-tools
   echo.
   echo Building %SPIRV_TOOLS_DIR%
   cd  %SPIRV_TOOLS_DIR%

   REM Cleanup any old directories lying around.
   if exist build32 (
      rmdir /s /q build32
   )
   if exist build (
      rmdir /s /q build
   )

   echo Making 32-bit spirv-tools
   echo *************************
   mkdir build32
   set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32

   cd %SPIRV_TOOLS_BUILD_DIR%

   echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
   cmake -G "Visual Studio %VS_VERSION%" ..

   echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug
   msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 32-bit Debug build failed!
      set errorCode=1
   )

   echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release
   msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 32-bit Release build failed!
      set errorCode=1
   )

   cd ..

   echo Making 64-bit spirv-tools
   echo *************************
   mkdir build
   set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
   cd %SPIRV_TOOLS_BUILD_DIR%

   echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
   cmake -G "Visual Studio %VS_VERSION% Win64" ..

   echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug
   msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 64-bit Debug build failed!
      set errorCode=1
   )

   echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release
   msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 64-bit Release build failed!
      set errorCode=1
   )
goto:eof

@echo off
REM Update source for glslang, spirv-tools

REM Determine the appropriate CMake strings for the current version of Visual Studio
echo Determining VS version
python .\scripts\determine_vs_version.py > vsversion.tmp
set /p VS_VERSION=< vsversion.tmp
echo Detected Visual Studio Version as %VS_VERSION%

REM Cleanup the file we used to collect the VS version output since it's no longer needed.
del /Q /F vsversion.tmp

setlocal EnableDelayedExpansion
set errorCode=0
set BUILD_DIR=%~dp0
set BASE_DIR="%BUILD_DIR%external"
set REVISION_DIR="%BUILD_DIR%external_revisions"
set GLSLANG_DIR=%BASE_DIR%\glslang
set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools

REM // ======== Parameter parsing ======== //

   if "%1" == "" (
      echo usage: update_external_sources.bat [options]
      echo.
      echo Available options:
      echo   --sync-glslang      just pull glslang_revision
      echo   --sync-spirv-tools  just pull spirv-tools_revision
      echo   --build-glslang     pulls glslang_revision, configures CMake, builds Release and Debug
      echo   --build-spirv-tools pulls spirv-tools_revision, configures CMake, builds Release and Debug
      echo   --all               sync and build glslang, LunarGLASS, spirv-tools
      goto:finish
   )

   set sync-glslang=0
   set sync-spirv-tools=0
   set build-glslang=0
   set build-spirv-tools=0
   set check-glslang-build-dependencies=0

   :parameterLoop

      if "%1"=="" goto:parameterContinue

      if "%1" == "--sync-glslang" (
         set sync-glslang=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--sync-spirv-tools" (
         set sync-spirv-tools=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--build-glslang" (
         set sync-glslang=1
         set check-glslang-build-dependencies=1
         set build-glslang=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--build-spirv-tools" (
         set sync-spirv-tools=1
         REM glslang has the same needs as spirv-tools
         set check-glslang-build-dependencies=1
         set build-spirv-tools=1
         shift
         goto:parameterLoop
      )

      if "%1" == "--all" (
         set sync-glslang=1
         set sync-spirv-tools=1
         set build-glslang=1
         set build-spirv-tools=1
         set check-glslang-build-dependencies=1
         shift
         goto:parameterLoop
      )

      echo Unrecognized options "%1"
      goto:error

   :parameterContinue

REM // ======== end Parameter parsing ======== //

REM // ======== Dependency checking ======== //
   REM git is required for all paths
   for %%X in (git.exe) do (set FOUND=%%~$PATH:X)
   if not defined FOUND (
      echo Dependency check failed:
      echo   git.exe not found
      echo   Git for Windows can be downloaded here:  https://git-scm.com/download/win
      echo   Install and ensure git.exe makes it into your PATH
      set errorCode=1
   )

   if %check-glslang-build-dependencies% equ 1 (
      for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X)
      if not defined FOUND (
         echo Dependency check failed:
         echo   cmake.exe not found
         echo   Get CNake 2.8 for Windows here:  http://www.cmake.org/cmake/resources/software.html
         echo   Install and ensure each makes it into your PATH, default is "C:\Program Files (x86)\CMake\bin"
         set errorCode=1
      )
   )

   REM goto:main

REM // ======== end Dependency checking ======== //

:main

if %errorCode% neq 0 (goto:error)

REM Read the target versions from external file, which is shared with Linux script

if not exist %REVISION_DIR%\glslang_revision (
   echo.
   echo Missing glslang_revision file!  Place it in %REVSION_DIR% with target version in it.
   set errorCode=1
   goto:error
)

if not exist %REVISION_DIR%\spirv-tools_revision (
   echo.
   echo Missing spirv-tools_revision file!  Place it in %REVISION_DIR% with target version in it.
   set errorCode=1
   goto:error
)

if not exist %REVISION_DIR%\spirv-headers_revision (
   echo.
   echo Missing spirv-headers_revision file!  Place it in %REVISION_DIR% with target version in it.
   set errorCode=1
   goto:error
)

set /p GLSLANG_REVISION= < %REVISION_DIR%\glslang_revision
set /p SPIRV_TOOLS_REVISION= < %REVISION_DIR%\spirv-tools_revision
set /p SPIRV_HEADERS_REVISION= < %REVISION_DIR%\spirv-headers_revision
echo GLSLANG_REVISION=%GLSLANG_REVISION%
echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
echo SPIRV_HEADERS_REVISION=%SPIRV_HEADERS_REVISION%

echo Creating and/or updating glslang, spirv-tools in %BASE_DIR%

if %sync-glslang% equ 1 (
   if not exist %GLSLANG_DIR% (
      call:create_glslang
   )
   if %errorCode% neq 0 (goto:error)
   call:update_glslang
   if %errorCode% neq 0 (goto:error)
)

if %sync-spirv-tools% equ 1 (
   if %errorlevel% neq 0 (goto:error)
   if not exist %SPIRV_TOOLS_DIR% (
      call:create_spirv-tools
   )
   if %errorCode% neq 0 (goto:error)
   call:update_spirv-tools
   if %errorCode% neq 0 (goto:error)
)

if %build-glslang% equ 1 (
   call:build_glslang
   if %errorCode% neq 0 (goto:error)
)

if %build-spirv-tools% equ 1 (
   call:build_spirv-tools
   if %errorCode% neq 0 (goto:error)
)

echo.
echo Exiting
goto:finish

:error
echo.
echo Halting due to error
goto:finish

:finish
if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
endlocal
goto:eof

REM // ======== Functions ======== //

:create_glslang
   echo.
   echo Creating local glslang repository %GLSLANG_DIR%)
   mkdir %GLSLANG_DIR%
   cd %GLSLANG_DIR%
   git clone https://github.com/KhronosGroup/glslang.git .
   git checkout %GLSLANG_REVISION%
   if not exist %GLSLANG_DIR%\SPIRV (
      echo glslang source download failed!
      set errorCode=1
   )
goto:eof

:update_glslang
   echo.
   echo Updating %GLSLANG_DIR%
   cd %GLSLANG_DIR%
   git fetch --all
   git checkout %GLSLANG_REVISION%
goto:eof

:create_spirv-tools
   echo.
   echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
   mkdir %SPIRV_TOOLS_DIR%
   cd %SPIRV_TOOLS_DIR%
   git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
   git checkout %SPIRV_TOOLS_REVISION%
   if not exist %SPIRV_TOOLS_DIR%\source (
      echo spirv-tools source download failed!
      set errorCode=1
   )
   mkdir %SPIRV_TOOLS_DIR%\external
   mkdir %SPIRV_TOOLS_DIR%\external\spirv-headers
   cd %SPIRV_TOOLS_DIR%\external\spirv-headers
   git clone https://github.com/KhronosGroup/SPIRV-HEADERS.git .
   git checkout %SPIRV_HEADERS_REVISION%
   if not exist %SPIRV_TOOLS_DIR%\external\spirv-headers\README.md (
      echo spirv-headers download failed!
      set errorCode=1
   )
goto:eof

:update_spirv-tools
   echo.
   echo Updating %SPIRV_TOOLS_DIR%
   cd %SPIRV_TOOLS_DIR%
   git fetch --all
   git checkout %SPIRV_TOOLS_REVISION%
   cd %SPIRV_TOOLS_DIR%\external\spirv-headers
   git fetch --all
   git checkout %SPIRV_HEADERS_REVISION%
goto:eof

:build_glslang
   echo.
   echo Building %GLSLANG_DIR%
   cd  %GLSLANG_DIR%

   if not exist build32 (
       mkdir build32
   )
   if not exist build (
      mkdir build
   )

   echo Making 32-bit glslang
   echo *************************
   set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build32
   cd %GLSLANG_BUILD_DIR%

   echo Generating 32-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
   cmake -G "Visual Studio %VS_VERSION%" -DCMAKE_INSTALL_PREFIX=install ..

   echo Building 32-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug
   msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
      echo.
      echo glslang 32-bit Debug build failed!
      set errorCode=1
   )
   echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release
   msbuild INSTALL.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
      echo.
      echo glslang 32-bit Release build failed!
      set errorCode=1
   )

   cd ..

   echo Making 64-bit glslang
   echo *************************
   set GLSLANG_BUILD_DIR=%GLSLANG_DIR%\build
   cd %GLSLANG_BUILD_DIR%

   echo Generating 64-bit Glslang CMake files for Visual Studio %VS_VERSION% -DCMAKE_INSTALL_PREFIX=install ..
   cmake -G "Visual Studio %VS_VERSION% Win64" -DCMAKE_INSTALL_PREFIX=install ..

   echo Building 64-bit Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug
   msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Debug\glslangd.lib (
      echo.
      echo glslang 64-bit Debug build failed!
      set errorCode=1
   )
   echo Building Glslang: MSBuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release
   msbuild INSTALL.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %GLSLANG_BUILD_DIR%\glslang\Release\glslang.lib (
      echo.
      echo glslang 64-bit Release build failed!
      set errorCode=1
   )
goto:eof

:build_spirv-tools
   echo.
   echo Building %SPIRV_TOOLS_DIR%
   cd  %SPIRV_TOOLS_DIR%

   REM Cleanup any old directories lying around.
   if not exist build32 (
       mkdir build32
   )
   if not exist build (
      mkdir build
   )

   echo Making 32-bit spirv-tools
   echo *************************
   set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build32

   cd %SPIRV_TOOLS_BUILD_DIR%

   echo Generating 32-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
   cmake -G "Visual Studio %VS_VERSION%" ..

   echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug
   msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 32-bit Debug build failed!
      set errorCode=1
   )

   echo Building 32-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release
   msbuild ALL_BUILD.vcxproj /p:Platform=x86 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 32-bit Release build failed!
      set errorCode=1
   )

   cd ..

   echo Making 64-bit spirv-tools
   echo *************************
   set SPIRV_TOOLS_BUILD_DIR=%SPIRV_TOOLS_DIR%\build
   cd %SPIRV_TOOLS_BUILD_DIR%

   echo Generating 64-bit spirv-tools CMake files for Visual Studio %VS_VERSION% ..
   cmake -G "Visual Studio %VS_VERSION% Win64" ..

   echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug
   msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Debug /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Debug\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 64-bit Debug build failed!
      set errorCode=1
   )

   echo Building 64-bit spirv-tools: MSBuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release
   msbuild ALL_BUILD.vcxproj /p:Platform=x64 /p:Configuration=Release /verbosity:quiet

   REM Check for existence of one lib, even though we should check for all results
   if not exist %SPIRV_TOOLS_BUILD_DIR%\source\Release\SPIRV-Tools.lib (
      echo.
      echo spirv-tools 64-bit Release build failed!
      set errorCode=1
   )
goto:eof

misc: Make update external bat not clean build

Change-Id: Ief2218fb83fb1916b8fcabe60f48893e9393121e


// 2>nul||@goto :batch
/*
:batch
@echo off
setlocal

:: find csc.exe
set "csc="
for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do  set "csc=%%#"

if not exist "%csc%" (
   echo no .net framework installed
   exit /b 10
)

if not exist "%~n0.exe" (
   call %csc% /nologo /r:"Microsoft.VisualBasic.dll" /out:"%~n0.exe" "%~dpsfnx0" || (
      exit /b %errorlevel%
   )
)
%~n0.exe %*
endlocal & exit /b %errorlevel%

*/

// reference
// https://stackoverflow.com/questions/462270/get-file-icon-used-by-shell
// https://gallery.technet.microsoft.com/scriptcenter/eeff544a-f690-4f6b-a586-11eea6fc5eb8

using System.Drawing;

class Class1
{
    public static void Main()
    {
        var filePath =  @"C:\Users\Public\Downloads\setup.exe";
        var theIcon = IconFromFilePath(filePath);

        if (theIcon != null)
        {
            // Save it to disk, or do whatever you want with it.
            using (var stream = new System.IO.FileStream(@"C:\Users\Public\Downloads\setup.ico", System.IO.FileMode.CreateNew))
            {
                theIcon.Save(stream);
            }
        }
    }

    public static Icon IconFromFilePath(string filePath)
    {
        var result = (Icon)null;

        try
        {
            result = Icon.ExtractAssociatedIcon(filePath);
        }
        catch (System.Exception)
        {
            // swallow and return nothing. You could supply a default Icon here as well
        }

        return result;
    }
}

// 2>nul||@goto :batch
/*
:batch
@echo off
setlocal

:: find csc.exe
set "csc="
for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do  set "csc=%%#"

if not exist "%csc%" (
   echo no .net framework installed
   exit /b 10
)

if not exist "%~n0.exe" (
   call %csc% /nologo /r:"Microsoft.VisualBasic.dll" /out:"%~n0.exe" "%~dpsfnx0" || (
      exit /b %errorlevel%
   )
)
%~n0.exe %*
endlocal & exit /b %errorlevel%

*/

// reference
// https://stackoverflow.com/questions/462270/get-file-icon-used-by-shell
// https://gallery.technet.microsoft.com/scriptcenter/eeff544a-f690-4f6b-a586-11eea6fc5eb8

using System.Drawing;

class Class1
{
    public static void Main()
    {
        var filePath =  @"C:\Users\Public\Downloads\setup.exe";
        var theIcon = IconFromFilePath(filePath);

        if (theIcon != null)
        {
            // Save it to disk, or do whatever you want with it.
            using (var stream = new System.IO.FileStream(@filePath+".ico", System.IO.FileMode.CreateNew))
            {
                theIcon.Save(stream);
            }
        }
    }

    public static Icon IconFromFilePath(string filePath)
    {
        var result = (Icon)null;

        try
        {
            result = Icon.ExtractAssociatedIcon(filePath);
        }
        catch (System.Exception)
        {
            // swallow and return nothing. You could supply a default Icon here as well
        }

        return result;
    }
}

Update ExtractAssociatedIcon.bat

Update ExtractAssociatedIcon.bat


@echo off

set projn=TestUC2
set workDir=%cd%
set UCCDir="C:\UT2004\System"

title %projn%
color 0F

echo %cd%
cd /d C:
cd %UCCDir%

cd ..
xcopy %workDir% %projn% /y /s /i
cd %UCCDir%

del %projn%.u
ucc.exe MakeCommandletUtils.EditPackagesCommandlet 1 %projn%
ucc.exe editor.MakeCommandlet -EXPORTCACHE -SHOWDEP
ucc.exe MakeCommandletUtils.EditPackagesCommandlet 0 %projn%
xcopy %projn%.u %workDir% /y
del %projn%.u

cd ..
del %projn%

@echo off

set projn=__TestUC2__Temp
set workDir=%cd%
set RootDir="C:\UT2004"
set UCCDir="%RootDir%\System"
set ScriptDir="%RootDir%\"
set DestDir="%RootDir%\System"

title %projn%
color 0F

echo %cd%
cd /d C:
cd "%UCCDir%"

xcopy "%workDir%\Classes\" "%ScriptDir%\%projn%\Classes\" /f /r /y /s /i

del "%DestDir%\%projn%.u"

cd "%UCCDir%"
ucc.exe MakeCommandletUtils.EditPackagesCommandlet 1 %projn%
ucc.exe editor.MakeCommandlet -EXPORTCACHE -SHOWDEP
ucc.exe MakeCommandletUtils.EditPackagesCommandlet 0 %projn%

xcopy "%DestDir%\%projn%.u" "%workDir%\TestUC2.u" /f /y /r

Fix batch script

Fix batch script


:: Author:  Lisandro Dalcin
:: Contact: dalcinl@gmail.com
:: Credits: Olivier Grisel and Kyle Kastner
@ECHO OFF

SET COMMAND_TO_RUN=%*

SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
IF "%PYTHON_VERSION:~0,1%" == "2" SET WIN_SDK_VERSION="v7.0"
IF "%PYTHON_VERSION:~0,1%" == "3" SET WIN_SDK_VERSION="v7.1"

IF "%PYTHON_ARCH%"=="64" (
    ECHO Configuring Windows SDK %WIN_SDK_VERSION% for Python %PYTHON_VERSION% on a 64 bit architecture
    SET DISTUTILS_USE_SDK=1
    SET MSSdk=1
    "%WIN_SDK_ROOT%\%WIN_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WIN_SDK_VERSION%
    "%WIN_SDK_ROOT%\%WIN_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
) ELSE (
    ECHO Using default MSVC build environment for 32 bit architecture
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
)

:: Author:  Lisandro Dalcin
:: Contact: dalcinl@gmail.com
:: Credits: Olivier Grisel and Kyle Kastner
@ECHO OFF

SET COMMAND_TO_RUN=%*

SET PYTHON_VERSION_MAJOR=%PYTHON_VERSION:~0,1%
SET PYTHON_VERSION_MINOR=%PYTHON_VERSION:~2,1%

SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
IF %PYTHON_VERSION_MAJOR% == 2 SET WIN_SDK_VERSION="v7.0"
IF %PYTHON_VERSION_MAJOR% == 3 SET WIN_SDK_VERSION="v7.1"

IF %PYTHON_ARCH% == 64 SET USE_WIN_SDK=1
IF %PYTHON_VERSION_MAJOR% EQU 3 IF %PYTHON_VERSION_MINOR% GEQ 5 SET USE_WIN_SDK=0
IF %PYTHON_VERSION_MAJOR% GTR 3 SET USE_WIN_SDK=0
if %PYTHON_ARCH% == 32 SET USE_WIN_SDK=0

IF %USE_WIN_SDK% == 1 (
    ECHO Configuring Windows SDK %WIN_SDK_VERSION% for %PYTHON_ARCH% bit architecture
    SET DISTUTILS_USE_SDK=1
    SET MSSdk=1
    "%WIN_SDK_ROOT%\%WIN_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WIN_SDK_VERSION%
    "%WIN_SDK_ROOT%\%WIN_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
    ECHO Executing: %COMMAND_TO_RUN%
    CALL %COMMAND_TO_RUN% || EXIT 1
) ELSE (
    ECHO Using default MSVC build environment for %PYTHON_ARCH% bit architecture
    ECHO Executing: %COMMAND_TO_RUN%
    CALL %COMMAND_TO_RUN% || EXIT 1
)

Fix build for Python 3.5

AppVeyor: Fix build for Python 3.5


@ECHO OFF

REM SET HOME to HOMEPATH because with py2exe it doesn't work
SET HOME=%HOMEDRIVE%%HOMEPATH%

REM EXE_DIR=H:\Dev\projects\gmvault\dist\inst
SET EXE_DIR=@PATHTOREPLACE@
pushd %EXE_DIR%
gmv_cmd.exe %*
popd

@ECHO OFF

REM SET HOME to HOMEPATH because with py2exe it doesn't work
SET HOME=%HOMEDRIVE%%HOMEPATH%

REM EXE_DIR=H:\Dev\projects\gmvault\dist\inst
SET EXE_DIR=@PATHTOREPLACE@
pushd %EXE_DIR%
gmv_cmd.exe %*
set err=%errorlevel%
popd
;;return error code from gmv_cmd
exit /b %err%

return error code in windows

return error code in windows


@echo off

rem for /l %%a in (1,1,100) do (
set /p var=:
git add *
git commit -m %var%_%date:~0,10%
git push origin master
pause
rem )

@echo off

rem for /l %%a in (1,1,100) do (
set /p var=:
git add *
git commit -m "%var%_%date:~0,10%"
git push origin master
pause
rem )

test 12_2017/06/05

test 12_2017/06/05


echo ON

git clone https://github.com/StatisKit/Misc.git
if %errorlevel% neq 0 exit /b %errorlevel%

cd Misc/conda
if %errorlevel% neq 0 exit /b %errorlevel%

echo OFF

if "%BUILD_TARGETS%" == "" set BUILD_TARGETS="libboost python-scons"

echo ON

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
cd toolchain
call config.bat
cd ..
rmdir toolchain /s /q

for %%BUILD_TARGET in (%BUILD_TARGETS%) do (
    conda build %%BUILD_TARGET -c statiskit
    if %errorlevel% neq 0 exit /b %errorlevel%
)

echo ON

git clone https://github.com/StatisKit/Misc.git
if %errorlevel% neq 0 exit /b %errorlevel%

cd Misc/conda
if %errorlevel% neq 0 exit /b %errorlevel%

echo OFF

if "%BUILD_TARGETS%" == "" set BUILD_TARGETS="libboost python-scons"

echo ON

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
cd toolchain
call config.bat
cd ..
rmdir toolchain /s /q

for %%x in (%BUILD_TARGETS%) do (
    conda build %%x -c statiskit
    if %errorlevel% neq 0 exit /b %errorlevel%
)

Update bld.bat

Update bld.bat


del database.db
sqlite3 database.db < schema.sql
sqlite3 database.db < test.sql

Add db rebuild script for windows, assuming sqlite3 is in path


@echo off
setlocal

REM Script for building the LLVM installer on Windows,
REM used for the the weekly snapshots at http://www.llvm.org/builds.
REM
REM Usage: build_llvm_package.bat <revision>

REM Prerequisites:
REM
REM   Visual Studio 2013, CMake, Ninja, SVN, GNUWin32,
REM   NSIS with the strlen_8192 patch,
REM   Visual Studio 2013 SDK (for the clang-format plugin).

REM You may need to modify the paths below:
set vcdir=c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
set PATH=%PATH%;c:\gnuwin32\bin

set revision=%1
set branch=trunk
set package_version=3.8.0-r%revision%
set clang_format_vs_version=3.8.0.%revision%
set build_dir=llvm_package_%revision%

echo Branch: %branch%
echo Revision: %revision%
echo Package version: %package_version%
echo Clang format plugin version: %clang_format_vs_version%
echo Build dir: %build_dir%
echo.
pause

mkdir %build_dir%
cd %build_dir%

echo Checking out %branch% at r%revision%...
svn.exe export -r %revision% http://llvm.org/svn/llvm-project/llvm/%branch% llvm || exit /b
svn.exe export -r %revision% http://llvm.org/svn/llvm-project/cfe/%branch% llvm/tools/clang || exit /b
svn.exe export -r %revision% http://llvm.org/svn/llvm-project/clang-tools-extra/%branch% llvm/tools/clang/tools/extra || exit /b
svn.exe export -r %revision% http://llvm.org/svn/llvm-project/lld/%branch% llvm/tools/lld || exit /b
svn.exe export -r %revision% http://llvm.org/svn/llvm-project/compiler-rt/%branch% llvm/projects/compiler-rt || exit /b

set cmake_flags=-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON -DLLVM_USE_CRT_RELEASE=MT -DCLANG_FORMAT_VS_VERSION=%clang_format_vs_version% -DPACKAGE_VERSION=%package_version%

REM TODO: Run all tests, including lld and compiler-rt.

call "%vcdir%/vcvarsall.bat" x86
set CC=
set CXX=
mkdir build32_stage0
cd build32_stage0
cmake -GNinja %cmake_flags% ..\llvm || exit /b
ninja all || exit /b
ninja check || exit /b
ninja check-clang || exit /b
cd..

mkdir build32
cd build32
set CC=..\build32_stage0\bin\clang-cl
set CXX=..\build32_stage0\bin\clang-cl
cmake -GNinja %cmake_flags% -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON ..\llvm || exit /b
ninja all || exit /b
ninja check || exit /b
ninja check-clang || exit /b
copy ..\llvm\tools\clang\tools\clang-format-vs\ClangFormat\bin\Release\ClangFormat.vsix ClangFormat-r%revision%.vsix
ninja package || exit /b
cd ..

call "%vcdir%/vcvarsall.bat" amd64
set CC=
set CXX=
mkdir build64_stage0
cd build64_stage0
cmake -GNinja %cmake_flags%  ..\llvm || exit /b
ninja all || exit /b
ninja check || exit /b
ninja check-clang || exit /b
cd..

mkdir build64
cd build64
set CC=..\build64_stage0\bin\clang-cl
set CXX=..\build64_stage0\bin\clang-cl
cmake -GNinja %cmake_flags% ..\llvm || exit /b
ninja all || exit /b
ninja check || exit /b
ninja check-clang || exit /b
ninja package || exit /b
cd ..

Check in the script for building Win snapshots

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@255318 91177308-0d34-0410-b5e6-96231b3b80d8


:: test on windows

nosetests --exe -A "not slow and not network and not disabled" pandas %*

add windows test.bat

TST: add windows test.bat


@echo off

REM Copyright (c) 2013-2018 The PurpleI2P Project
REM This file is part of Purple i2pd project and licensed under BSD3
REM See full license text in LICENSE file at top of project tree

echo  7z 娢  ஬...
REM  室 砥 7z 娢,  ஬    Firefox, I2Pd, src  䠩 StartI2PdBrowser.exe ஢ .
7z a -t7z -m0=lzma2:d192m -mx=9 -aoa -mfb=273 -md=128m -ms=on -- I2PdBrowserPortable.7z ..\..\windows\Firefox ..\..\windows\i2pd ...\src\StartI2PdBrowser.bat ..\src\browser.ico

echo  7z SFX - ᠬᯠ뢠騩 娢...
REM  室 砥 ᠬᯠ뢠騩 娢, 娢 ᫥ ⮣ 㤠塞.
copy /b 7zsd_LZMA2_i2pdbrowser_1.2.7.sfx + config.txt + I2PdBrowserPortable.7z I2PdBrowserPortable_1.2.7.exe >> nul
del I2PdBrowserPortable.7z >> nul

echo ⮢!
pause

@echo off

REM Copyright (c) 2013-2018 The PurpleI2P Project
REM This file is part of Purple i2pd project and licensed under BSD3
REM See full license text in LICENSE file at top of project tree

echo  7z 娢  ஬...
REM  室 砥 7z 娢,  ஬    Firefox, I2Pd, src  䠩 StartI2PdBrowser.exe ஢ .
7z a -t7z -m0=lzma2:d192m -mx=9 -aoa -mfb=273 -md=128m -ms=on -- I2PdBrowserPortable.7z ..\..\windows\Firefox ..\..\windows\i2pd ..\src\StartI2PdBrowser.bat ..\src\browser.ico

echo  7z SFX - ᠬᯠ뢠騩 娢...
REM  室 砥 ᠬᯠ뢠騩 娢, 娢 ᫥ ⮣ 㤠塞.
copy /b 7zsd_LZMA2_i2pdbrowser_1.2.7.sfx + config.txt + I2PdBrowserPortable.7z I2PdBrowserPortable_1.2.7.exe >> nul
del I2PdBrowserPortable.7z >> nul

echo ⮢!
pause

delete one dot in path

delete one dot in path

Former-commit-id: 65e72bc454cb91474d3870f05f6decae3739036b


@echo off

set MAPNIK_VERSION=v2.2.0
set MAPNIK_PREFIX=c:\\mapnik-%MAPNIK_VERSION%
set MAPNIK_LIBS=%MAPNIK_PREFIX%\\lib
set MAPNIK_INCLUDES=%MAPNIK_PREFIX%\\include
set MAPNIK_INPUT_PLUGINS_DIRECTORY=%MAPNIK_PREFIX%\\input
set MAPNIK_FONTS_DIRECTORY=%MAPNIK_PREFIX%\\fonts

if /i "%1"=="" goto help
if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help
if /i "%1"=="--prefix" echo %MAPNIK_PREFIX%
if /i "%1"=="--libs" echo mapnik.lib
@rem TODO - figure out how to avoid hardcoding these library names
if /i "%1"=="--dep-libs" echo icuuc.lib icuin.lib libboost_system-vc100-mt-s-1_49.lib
if /i "%1"=="--ldflags" echo %MAPNIK_LIBS%
if /i "%1"=="--defines" echo _WINDOWS HAVE_JPEG HAVE_PNG HAVE_TIFF MAPNIK_USE_PROJ4 BOOST_REGEX_HAS_ICU MAPNIK_THREADSAFE BIGINT HAVE_LIBXML2 HAVE_CAIRO
@rem /MD is multithreaded dynamic linking - http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
@rem /EHsc is to support c++ exceptions - http://msdn.microsoft.com/en-us/library/1deeycx5(v=vs.80).aspx
@rem /GR is to support rtti (runtime type detection) - http://msdn.microsoft.com/en-us/library/we6hfdy0.aspx
if /i "%1"=="--cxxflags" echo /MD /EHsc /GR
if /i "%1"=="--includes" echo %MAPNIK_INCLUDES% %MAPNIK_INCLUDES%\\mapnik\\agg
if /i "%1"=="--dep-includes" echo
if /i "%1"=="--input-plugins" echo %MAPNIK_INPUT_PLUGINS_DIRECTORY%
if /i "%1"=="--fonts" echo %MAPNIK_FONTS_DIRECTORY%
goto exit

:help
echo mapnik-config.bat
echo Examples:
echo   --libs            : provide lib name for mapnik.dll
echo   --defines         : provide compiler defines needed for this mapnik build
echo   --dep-libs        : provide lib names of depedencies
echo   --ldflags         : provide lib paths to depedencies
echo   --cxxflags        : provide compiler flags
echo   --includes        : provide header paths for mapnik
echo   --dep-includes    : provide header paths for dependencies
echo   --input-plugins   : provide path to input plugins directory
echo   --fonts           : provide path to fonts directory
goto exit

:exit
goto :EOF

@echo off

set MAPNIK_VERSION=v2.2.0
set MAPNIK_PREFIX=c:\\mapnik-%MAPNIK_VERSION%
set MAPNIK_LIBS=%MAPNIK_PREFIX%\\lib
set MAPNIK_INCLUDES=%MAPNIK_PREFIX%\\include
set MAPNIK_INPUT_PLUGINS_DIRECTORY=%MAPNIK_PREFIX%\\lib\\mapnik\\input
set MAPNIK_FONTS_DIRECTORY=%MAPNIK_PREFIX%\\lib\\mapnik\\fonts

if /i "%1"=="" goto help
if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help
if /i "%1"=="--prefix" echo %MAPNIK_PREFIX%
if /i "%1"=="--libs" echo mapnik.lib
@rem TODO - figure out how to avoid hardcoding these library names
if /i "%1"=="--dep-libs" echo icuuc.lib icuin.lib libboost_system-vc100-mt-s-1_49.lib
if /i "%1"=="--ldflags" echo %MAPNIK_LIBS%
if /i "%1"=="--defines" echo _WINDOWS HAVE_JPEG HAVE_PNG HAVE_TIFF MAPNIK_USE_PROJ4 BOOST_REGEX_HAS_ICU MAPNIK_THREADSAFE BIGINT HAVE_LIBXML2 HAVE_CAIRO
@rem /MD is multithreaded dynamic linking - http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
@rem /EHsc is to support c++ exceptions - http://msdn.microsoft.com/en-us/library/1deeycx5(v=vs.80).aspx
@rem /GR is to support rtti (runtime type detection) - http://msdn.microsoft.com/en-us/library/we6hfdy0.aspx
if /i "%1"=="--cxxflags" echo /MD /EHsc /GR
if /i "%1"=="--includes" echo %MAPNIK_INCLUDES% %MAPNIK_INCLUDES%\\mapnik\\agg
if /i "%1"=="--dep-includes" echo
if /i "%1"=="--input-plugins" echo %MAPNIK_INPUT_PLUGINS_DIRECTORY%
if /i "%1"=="--fonts" echo %MAPNIK_FONTS_DIRECTORY%
goto exit

:help
echo mapnik-config.bat
echo Examples:
echo   --libs            : provide lib name for mapnik.dll
echo   --defines         : provide compiler defines needed for this mapnik build
echo   --dep-libs        : provide lib names of depedencies
echo   --ldflags         : provide lib paths to depedencies
echo   --cxxflags        : provide compiler flags
echo   --includes        : provide header paths for mapnik
echo   --dep-includes    : provide header paths for dependencies
echo   --input-plugins   : provide path to input plugins directory
echo   --fonts           : provide path to fonts directory
goto exit

:exit
goto :EOF

fix plugins and fonts path in mapnik-config.bat


@echo off

git rev-parse > version.txt
bundle exec middleman build %*

@echo off

git rev-parse HEAD > version.txt
bundle exec middleman build %*

Add missing argument.

Add missing argument.


:: Start with bootstrap
cd .\tools\build
dir .
:: CALL .\bootstrap.bat
:: IF errorlevel 1 exit 1
:: dir .
:: CALL .\bootstrap.bat mingw
:: IF errorlevel 1 exit 1
:: cd ..\..
:: dir .
:: CALL .\tools\build\b2.exe install toolset=gcc --prefix=%LIBRARY_PREFIX%
:: dir .
:: set PATH=%PATH%;%LIBRARY_BIN%

:: Build step
:: CALL b2 install ^
::     --build-dir=buildboost ^
::     --prefix=%LIBRARY_PREFIX% ^
::     toolset=gcc ^
::     address-model=%ARCH% ^
::     variant=release ^
::     threading=multi ^
::     link=shared ^
::     -j%CPU_COUNT% ^
::     -s ZLIB_INCLUDE="%LIBRARY_INC%" ^
::     -s ZLIB_LIBPATH="%LIBRARY_LIB%" ^
::     --with-python
:: IF errorlevel 1 exit 1

:: :: Install fix-up for a non version-specific boost include
:: move %LIBRARY_INC%\boost-1_61\boost %LIBRARY_INC%
:: IF errorlevel 1 exit 1

:: Move dll's to LIBRARY_BIN
:: move %LIBRARY_LIB%\*vc%LIB_VER%-mt-1_61.dll "%LIBRARY_BIN%"
:: IF errorlevel 1 exit 1
:: Status API Training Shop Blog About

:: Start with bootstrap
cd .\tools\build
dir .
:: CALL .\bootstrap.bat
:: IF errorlevel 1 exit 1
:: dir .
CALL .\bootstrap.bat mingw
IF errorlevel 1 exit 1
:: cd ..\..
:: dir .
:: CALL .\tools\build\b2.exe install toolset=gcc --prefix=%LIBRARY_PREFIX%
:: dir .
:: set PATH=%PATH%;%LIBRARY_BIN%

:: Build step
:: CALL b2 install ^
::     --build-dir=buildboost ^
::     --prefix=%LIBRARY_PREFIX% ^
::     toolset=gcc ^
::     address-model=%ARCH% ^
::     variant=release ^
::     threading=multi ^
::     link=shared ^
::     -j%CPU_COUNT% ^
::     -s ZLIB_INCLUDE="%LIBRARY_INC%" ^
::     -s ZLIB_LIBPATH="%LIBRARY_LIB%" ^
::     --with-python
:: IF errorlevel 1 exit 1

:: :: Install fix-up for a non version-specific boost include
:: move %LIBRARY_INC%\boost-1_61\boost %LIBRARY_INC%
:: IF errorlevel 1 exit 1

:: Move dll's to LIBRARY_BIN
:: move %LIBRARY_LIB%\*vc%LIB_VER%-mt-1_61.dll "%LIBRARY_BIN%"
:: IF errorlevel 1 exit 1
:: Status API Training Shop Blog About

Update bld.bat

Update bld.bat


:: Start with bootstrap
cd .\tools\build
ECHO .\bootstrap.bat
CALL .\bootstrap.bat
IF errorlevel 1 exit 1
ECHO .\bootstrap.bat gcc
CALL .\bootstrap.bat gcc
IF errorlevel 1 exit 1
ECHO .\b2.exe install toolset=gcc --prefix=%SRC_DIR%\b2_for_mingw
CALL .\b2.exe install toolset=gcc --prefix=%SRC_DIR%\b2_for_mingw
IF errorlevel 1 exit 1
ECHO cd %SRC_DIR%
cd %SRC_DIR%
IF errorlevel 1 exit 1
set PATH=%PATH%;%SRC_DIR%\b2_for_mingw\bin
IF errorlevel 1 exit 1
ECHO b2 install toolset=gcc --build-type=complete stage ^
        --build-dir=buildboost ^
        --prefix=%LIBRARY_PREFIX% ^
        address-model=%ARCH% ^
        variant=release ^
        threading=multi ^
        link=shared ^
        -j%CPU_COUNT% ^
        -s ZLIB_INCLUDE="%LIBRARY_INC%" ^
        -s ZLIB_LIBPATH="%LIBRARY_LIB%" ^
        --with-python
CALL b2 install toolset=gcc ^
        address-model=%ARCH% ^
        variant=release ^
        threading=multi ^
        link=shared ^
        -j%CPU_COUNT% ^
        -s ZLIB_INCLUDE="%LIBRARY_INC%" ^
        -s ZLIB_LIBPATH="%LIBRARY_LIB%" ^
        --with-python ^
        --build-dir=buildboost ^
        --prefix=%LIBRARY_PREFIX%
IF errorlevel 1 exit 1
ECHO dir  %LIBRARY_INC%
CALL dir  %LIBRARY_INC%
move %LIBRARY_INC%\boost-1_61\boost %LIBRARY_INC%
IF errorlevel 1 exit 1
ECHO dir  %LIBRARY_INC%
CALL dir  %LIBRARY_INC%

ECHO dir %LIBRARY_LIB%
CALL dir %LIBRARY_LIB%
move %LIBRARY_LIB%\*vc%LIB_VER%-mt-1_61.dll "%LIBRARY_BIN%"
IF errorlevel 1 exit 1

:: Start with bootstrap
cd .\tools\build
ECHO .\bootstrap.bat
CALL .\bootstrap.bat
IF errorlevel 1 exit 1
ECHO .\bootstrap.bat gcc
CALL .\bootstrap.bat gcc
IF errorlevel 1 exit 1
ECHO .\b2.exe install toolset=gcc --prefix=%SRC_DIR%\b2_for_mingw
CALL .\b2.exe install toolset=gcc --prefix=%SRC_DIR%\b2_for_mingw
IF errorlevel 1 exit 1
ECHO cd %SRC_DIR%
cd %SRC_DIR%
IF errorlevel 1 exit 1
set PATH=%PATH%;%SRC_DIR%\b2_for_mingw\bin
IF errorlevel 1 exit 1
ECHO b2 install toolset=gcc --build-type=complete stage ^
        --build-dir=buildboost ^
        --prefix=%LIBRARY_PREFIX% ^
        address-model=%ARCH% ^
        variant=release ^
        threading=multi ^
        link=shared ^
        -j%CPU_COUNT% ^
        -s ZLIB_INCLUDE="%LIBRARY_INC%" ^
        -s ZLIB_LIBPATH="%LIBRARY_LIB%" ^
        --with-python
CALL b2 install toolset=gcc ^
        address-model=%ARCH% ^
        variant=release ^
        threading=multi ^
        link=shared ^
        -j%CPU_COUNT% ^
        -s ZLIB_INCLUDE="%LIBRARY_INC%" ^
        -s ZLIB_LIBPATH="%LIBRARY_LIB%" ^
        --with-python ^
        --build-dir=buildboost ^
        --prefix=%LIBRARY_PREFIX%
IF errorlevel 1 exit 1
ECHO dir  %LIBRARY_INC%
CALL dir  %LIBRARY_INC%
move %LIBRARY_INC%\boost-1_61\boost %LIBRARY_INC%
IF errorlevel 1 exit 1
ECHO dir  %LIBRARY_INC%
CALL dir  %LIBRARY_INC%

ECHO dir %LIBRARY_LIB%
CALL dir %LIBRARY_LIB%
move %LIBRARY_LIB%\*mingw*-mt-1_61.dll "%LIBRARY_BIN%"
IF errorlevel 1 exit 1

Update bld.bat

Update bld.bat


powershell -ExecutionPolicy Bypass -command "(Get-AuthenticodeSignature \"C:\Temp\CatalogPC.cab\").Status -eq 'Valid'"

REM https://stackoverflow.com/a/19876949
REM https://linux.die.net/man/1/chktrust
REM http://manpages.ubuntu.com/manpages/trusty/man1/chktrust.1.html

Update PS_VerifyFileSig.bat

Update PS_VerifyFileSig.bat

chktrust from mono project seems like it can verify signatures, but NOT of CAB files it seems.


@echo off

echo Building dependencies...

if exist lib (rd lib /q /s)
md lib
cd lib
md Debug
md Release
cd ../

REM If your path is different with blow, please change to your install path
set %VS150COMNTOOLS%=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\
echo "%VS150COMNTOOLS%..\IDE\Devenv"

REM ######################################################################################################
echo Building protobuf...

if exist protobuf (rd protobuf /q /s)
git clone -b 3.5.x https://github.com/google/protobuf.git

cd protobuf/cmake
md build
cd build
cmake -G "Visual Studio 15 Win64" -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF ..
"%VS150COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Debug|x64"
"%VS150COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Release|x64"
copy Debug\*.dll ..\..\..\lib\Debug /Y
copy Debug\*.lib ..\..\..\lib\Debug /Y
copy Release\*.dll ..\..\..\lib\Release /Y
copy Release\*.lib ..\..\..\lib\Release /Y

copy Release\libprotobuf.dll ..\..\..\..\Frame\SDK\Proto\proto-gen /Y
copy Release\libprotoc.dll ..\..\..\..\Frame\SDK\Proto\proto-gen /Y
copy Release\protoc.exe ..\..\..\..\Frame\SDK\Proto\proto-gen /Y

cd ..\..\..\
REM ######################################################################################################
echo Building libevent...

if exist libevent (rd libevent /q /s)
git clone -b master https://github.com/libevent/libevent.git

cd libevent
md build
cd build
cmake -G "Visual Studio 15 Win64" -DEVENT__DISABLE_OPENSSL=ON ..
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_core_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_core_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_extra_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_extra_static.vcxproj
copy lib\Debug\*.lib ..\..\lib\Debug /Y
copy lib\Release\*.lib ..\..\lib\Release /Y
cd ..\..\
REM ######################################################################################################
echo Building evpp...
if exist evpp (rd evpp /q /s)
git clone -b master https://github.com/ArkGame/evpp.git

cd evpp
md build
cd build
cmake -G "Visual Studio 15 Win64" -DLIBEVENT_DIR=..\libevent -DLIBEVENT_LIB_DIR=..\lib\Release ..
"%VS150COMNTOOLS%..\IDE\Devenv" evpp.sln /build "Debug|x64" /project evpp/evpp_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" evpp.sln /build "Release|x64" /project evpp/evpp_static.vcxproj
copy lib\Debug\*.lib ..\..\lib\Debug /Y
copy lib\Release\*.lib ..\..\lib\Release /Y

cd ..\..\
REM ####################################################################################################
REM back to root dir
cd ..\

add dep build script for vs2017

add dep build script for vs2017

Former-commit-id: a3047942f988b76a16dc9b3d226564d552f92af1
Former-commit-id: 480bac538ce6d71935e220f8cc17bf358eca262c


@echo off
setlocal
set mypath=%~dp0
set PATH=%mypath%\python2.7;%PATH%
set PYTHONPATH=%mypath%\lib
set OQ_SITE_CFG_PATH=%mypath%\openquake.cfg

doskey oq=python.exe -m openquake.commands.__main__ $*
doskey oq-engine=python.exe -m openquake.commands.__main__ engine $*

echo OpenQuake environment loaded
echo The command 'oq-engine' is deprecated and will be removed. Please use 'oq engine' instead
cmd /k

endlocal

@echo off
setlocal
set mypath=%~dp0
set PATH=%mypath%\python2.7\Scripts;%mypath%\python2.7;%PATH%
set PYTHONPATH=%mypath%\lib
set OQ_SITE_CFG_PATH=%mypath%\openquake.cfg

doskey oq=python.exe -m openquake.commands.__main__ $*
doskey oq-engine=python.exe -m openquake.commands.__main__ engine $*

echo OpenQuake environment loaded
echo The command 'oq-engine' is deprecated and will be removed. Please use 'oq engine' instead
cmd /k

endlocal

Add python2.7\Scripts to PATH on Win

Add python2.7\Scripts to PATH on Win


:: Copyright (c) 2018 Google LLC.
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
::     http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::
:: Windows Build Script.

@echo on

set BUILD_ROOT=%cd%
set SRC=%cd%\github\SPIRV-Tools
set BUILD_TYPE=%1
set VS_VERSION=%2

:: Force usage of python 2.7 rather than 3.6
set PATH=C:\python27;%PATH%

cd %SRC%
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers
git clone --depth=1 https://github.com/google/googletest          external/googletest
git clone --depth=1 https://github.com/google/effcee              external/effcee
git clone --depth=1 https://github.com/google/re2                 external/re2

:: #########################################
:: set up msvc build env
:: #########################################
if %VS_VERSION% == 2017 (
  call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
  echo "Using VS 2017..."
) else if %VS_VERSION% == 2015 (
  call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
  echo "Using VS 2015..."
) else if %VS_VERSION% == 2013 (
  call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
  echo "Using VS 2013..."
)

cd %SRC%
mkdir build
cd build

:: #########################################
:: Start building.
:: #########################################
echo "Starting build... %DATE% %TIME%"
if "%KOKORO_GITHUB_COMMIT%." == "." (
  set BUILD_SHA=%KOKORO_GITHUB_PULL_REQUEST_COMMIT%
) else (
  set BUILD_SHA=%KOKORO_GITHUB_COMMIT%
)

:: Skip building tests for VS2013
if %VS_VERSION% == 2013 (
  cmake -GNinja -DSPIRV_SKIP_TESTS=ON -DSPIRV_BUILD_COMPRESSION=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_INSTALL_PREFIX=install -DRE2_BUILD_TESTING=OFF -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe ..
) else (
  cmake -GNinja -DSPIRV_BUILD_COMPRESSION=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_INSTALL_PREFIX=install -DRE2_BUILD_TESTING=OFF -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe ..
)

if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%

echo "Build everything... %DATE% %TIME%"
ninja
if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%
echo "Build Completed %DATE% %TIME%"

:: ################################################
:: Run the tests (We no longer run tests on VS2013)
:: ################################################
if NOT %VS_VERSION% == 2013 (
  echo "Running Tests... %DATE% %TIME%"
  ctest -C %BUILD_TYPE% --output-on-failure --timeout 300
  if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%
  echo "Tests Completed %DATE% %TIME%"
)

:: Clean up some directories.
rm -rf %SRC%\build
rm -rf %SRC%\external

exit /b %ERRORLEVEL%

:: Copyright (c) 2018 Google LLC.
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
::     http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::
:: Windows Build Script.

@echo on

set BUILD_ROOT=%cd%
set SRC=%cd%\github\SPIRV-Tools
set BUILD_TYPE=%1
set VS_VERSION=%2

:: Force usage of python 2.7 rather than 3.6
set PATH=C:\python27;%PATH%

cd %SRC%
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers
git clone --depth=1 https://github.com/google/googletest          external/googletest
git clone --depth=1 https://github.com/google/effcee              external/effcee
git clone --depth=1 https://github.com/google/re2                 external/re2

:: #########################################
:: set up msvc build env
:: #########################################
if %VS_VERSION% == 2017 (
  call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
  echo "Using VS 2017..."
) else if %VS_VERSION% == 2015 (
  call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
  echo "Using VS 2015..."
) else if %VS_VERSION% == 2013 (
  call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
  echo "Using VS 2013..."
)

cd %SRC%
mkdir build
cd build

:: #########################################
:: Start building.
:: #########################################
echo "Starting build... %DATE% %TIME%"
if "%KOKORO_GITHUB_COMMIT%." == "." (
  set BUILD_SHA=%KOKORO_GITHUB_PULL_REQUEST_COMMIT%
) else (
  set BUILD_SHA=%KOKORO_GITHUB_COMMIT%
)

set CMAKE_FLAGS=-GNinja -DSPIRV_BUILD_COMPRESSION=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_INSTALL_PREFIX=install -DRE2_BUILD_TESTING=OFF -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe

:: Skip building tests for VS2013
if %VS_VERSION% == 2013 (
  set CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_SKIP_TESTS=ON
)

cmake %CMAKE_FLAGS% ..

if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%

echo "Build everything... %DATE% %TIME%"
ninja
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
echo "Build Completed %DATE% %TIME%"

:: This lets us use !ERRORLEVEL! inside an IF ... () and get the actual error at that point.
setlocal ENABLEDELAYEDEXPANSION

:: ################################################
:: Run the tests (We no longer run tests on VS2013)
:: ################################################
echo "Running Tests... %DATE% %TIME%"
if %VS_VERSION% NEQ 2013 (
  ctest -C %BUILD_TYPE% --output-on-failure --timeout 300
  if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL!
)
echo "Tests Completed %DATE% %TIME%"

:: Clean up some directories.
rm -rf %SRC%\build
rm -rf %SRC%\external

exit /b 0

[kokoro] Fix usage of ERRORLEVEL in Windows script. (#2262)


@echo off
setlocal
call NightlyBuild.cmd
set PackageDir=%~dp0LocalPackages
call dnu restore dnx\src\Microsoft.DotNet.xunit.performance.runner.dnx\project.json -f %PackageDir%
call dnu pack dnx\src\Microsoft.DotNet.xunit.performance.runner.dnx\project.json --out %PackageDir% --configuration Release

@echo off
setlocal
call NightlyBuild.cmd
set PackageDir=%~dp0LocalPackages
pushd %~dp0dnx\src\Microsoft.DotNet.xunit.performance.runner.dnx
call dnu restore
call dnu pack --out %PackageDir% --configuration Release
popd

Fix BuildForPublishcation.cmd Apparently the paths in nuget.config are relative to the *current* directory...


start /WAIT %1
IF ERRORLEVEL 1 ECHO ERRORLEVEL > %2

write marker on windows installer fail.

write marker on windows installer fail.


mkdir build
cd build

cmake ^
    -G "Ninja" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DBUILD_TESTING:BOOL=ON ^
    %SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

:: Test.
ctest --output-on-failure -C Release
if errorlevel 1 exit 1

Create bld.bat

Create bld.bat


@echo off

cmake -G "Visual Studio 14 2015 Win64"  %"Set the generator to Visual Studio 2015 x64"% ^
      -T "v140_clang_3_7"               %"Set the compiler toolchain to Clang/C2"% ^
      -H%~dp0\..                        %"Set the source directory to the parent directory"% ^
      -B%~dp0\..\_build_clang           %"Set the build directory to the _build_clang subdirectory"% ^
      %*                                %"Forward additional command line arguments to CMake"%

@echo on

@echo off

cmake -G "Visual Studio 14 2015 Win64"  %"Set the generator to Visual Studio 2015 x64"% ^
      -T "v140_clang_c2"                %"Set the compiler toolchain to Clang/C2"% ^
      -H%~dp0\..                        %"Set the source directory to the parent directory"% ^
      -B%~dp0\..\_build_clang           %"Set the build directory to the _build_clang subdirectory"% ^
      %*                                %"Forward additional command line arguments to CMake"%

@echo on

Update Clang/C2 batch file with new toolchain name


%CONDA_PREFIX%\Library\libexec\tests -[random]
if errorlevel 1 exit 1

%CONDA_PREFIX%\Library\libexec\tests ~[random]
if errorlevel 1 exit 1

fix cmdline for testing on windows

FIX: fix cmdline for testing on windows


@echo off
setlocal

set DATALOADER_VERSION=@@FULL_VERSION@@
for /f "tokens=1 delims=." %%a in ("%DATALOADER_VERSION%") do (
  set DATALOADER_SHORT_VERSION=%%a
)
set DATALOADER_UBER_JAR_NAME=dataloader-%DATALOADER_VERSION%-uber.jar
set MIN_JAVA_VERSION=@@MIN_JAVA_VERSION@@

echo.
echo *************************************************************************
echo **            ___  ____ ___ ____   _    ____ ____ ___  ____ ____       **
echo **            ^|  \ ^|__^|  ^|  ^|__^|   ^|    ^|  ^| ^|__^| ^|  \ ^|___ ^|__/       **
echo **            ^|__/ ^|  ^|  ^|  ^|  ^|   ^|___ ^|__^| ^|  ^| ^|__/ ^|___ ^|  \       **
echo **                                                                     **
echo **  Data Loader v%DATALOADER_SHORT_VERSION% is a Salesforce supported Open Source project to   **
echo **  help you import data to and export data from your Salesforce org.  **
echo **  It requires Java JRE %MIN_JAVA_VERSION% or later to run.                           **
echo **                                                                     **
echo **  Github Project Url:                                                **
echo **       https://github.com/forcedotcom/dataloader                     **
echo **  Salesforce Documentation:                                          **
echo **       https://help.salesforce.com/articleView?id=data_loader.htm    **
echo **                                                                     **
echo *************************************************************************
echo.

echo Data Loader installation requires you to provide an installation directory to create a version-specific subdirectory for the installation artifacts.
echo It uses '%USERPROFILE%\^<relative path^>' as the installation directory if you provide a relative path for the installation directory.
echo.
set /p DIR_NAME=Provide the installation directory [default: dataloader] : || set DIR_NAME=dataloader

if "%DIR_NAME:~1,1%" == ":" (
    REM absolute path specified
    set INSTALLATION_DIR=%DIR_NAME%\v%DATALOADER_VERSION%
) else (
    if "%DIR_NAME:~0,1%" == "\" (
        REM absolute path specified
        set INSTALLATION_DIR=%DIR_NAME%\v%DATALOADER_VERSION%
    ) else (
        REM relative path specified
        set INSTALLATION_DIR=%USERPROFILE%\%DIR_NAME%\v%DATALOADER_VERSION%
    )
)

IF EXIST %INSTALLATION_DIR% (
    goto ExistingDir
) ELSE (
    goto CopyFiles
)

:ExistingDir
    echo.
    echo Do you want to overwrite previously installed versions of Data Loader v%DATALOADER_VERSION% and configurations in '%INSTALLATION_DIR%'?
    set /p DELETE_EXISTING_DIR=If not, installation will quit and you can restart installation using another directory.[Yes/No]
    if /I "%DELETE_EXISTING_DIR%"=="Y" goto DeleteDirYes
    if /I "%DELETE_EXISTING_DIR%"=="Yes" goto DeleteDirYes
    if /I "%DELETE_EXISTING_DIR%"=="N" goto DeleteDirNo
    if /I "%DELETE_EXISTING_DIR%"=="No" goto DeleteDirNo
    echo Type Yes or No.
    goto ExistingDir
:DeleteDirYes
    echo Deleting existing Data Loader v%DATALOADER_VERSION%...
    rd /s /q "%INSTALLATION_DIR%"
    goto CopyFiles
:DeleteDirNo
    goto Exit

:CopyFiles
    echo.
    set SRC_DIR=%~dp0
    IF %SRC_DIR:~-1%==\ SET SRC_DIR=%SRC_DIR:~0,-1%
    echo Copying files from '%SRC_DIR%' to '%INSTALLATION_DIR%'  ...
    xcopy "%SRC_DIR%" "%INSTALLATION_DIR%" /e /i
    del "%INSTALLATION_DIR%\install.bat" /q
    rmdir "%INSTALLATION_DIR%\META-INF" /s /q
    echo Your Data Loader v%DATALOADER_VERSION% is created in '%INSTALLATION_DIR%'

:CreateStartMenuShortCut
    echo.
    set /p REPLY=Would you like to create a start menu shortcut? [Yes/No]
    if /I "%REPLY%"=="Y" goto StartMenuShortCutYes
    if /I "%REPLY%"=="Yes" goto StartMenuShortCutYes
    if /I "%REPLY%"=="N" goto StartMenuShortCutNo
    if /I "%REPLY%"=="No" goto StartMenuShortCutNo
    echo Type Yes or No.
    goto CreateStartMenuShortCut
:StartMenuShortCutNo
    goto CreateDesktopShortcut
:StartMenuShortCutYes
    IF NOT EXIST "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce\" (
        mkdir "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce"
    )
    powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut(""""$Home\Desktop\Dataloader.lnk""""); $Shortcut.WorkingDirectory = """"$env:INSTALLATION_DIR""""; $Shortcut.TargetPath = """"$env:INSTALLATION_DIR\dataloader.bat""""; $Shortcut.IconLocation = """"$env:INSTALLATION_DIR\dataloader.ico""""; $Shortcut.WindowStyle=7; $Shortcut.Save()"
    move "%USERPROFILE%\Desktop\Dataloader.lnk" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce\Dataloader %DATALOADER_VERSION%.lnk" >nul

:CreateDesktopShortcut
    echo.
    set /p REPLY=Would you like to create a desktop icon? [Yes/No]
    if /I "%REPLY%"=="Y" goto StartMenuShortCutYes
    if /I "%REPLY%"=="Yes" goto StartMenuShortCutYes
    if /I "%REPLY%"=="N" goto StartMenuShortCutNo
    if /I "%REPLY%"=="No" goto StartMenuShortCutNo
    echo Type Yes or No.
    goto CreateDesktopShortcut
:StartMenuShortCutNo
    goto Exit
:StartMenuShortCutYes
    powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut(""""$Home\Desktop\Dataloader.lnk""""); $Shortcut.WorkingDirectory = """"$env:INSTALLATION_DIR""""; $Shortcut.TargetPath = """"$env:INSTALLATION_DIR\dataloader.bat""""; $Shortcut.IconLocation = """"$env:INSTALLATION_DIR\dataloader.ico""""; $Shortcut.WindowStyle=7; $Shortcut.Save()"
    move "%USERPROFILE%\Desktop\Dataloader.lnk" "%USERPROFILE%\Desktop\Dataloader %DATALOADER_VERSION%.lnk" >nul

:Exit
    echo.
    echo Data Loader installation is quitting.
    endlocal
    PAUSE

@echo off
setlocal

set DATALOADER_VERSION=@@FULL_VERSION@@
for /f "tokens=1 delims=." %%a in ("%DATALOADER_VERSION%") do (
  set DATALOADER_SHORT_VERSION=%%a
)
set DATALOADER_UBER_JAR_NAME=dataloader-%DATALOADER_VERSION%-uber.jar
set MIN_JAVA_VERSION=@@MIN_JAVA_VERSION@@

echo.
echo *************************************************************************
echo **            ___  ____ ___ ____   _    ____ ____ ___  ____ ____       **
echo **            ^|  \ ^|__^|  ^|  ^|__^|   ^|    ^|  ^| ^|__^| ^|  \ ^|___ ^|__/       **
echo **            ^|__/ ^|  ^|  ^|  ^|  ^|   ^|___ ^|__^| ^|  ^| ^|__/ ^|___ ^|  \       **
echo **                                                                     **
echo **  Data Loader v%DATALOADER_SHORT_VERSION% is a Salesforce supported Open Source project to   **
echo **  help you import data to and export data from your Salesforce org.  **
echo **  It requires Java JRE %MIN_JAVA_VERSION% or later to run.                           **
echo **                                                                     **
echo **  Github Project Url:                                                **
echo **       https://github.com/forcedotcom/dataloader                     **
echo **  Salesforce Documentation:                                          **
echo **       https://help.salesforce.com/articleView?id=data_loader.htm    **
echo **                                                                     **
echo *************************************************************************
echo.

echo Data Loader installation requires you to provide an installation directory to create a version-specific subdirectory for the installation artifacts.
echo It uses '%USERPROFILE%\^<relative path^>' as the installation directory if you provide a relative path for the installation directory.
echo.
set /p DIR_NAME=Provide the installation directory [default: dataloader] : || set DIR_NAME=dataloader

if "%DIR_NAME:~1,1%" == ":" (
    REM absolute path specified
    set INSTALLATION_DIR=%DIR_NAME%\v%DATALOADER_VERSION%
) else (
    if "%DIR_NAME:~0,1%" == "\" (
        REM absolute path specified
        set INSTALLATION_DIR=%DIR_NAME%\v%DATALOADER_VERSION%
    ) else (
        REM relative path specified
        set INSTALLATION_DIR=%USERPROFILE%\%DIR_NAME%\v%DATALOADER_VERSION%
    )
)

IF EXIST %INSTALLATION_DIR% (
    goto ExistingDir
) ELSE (
    goto CopyFiles
)

:ExistingDir
    echo.
    echo Do you want to overwrite previously installed versions of Data Loader v%DATALOADER_VERSION% and configurations in '%INSTALLATION_DIR%'?
    set /p DELETE_EXISTING_DIR=If not, installation will quit and you can restart installation using another directory.[Yes/No]
    if /I "%DELETE_EXISTING_DIR%"=="Y" goto DeleteDirYes
    if /I "%DELETE_EXISTING_DIR%"=="Yes" goto DeleteDirYes
    if /I "%DELETE_EXISTING_DIR%"=="N" goto DeleteDirNo
    if /I "%DELETE_EXISTING_DIR%"=="No" goto DeleteDirNo
    echo Type Yes or No.
    goto ExistingDir
:DeleteDirYes
    echo Deleting existing Data Loader v%DATALOADER_VERSION%...
    rd /s /q "%INSTALLATION_DIR%"
    goto CopyFiles
:DeleteDirNo
    goto Exit

:CopyFiles
    echo.
    set SRC_DIR=%~dp0
    IF %SRC_DIR:~-1%==\ SET SRC_DIR=%SRC_DIR:~0,-1%
    echo Copying files from '%SRC_DIR%' to '%INSTALLATION_DIR%'  ...
    xcopy "%SRC_DIR%" "%INSTALLATION_DIR%" /e /i
    del "%INSTALLATION_DIR%\install.bat" /q
    rmdir "%INSTALLATION_DIR%\META-INF" /s /q
    echo Your Data Loader v%DATALOADER_VERSION% is created in '%INSTALLATION_DIR%'

:CreateStartMenuShortCut
    echo.
    set /p REPLY=Would you like to create a start menu shortcut? [Yes/No]
    if /I "%REPLY%"=="Y" goto StartMenuShortCutYes
    if /I "%REPLY%"=="Yes" goto StartMenuShortCutYes
    if /I "%REPLY%"=="N" goto StartMenuShortCutNo
    if /I "%REPLY%"=="No" goto StartMenuShortCutNo
    echo Type Yes or No.
    goto CreateStartMenuShortCut
:StartMenuShortCutNo
    goto CreateDesktopShortcut
:StartMenuShortCutYes
    IF NOT EXIST "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce\" (
        mkdir "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce"
    )
    powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut(""""$Home\Desktop\Dataloader.lnk""""); $Shortcut.WorkingDirectory = """"$env:INSTALLATION_DIR""""; $Shortcut.TargetPath = """"$env:INSTALLATION_DIR\dataloader.bat""""; $Shortcut.IconLocation = """"$env:INSTALLATION_DIR\dataloader.ico""""; $Shortcut.WindowStyle=7; $Shortcut.Save()"
    move "%USERPROFILE%\Desktop\Dataloader.lnk" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce\Dataloader %DATALOADER_VERSION%.lnk" >nul

:CreateDesktopShortcut
    echo.
    set /p REPLY=Would you like to create a desktop icon? [Yes/No]
    if /I "%REPLY%"=="Y" goto DesktopShortCutYes
    if /I "%REPLY%"=="Yes" goto DesktopShortCutYes
    if /I "%REPLY%"=="N" goto DesktopShortCutNo
    if /I "%REPLY%"=="No" goto DesktopShortCutNo
    echo Type Yes or No.
    goto CreateDesktopShortcut
:DesktopShortCutNo
    goto Exit
:DesktopShortCutYes
    powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut(""""$Home\Desktop\Dataloader.lnk""""); $Shortcut.WorkingDirectory = """"$env:INSTALLATION_DIR""""; $Shortcut.TargetPath = """"$env:INSTALLATION_DIR\dataloader.bat""""; $Shortcut.IconLocation = """"$env:INSTALLATION_DIR\dataloader.ico""""; $Shortcut.WindowStyle=7; $Shortcut.Save()"
    for /f "usebackq tokens=3*" %%D IN (`reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) do set DESKTOP_DIR=%%D
    move "%USERPROFILE%\Desktop\Dataloader.lnk" "%DESKTOP_DIR%\Dataloader %DATALOADER_VERSION%.lnk" >nul

:Exit
    echo.
    echo Data Loader installation is quitting.
    endlocal
    PAUSE

fix issue with creating desktop shortcut link

Desktop shortcut link is created in %USERPROFILE%\Desktop folder, which is the case for most desktops. However, sometimes Desktop folder is configured in a different location, which results in the missing desktop shortcut link. Fix is to look up the registry to figure out the location of Desktop folder and create the link.


setlocal EnableDelayedExpansion

if "%ARCH%"=="64" (
    set WIN64="WIN64=YES"
) else (
    set WIN64=
)

:: Work out MSVC_VER - needed for build process.
:: Currently guess from Python version
if  %vc% LEQ 9 set MSVC_VER=1500
if  %vc% GTR 9 set MSVC_VER=1900

:: Get the minor/major version of poppler from the %poppler% environment
:: variable that is set by conda-build
FOR /F "tokens=1,2 delims=." %%a IN ("%poppler%") DO (
  set POPPLER_MAJOR_VERSION=%%a
  set POPPLER_MINOR_VERSION=%%b
)

:: Need consistent flags between build and install.
set BLD_OPTS=%WIN64% ^
    MSVC_VER=%MSVC_VER% ^
    GDAL_HOME=%LIBRARY_PREFIX% ^
    BINDIR=%LIBRARY_BIN% ^
    LIBDIR=%LIBRARY_LIB% ^
    INCDIR=%LIBRARY_INC% ^
    DATADIR=%LIBRARY_PREFIX%\share\gdal ^
    CURL_INC="-I%LIBRARY_INC%" ^
    CURL_LIB="%LIBRARY_LIB%\libcurl.lib wsock32.lib wldap32.lib winmm.lib" ^
    EXPAT_DIR=%LIBRARY_PREFIX% ^
    EXPAT_INCLUDE="-I%LIBRARY_INC%" ^
    EXPAT_LIB=%LIBRARY_LIB%\expat.lib ^
    FITS_PLUGIN=NO ^
    FITS_INC_DIR=%LIBRARY_INC% ^
    FITS_LIB="%LIBRARY_LIB%\cfitsio.lib" ^
    FREEXL_CFLAGS="-I%LIBRARY_INC%" ^
    FREEXL_LIBS=%LIBRARY_LIB%\freexl_i.lib ^
    GEOS_CFLAGS="-I%LIBRARY_INC% -DHAVE_GEOS" ^
    GEOS_DIR=%LIBRARY_PREFIX% ^
    GEOS_LIB=%LIBRARY_LIB%\geos_c.lib ^
    HDF4_DIR=%LIBRARY_PREFIX% ^
    HDF4_HAS_MAXOPENFILES=YES ^
    HDF4_LIB="%LIBRARY_LIB%\hdf.lib %LIBRARY_LIB%\mfhdf.lib %LIBRARY_LIB%\xdr.lib" ^
    HDF5_DIR=%LIBRARY_PREFIX% ^
    HDF5_LIB=%LIBRARY_LIB%\hdf5.lib ^
    HDF5_H5_IS_DLL=YES ^
    TILEDB_ENABLED=YES ^
    TILEDB_DIR=%LIBRARY_PREFIX% ^
    TILEDB_LIBS=%LIBRARY_LIB%\tiledb.lib ^
    JPEGDIR=%LIBRARY_INC% ^
    JPEG_EXTERNAL_LIB=1 ^
    JPEG_LIB=%LIBRARY_LIB%\libjpeg.lib ^
    KEA_CFLAGS="-I%LIBRARY_INC%" ^
    KEA_LIB="%LIBRARY_LIB%\hdf5_cpp.lib %LIBRARY_LIB%\libkea.lib" ^
    NETCDF_INC_DIR=%LIBRARY_INC% ^
    NETCDF_LIB=%LIBRARY_LIB%\netcdf.lib ^
    NETCDF_SETTING=yes ^
    NETCDF_HAS_NC4=yes ^
    OPENJPEG_CFLAGS="-I%LIBRARY_INC%\openjpeg-2.4" ^
    OPENJPEG_ENABLED=YES ^
    OPENJPEG_LIB=%LIBRARY_LIB%\openjp2.lib ^
    PG_INC_DIR=%LIBRARY_INC% ^
    PG_LIB=%LIBRARY_LIB%\libpq.lib ^
    PNGDIR=%LIBRARY_INC% ^
    PNG_EXTERNAL_LIB=1 ^
    PNG_LIB=%LIBRARY_LIB%\libpng.lib ^
    PROJ_FLAGS="-DPROJ_STATIC" ^
    PROJ_INCLUDE="-I%LIBRARY_INC%" ^
    PROJ_LIBRARY=%LIBRARY_LIB%\proj.lib ^
    SPATIALITE_412_OR_LATER=yes ^
    SQLITE_INC="-I%LIBRARY_INC% -DHAVE_SPATIALITE" ^
    SQLITE_LIB="%LIBRARY_LIB%\sqlite3.lib %LIBRARY_LIB%\spatialite_i.lib" ^
    TIFF_INC="-I%LIBRARY_INC%" ^
    TIFF_LIB=%LIBRARY_LIB%\tiff.lib ^
    TIFF_OPTS=-DBIGTIFF_SUPPORT ^
    XERCES_DIR=%LIBRARY_PREFIX% ^
    XERCES_INCLUDE="-I%LIBRARY_INC% -I%LIBRARY_INC%\xercesc" ^
    XERCES_LIB=%LIBRARY_LIB%\xerces-c_3.lib ^
    GEOTIFF_INC="-I%LIBRARY_INC%" ^
    GEOTIFF_LIB=%LIBRARY_LIB%\geotiff_i.lib ^
    LIBICONV_INCLUDE="-I%LIBRARY_INC% -DICONV_CONST= " ^
    LIBICONV_LIBRARY="%LIBRARY_LIB%\iconv.lib" ^
    POPPLER_ENABLED=YES ^
    POPPLER_CFLAGS="-I%LIBRARY_INC%\poppler -DPOPPLER_HAS_OPTCONTENT= -DPOPPLER_BASE_STREAM_HAS_TWO_ARGS= " ^
    POPPLER_MAJOR_VERSION=%POPPLER_MAJOR_VERSION% ^
    POPPLER_MINOR_VERSION=%POPPLER_MINOR_VERSION% ^
    POPPLER_LIBS="%LIBRARY_LIB%\poppler.lib" ^
    WEBP_ENABLED=YES ^
    WEBP_CFLAGS="-I%LIBRARY_INC%" ^
    WEBP_LIBS="%LIBARY_LIB%\libwebp.lib" ^
    ZSTD_CFLAGS="-I%LIBRARY_INC%" ^
    ZSTD_LIBS="%LIBRARY_LIB%\libzstd.lib" ^
    LIBKML_INCLUDE="%LIBRARY_INC%" ^
    LIBKML_LIBS="%LIBRARY_LIB%\kmlconvenience.lib %LIBRARY_LIB%\libkmldom.lib %LIBRARY_LIB%\libkmlengine.lib.lib %LIBRARY_LIB%\libkmlregionator.lib %LIBRARY_LIB%\libkmlxsd.lid %LIBRARY_LIB%\minizip.lib %LIBRARY_LIB%\uriparser.lib"

endlocal && set BLD_OPTS=%BLD_OPTS%

setlocal EnableDelayedExpansion

if "%ARCH%"=="64" (
    set WIN64="WIN64=YES"
) else (
    set WIN64=
)

:: Work out MSVC_VER - needed for build process.
:: Currently guess from Python version
if  %vc% LEQ 9 set MSVC_VER=1500
if  %vc% GTR 9 set MSVC_VER=1900

:: Get the minor/major version of poppler from the %poppler% environment
:: variable that is set by conda-build
FOR /F "tokens=1,2 delims=." %%a IN ("%poppler%") DO (
  set POPPLER_MAJOR_VERSION=%%a
  set POPPLER_MINOR_VERSION=%%b
)

:: Need consistent flags between build and install.
set BLD_OPTS=%WIN64% ^
    MSVC_VER=%MSVC_VER% ^
    GDAL_HOME=%LIBRARY_PREFIX% ^
    BINDIR=%LIBRARY_BIN% ^
    LIBDIR=%LIBRARY_LIB% ^
    INCDIR=%LIBRARY_INC% ^
    DATADIR=%LIBRARY_PREFIX%\share\gdal ^
    CURL_INC="-I%LIBRARY_INC%" ^
    CURL_LIB="%LIBRARY_LIB%\libcurl.lib wsock32.lib wldap32.lib winmm.lib" ^
    EXPAT_DIR=%LIBRARY_PREFIX% ^
    EXPAT_INCLUDE="-I%LIBRARY_INC%" ^
    EXPAT_LIB=%LIBRARY_LIB%\expat.lib ^
    FITS_PLUGIN=NO ^
    FITS_INC_DIR=%LIBRARY_INC% ^
    FITS_LIB="%LIBRARY_LIB%\cfitsio.lib" ^
    FREEXL_CFLAGS="-I%LIBRARY_INC%" ^
    FREEXL_LIBS=%LIBRARY_LIB%\freexl_i.lib ^
    GEOS_CFLAGS="-I%LIBRARY_INC% -DHAVE_GEOS" ^
    GEOS_DIR=%LIBRARY_PREFIX% ^
    GEOS_LIB=%LIBRARY_LIB%\geos_c.lib ^
    HDF4_DIR=%LIBRARY_PREFIX% ^
    HDF4_HAS_MAXOPENFILES=YES ^
    HDF4_LIB="%LIBRARY_LIB%\hdf.lib %LIBRARY_LIB%\mfhdf.lib %LIBRARY_LIB%\xdr.lib" ^
    HDF5_DIR=%LIBRARY_PREFIX% ^
    HDF5_LIB=%LIBRARY_LIB%\hdf5.lib ^
    HDF5_H5_IS_DLL=YES ^
    TILEDB_ENABLED=YES ^
    TILEDB_DIR=%LIBRARY_PREFIX% ^
    TILEDB_LIBS=%LIBRARY_LIB%\tiledb.lib ^
    JPEGDIR=%LIBRARY_INC% ^
    JPEG_EXTERNAL_LIB=1 ^
    JPEG_LIB=%LIBRARY_LIB%\libjpeg.lib ^
    KEA_CFLAGS="-I%LIBRARY_INC%" ^
    KEA_LIB="%LIBRARY_LIB%\hdf5_cpp.lib %LIBRARY_LIB%\libkea.lib" ^
    NETCDF_INC_DIR=%LIBRARY_INC% ^
    NETCDF_LIB=%LIBRARY_LIB%\netcdf.lib ^
    NETCDF_SETTING=yes ^
    NETCDF_HAS_NC4=yes ^
    OPENJPEG_CFLAGS="-I%LIBRARY_INC%\openjpeg-2.4" ^
    OPENJPEG_ENABLED=YES ^
    OPENJPEG_LIB=%LIBRARY_LIB%\openjp2.lib ^
    PG_INC_DIR=%LIBRARY_INC% ^
    PG_LIB=%LIBRARY_LIB%\libpq.lib ^
    PNGDIR=%LIBRARY_INC% ^
    PNG_EXTERNAL_LIB=1 ^
    PNG_LIB=%LIBRARY_LIB%\libpng.lib ^
    PROJ_FLAGS="-DPROJ_STATIC" ^
    PROJ_INCLUDE="-I%LIBRARY_INC%" ^
    PROJ_LIBRARY=%LIBRARY_LIB%\proj.lib ^
    SPATIALITE_412_OR_LATER=yes ^
    SQLITE_INC="-I%LIBRARY_INC% -DHAVE_SPATIALITE" ^
    SQLITE_LIB="%LIBRARY_LIB%\sqlite3.lib %LIBRARY_LIB%\spatialite_i.lib" ^
    TIFF_INC="-I%LIBRARY_INC%" ^
    TIFF_LIB=%LIBRARY_LIB%\tiff.lib ^
    TIFF_OPTS=-DBIGTIFF_SUPPORT ^
    XERCES_DIR=%LIBRARY_PREFIX% ^
    XERCES_INCLUDE="-I%LIBRARY_INC% -I%LIBRARY_INC%\xercesc" ^
    XERCES_LIB=%LIBRARY_LIB%\xerces-c_3.lib ^
    GEOTIFF_INC="-I%LIBRARY_INC%" ^
    GEOTIFF_LIB=%LIBRARY_LIB%\geotiff_i.lib ^
    LIBICONV_INCLUDE="-I%LIBRARY_INC% -DICONV_CONST= " ^
    LIBICONV_LIBRARY="%LIBRARY_LIB%\iconv.lib" ^
    POPPLER_ENABLED=YES ^
    POPPLER_CFLAGS="-I%LIBRARY_INC%\poppler -DPOPPLER_HAS_OPTCONTENT= -DPOPPLER_BASE_STREAM_HAS_TWO_ARGS= " ^
    POPPLER_MAJOR_VERSION=%POPPLER_MAJOR_VERSION% ^
    POPPLER_MINOR_VERSION=%POPPLER_MINOR_VERSION% ^
    POPPLER_LIBS="%LIBRARY_LIB%\poppler.lib" ^
    WEBP_ENABLED=YES ^
    WEBP_CFLAGS="-I%LIBRARY_INC%" ^
    WEBP_LIBS="%LIBARY_LIB%\libwebp.lib" ^
    ZSTD_CFLAGS="-I%LIBRARY_INC%" ^
    ZSTD_LIBS="%LIBRARY_LIB%\libzstd.lib" ^
    LIBKML_INCLUDE="%LIBRARY_INC%" ^
    LIBKML_LIBS="%LIBRARY_LIB%\kmlconvenience.lib %LIBRARY_LIB%\kmldom.lib %LIBRARY_LIB%\kmlengine.lib %LIBRARY_LIB%\kmlregionator.lib %LIBRARY_LIB%\kmlxsd.lid %LIBRARY_LIB%\minizip.lib %LIBRARY_LIB%\uriparser.lib"

endlocal && set BLD_OPTS=%BLD_OPTS%

fix library names

fix library names


mkdir build
cd build

:: Compilation of Windows shared library is not supported (see https://github.com/coin-or/qpOASES/pull/109)
cmake ^
    -G "Ninja" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DBUILD_SHARED_LIBS:BOOL=ON ^
    -DBUILD_TESTING:BOOL=ON ^
    %SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

:: Test.
ctest --output-on-failure -C Release
if errorlevel 1 exit 1

mkdir build
cd build

cmake ^
    -G "Ninja" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DBUILD_SHARED_LIBS:BOOL=ON ^
    -DBUILD_TESTING:BOOL=ON ^
    %SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

:: Test.
ctest --output-on-failure -C Release
if errorlevel 1 exit 1

Update bld.bat

Update bld.bat


rem @if "%_echo%"=="" echo off

setlocal

call %~d0%~p0\..\..\..\config.bat

if EXIST magic.dll del magic.dll
if errorlevel 1 goto :Error

"%FSC%" --out:magic.dll -a magic.fs --keyfile:magic.snk
if errorlevel 1 goto :Error

REM == If we are running this test on a lab machine, we may not be running from an elev cmd prompt
REM == In that case, ADMIN_PIPE is set to the tool to invoke the command elevated.
IF DEFINED ADMIN_PIPE %ADMIN_PIPE% %GACUTIL% /if magic.dll
if errorlevel 1 goto :Error

if EXIST provider.dll del provider.dll
if ERRORLEVEL 1 goto :Error

"%CSC%" /out:provider.dll /target:library /r:"%FSCOREDLLPATH%" /r:magic.dll provider.cs
if ERRORLEVEL 1 goto :Error

"%GACUTIL%" /if magic.dll

"%FSC%" %fsc_flags% /debug+ /r:provider.dll /optimize- test.fsx
if ERRORLEVEL 1 goto Error

:Ok
echo. > build.ok
endlocal
exit /b 0

:Error
endlocal
exit /b %ERRORLEVEL%

rem @if "%_echo%"=="" echo off

setlocal

call %~d0%~p0\..\..\..\config.bat

if EXIST magic.dll del magic.dll
if errorlevel 1 goto :Error

"%FSC%" --out:magic.dll -a magic.fs --keyfile:magic.snk
if errorlevel 1 goto :Error

REM == If we are running this test on a lab machine, we may not be running from an elev cmd prompt
REM == In that case, ADMIN_PIPE is set to the tool to invoke the command elevated.
IF DEFINED ADMIN_PIPE %ADMIN_PIPE% %GACUTIL% /if magic.dll
if errorlevel 1 goto :Error

if EXIST provider.dll del provider.dll
if ERRORLEVEL 1 goto :Error

%CSC% /out:provider.dll /target:library "/r:%FSCOREDLLPATH%" /r:magic.dll provider.cs
if ERRORLEVEL 1 goto :Error

"%GACUTIL%" /if magic.dll

"%FSC%" %fsc_flags% /debug+ /r:provider.dll /optimize- test.fsx
if ERRORLEVEL 1 goto Error

:Ok
echo. > build.ok
endlocal
exit /b 0

:Error
endlocal
exit /b %ERRORLEVEL%

Fix accidental incorrect quoting in test script (changeset 1235391)


@(echo '> nul ) &::' ) | out-null; @'
@:: ## emacs -*- tab-width: 4; coding: dos; mode: powershell; indent-tabs-mode: nil; basic-offset: 2; -*- ## (jedit) :tabsize=4:mode=perl: ## (notepad++) vim: syntax=powershell : tabstop=4 : shiftwidth=2 : expandtab : smarttab : softtabstop=2 ## modeline ( see http://archive.is/djTUD @@ http://webcitation.org/66W3EhCAP )
@setlocal
@echo off

set "__ME=%~n0"

:: require PowerShell (to self-execute)
call :$path_in_pathlist _POWERSHELL_exe powershell.exe "%PATH%;%SystemRoot%\System32\WindowsPowerShell\v1.0"
if NOT DEFINED _POWERSHELL_exe (
    echo %__ME%: ERROR: script requires PowerShell [see http://support.microsoft.com/kb/968929 {to download Windows Management Framework Core [includes PowerShell 2.0]}] 1>&2
    exit /b 1
    )

:: execute self as PowerShell script [using an endlocal block to pass a clean environment]
set __ARGS=%*
( endlocal
setlocal
:: send the least interpreted/cleanest possible ARGS to PowerShell via the environment
set __ARGS=%__ARGS%
call "%_POWERSHELL_exe%" -NoProfile -ExecutionPolicy unrestricted -Command "${__0}='%~f0'; ${__ME}='%__ME%'; ${__INPUT} = @($input); ${__ARGS}=$env:__ARGS; Invoke-Expression $( [String]::Join([environment]::newline,$(Get-Content ${__0} | foreach { $_ }))+' ; exit $LASTEXITCODE' )"
:: restore needed ENV vars
set "__ME=%__ME%"
)
set "__exit_code=%ERRORLEVEL%"

( endlocal
    exit /b %__exit_code%
)
goto :EOF

::#### SUBs

::
:$path_in_pathlist ( ref_RETURN FILENAME PATHLIST )
:: NOTE: FILENAME should be a simple filename, not a directory or filename with leading diretory prefix. CMD will match these more complex paths, but TCC will not
setlocal
set "pathlist=%~3"
set "PATH=%pathlist%"
set "_RETval=%~$PATH:2"
:$path_in_pathlist_RETURN
endlocal & set %~1^=%_RETval%
goto :EOF
::

::#### SUBs.end

goto :EOF
'@ | Out-Null
#
function __MAIN {
# "__0 = '${__0}'" ## script full path
# "__ME = '${__ME}'" ## name
# "input = '"+($input -join ';')+"'" ## STDIN
# "args = '"+($args -join ';')+"'" ## ARGS
######

$rule_exclusions = @( 'PSAvoidUsingWriteHost' )

##

# $repo_dir = ( Get-Item $MyInvocation.MyCommand.Path ).directory.parent
$repo_dir = [System.IO.FileInfo]::new(${__0}).directory.parent

$repo_files = @(
    $args |
        foreach-object { Get-ChildItem $_ -ea Silent }
)
if ( $repo_files.count -lt 1 ) { $repo_files = @( Get-ChildItem $repo_dir.fullname -file -recurse -force ) }

$project_file_exclusions = @(
    $([regex]::Escape($repo_dir.fullname)+'\\.git\\.*$')
    $([regex]::Escape($repo_dir.fullname)+'\\vendor\\.*$')
)

$files = @(
    $repo_files |
        where-object { $_.fullname -inotmatch $($project_file_exclusions -join '|') } |
        where-object { $_.fullname -imatch '.(ps1|psm1)$' }
)

$files_exist = ($files.Count -gt 0)

if (-not $files_exist) { throw "no files found to critique" }

$lint_module_name = 'PSScriptAnalyzer'
$lint_module_version = '1.3.0'
if (-not (Get-Module $lint_module_name)) {
    $filename = [System.IO.Path]::Combine($repo_dir.fullname,"vendor\$lint_module_name\$lint_module_version\$lint_module_name.psd1")
    import-module $(resolve-path $filename)
}
$have_delinter = Get-Module $lint_module_name

if (-not $have_delinter) { throw "unable to find/load '$lint_module_name' for critique" }

function abbrev_message {
    param([string]$message,[int]$size=$host.ui.RawUI.windowsize.width-1)
    $result = $message
    $continuation = '...'
    $continuation_size = $continuation.length
    if ($message.length -gt $size) { $result = $message.substring(0, $size-$continuation_size) + $continuation }
    $result
}

if ($null -ne $files) { foreach ($file in $files) {
    $repo_relative_name = [System.IO.Path]::Combine(($file.directoryname -replace $('^'+[regex]::escape($repo_dir.fullname)),'.'), $file.name)
    write-host -nonewline "Analyzing $repo_relative_name ... "
    $notes = Invoke-ScriptAnalyzer $file.FullName -excluderule $rule_exclusions
    if ($notes.count -ne 0) {
        write-output ''
        foreach ($note in $notes) {
            if ($note.severity -eq 'information') { write-host -fore cyan $(abbrev_message $("info:(@$($note.line)):'$($note.rulename)': $($note.message)")) }
            if ($note.severity -eq 'warning') { write-host -fore darkyellow $(abbrev_message $("warn:(@$($note.line)):'$($note.rulename)': $($note.message)")) }
            if ($note.severity -eq 'error') { write-host -fore red $(abbrev_message $("err!:(@$($note.line)):'$($note.rulename)': $($note.message)")) }
        }
    } else { write-host -fore green "done" }
}}

######
}
if ( $MyInvocation.MyCommand.CommandType -ne 'Script' ) {
    # NOT via `iex(...)`
    ${__0} = "$($MyInvocation.MyCommand.Path)"
    ${__ME} = $(get-item $MyInvocation.MyCommand.Path).BaseName
    ${__ENVPIPE} = $null
    ${__INPUT} = @($input)
    ${__ARGS} = $args -replace '(\s|`|\$)','`$1'
    }
iex ( '${__INPUT} | __MAIN '+$(${__ARGS} -join ' ') )

@(echo '> nul ) &::' ) | out-null; @'
@:: ## emacs -*- tab-width: 4; coding: dos; mode: powershell; indent-tabs-mode: nil; basic-offset: 2; -*- ## (jedit) :tabsize=4:mode=perl: ## (notepad++) vim: syntax=powershell : tabstop=4 : shiftwidth=2 : expandtab : smarttab : softtabstop=2 ## modeline ( see http://archive.is/djTUD @@ http://webcitation.org/66W3EhCAP )
@setlocal
@echo off

set "__ME=%~n0"

:: require PowerShell (to self-execute)
call :$path_in_pathlist _POWERSHELL_exe powershell.exe "%PATH%;%SystemRoot%\System32\WindowsPowerShell\v1.0"
if NOT DEFINED _POWERSHELL_exe (
    echo %__ME%: ERROR: script requires PowerShell [see http://support.microsoft.com/kb/968929 {to download Windows Management Framework Core [includes PowerShell 2.0]}] 1>&2
    exit /b 1
    )

:: execute self as PowerShell script [using an endlocal block to pass a clean environment]
set __ARGS=%*
( endlocal
setlocal
:: send the least interpreted/cleanest possible ARGS to PowerShell via the environment
set __ARGS=%__ARGS%
call "%_POWERSHELL_exe%" -NoProfile -ExecutionPolicy unrestricted -Command "${__0}='%~f0'; ${__ME}='%__ME%'; ${__INPUT} = @($input); ${__ARGS}=$env:__ARGS; Invoke-Expression $( [String]::Join([environment]::newline,$(Get-Content ${__0} | foreach { $_ }))+' ; exit $LASTEXITCODE' )"
:: restore needed ENV vars
set "__ME=%__ME%"
)
set "__exit_code=%ERRORLEVEL%"

( endlocal
    exit /b %__exit_code%
)
goto :EOF

::#### SUBs

::
:$path_in_pathlist ( ref_RETURN FILENAME PATHLIST )
:: NOTE: FILENAME should be a simple filename, not a directory or filename with leading diretory prefix. CMD will match these more complex paths, but TCC will not
setlocal
set "pathlist=%~3"
set "PATH=%pathlist%"
set "_RETval=%~$PATH:2"
:$path_in_pathlist_RETURN
endlocal & set %~1^=%_RETval%
goto :EOF
::

::#### SUBs.end

goto :EOF
'@ | Out-Null
#
function __MAIN {
# "__0 = '${__0}'" ## script full path
# "__ME = '${__ME}'" ## name
# "input = '"+($input -join ';')+"'" ## STDIN
# "args = '"+($args -join ';')+"'" ## ARGS
######

$rule_exclusions = @( 'PSAvoidUsingWriteHost' )

##

# $repo_dir = ( Get-Item $MyInvocation.MyCommand.Path ).directory.parent
$repo_dir = [System.IO.FileInfo]::new(${__0}).directory.parent

$repo_files = @(
    $args |
        foreach-object { Get-ChildItem $_ -ea Silent }
)
if ( $repo_files.count -lt 1 ) { $repo_files = @( Get-ChildItem $repo_dir.fullname -file -recurse -force ) }

$project_file_exclusions = @(
    $([regex]::Escape($repo_dir.fullname)+'\\.git\\.*$')
    $([regex]::Escape($repo_dir.fullname)+'\\vendor\\.*$')
)

$files = @(
    $repo_files |
        where-object { $_.fullname -inotmatch $($project_file_exclusions -join '|') } |
        where-object { $_.fullname -imatch '.(ps1|psm1)$' }
)

$files_exist = ($files.Count -gt 0)

if (-not $files_exist) { throw "no files found to critique" }

# NOTE: PSScriptAnalyzer automatically unloads it's associated the lint module assembly when shut down (no need for an in-memory copy)
$lint_module_name = 'PSScriptAnalyzer'
$lint_module_version = '1.3.0'
if (-not (Get-Module $lint_module_name)) {
    $filename = [System.IO.Path]::Combine($repo_dir.fullname,"vendor\$lint_module_name\$lint_module_version\$lint_module_name.psd1")
    import-module $(resolve-path $filename)
}
$have_delinter = Get-Module $lint_module_name

if (-not $have_delinter) { throw "unable to find/load '$lint_module_name' for critique" }

function abbrev_message {
    param([string]$message,[int]$size=$host.ui.RawUI.windowsize.width-1)
    $result = $message
    $continuation = '...'
    $continuation_size = $continuation.length
    if ($message.length -gt $size) { $result = $message.substring(0, $size-$continuation_size) + $continuation }
    $result
}

if ($null -ne $files) { foreach ($file in $files) {
    $repo_relative_name = [System.IO.Path]::Combine(($file.directoryname -replace $('^'+[regex]::escape($repo_dir.fullname)),'.'), $file.name)
    write-host -nonewline "Analyzing $repo_relative_name ... "
    $notes = Invoke-ScriptAnalyzer $file.FullName -excluderule $rule_exclusions
    if ($notes.count -ne 0) {
        write-output ''
        foreach ($note in $notes) {
            if ($note.severity -eq 'information') { write-host -fore cyan $(abbrev_message $("info:(@$($note.line)):'$($note.rulename)': $($note.message)")) }
            if ($note.severity -eq 'warning') { write-host -fore darkyellow $(abbrev_message $("warn:(@$($note.line)):'$($note.rulename)': $($note.message)")) }
            if ($note.severity -eq 'error') { write-host -fore red $(abbrev_message $("err!:(@$($note.line)):'$($note.rulename)': $($note.message)")) }
        }
    } else { write-host -fore green "done" }
}}

######
}
if ( $MyInvocation.MyCommand.CommandType -ne 'Script' ) {
    # NOT via `iex(...)`
    ${__0} = "$($MyInvocation.MyCommand.Path)"
    ${__ME} = $(get-item $MyInvocation.MyCommand.Path).BaseName
    ${__ENVPIPE} = $null
    ${__INPUT} = @($input)
    ${__ARGS} = $args -replace '(\s|`|\$)','`$1'
    }
iex ( '${__INPUT} | __MAIN '+$(${__ARGS} -join ' ') )

CHANGE ~ add note to critique (in-memory loading of PSSCriptAnalyzer is not needed)


pyinstaller --onefile driver.spec

taskkill /f /im {{cookiecutter.model_name}}.exe

sleep 3

copy dist\{{cookiecutter.model_name}}.exe                     "c:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers"
copy {{cookiecutter.project_slug}}_runtime_configuration.json "c:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers"

copy {{cookiecutter.project_slug}}_datamodel.xml               release\
copy dist\{{cookiecutter.model_name}}.exe                      release\
copy {{cookiecutter.project_slug}}_runtime_configuration.json  release\

pyinstaller --onefile driver.spec

taskkill /f /im {{cookiecutter.model_name}}.exe

sleep 3

set driverdir="c:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers"
IF EXIST %driverdir% GOTO :havecs
set driverdir="c:\Program Files (x86)\QualiSystems\TestShell\Server\Drivers"
:havecs

copy dist\{{cookiecutter.model_name}}.exe                     %driverdir%
copy {{cookiecutter.project_slug}}_runtime_configuration.json %driverdir%

copy {{cookiecutter.project_slug}}_datamodel.xml               release\
copy dist\{{cookiecutter.model_name}}.exe                      release\
copy {{cookiecutter.project_slug}}_runtime_configuration.json  release\

support CloudShell and TestShell server dirs