@setlocal
@rem Check environment
@IF %flexstate%==0 echo Flex and bison are required to build Mesa3D.
@IF %flexstate%==0 echo.
@IF %flexstate%==0 GOTO skipmesa
@if NOT EXIST mesa if %gitstate%==0 echo Fatal: Both Mesa3D code and Git are missing. At least one is required. Execution halted.
@if NOT EXIST mesa if %gitstate%==0 echo.
@if NOT EXIST mesa if %gitstate%==0 GOTO skipmesa
@IF %pkgconfigstate%==0 echo No suitable pkg-config implementation found. pkgconf or pkg-config-lite is required to build Mesa3D with Meson and MSVC.
@IF %pkgconfigstate%==0 echo.
@IF %pkgconfigstate%==0 GOTO skipmesa

@REM Aquire Mesa3D source code if missing.
@cd %devroot%
@if NOT EXIST mesa echo Warning: Mesa3D source code not found.
@if NOT EXIST mesa echo.
@if NOT EXIST mesa set /p buildmesa=Download mesa code and build (y/n):
@if NOT EXIST mesa echo.
@if NOT EXIST mesa if /i NOT "%buildmesa%"=="y" GOTO skipmesa
@if NOT EXIST mesa set branch=master
@if NOT EXIST mesa set /p branch=Enter Mesa source code branch name - defaults to master:
@if NOT EXIST mesa echo.
@if NOT EXIST mesa (
@git clone --recurse-submodules https://gitlab.freedesktop.org/mesa/mesa.git mesa
@echo.
@cd mesa
@IF NOT "%branch%"=="master" git checkout %branch%
@echo.
@cd ..
)

@if EXIST mesa if /i NOT "%buildmesa%"=="y" (
@set /p buildmesa=Begin mesa build. Proceed - y/n :
@echo.
)
@if /i NOT "%buildmesa%"=="y" GOTO skipmesa
@cd mesa

@rem Get Mesa3D version as an integer
@set /p mesaver=<VERSION
@if "%mesaver:~-7%"=="0-devel" set /a intmesaver=%mesaver:~0,2%%mesaver:~3,1%00
@if "%mesaver:~5,4%"=="0-rc" set /a intmesaver=%mesaver:~0,2%%mesaver:~3,1%00+%mesaver:~9%
@if NOT "%mesaver:~5,2%"=="0-" set /a intmesaver=%mesaver:~0,2%%mesaver:~3,1%50+%mesaver:~5%
@IF NOT EXIST %devroot%\mesa\subprojects\.gitignore echo Mesa3D source code you are using is too old. Update to 19.3 or newer.
@IF NOT EXIST %devroot%\mesa\subprojects\.gitignore echo.
@IF NOT EXIST %devroot%\mesa\subprojects\.gitignore GOTO skipmesa

@REM Verify if out of tree patches can be applied.
@IF NOT defined disablemesapatch set disablemesapatch=0
@set cannotmesapatch=0
@if %gitstate%==0 IF NOT EXIST %msysloc%\usr\bin\patch.exe IF %toolchain%==msvc set cannotmesapatch=1
@IF %cannotmesapatch%==1 set disablemesapatch=1
@IF %cannotmesapatch%==1 echo Error: Git and MSYS2 GNU patch are both missing. Auto-patching disabled. This could have many consequences going all the way up to build failure.
@IF %cannotmesapatch%==1 echo.
@IF %disablemesapatch%==1 IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 IF NOT %toolchain%==msvc echo FATAL: Mesa 20.1-devel through 20.1.0-rc2 cannot be built with MinGW without out of tree patches.
@IF %disablemesapatch%==1 IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 IF NOT %toolchain%==msvc echo.
@IF %disablemesapatch%==1 IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 IF NOT %toolchain%==msvc GOTO skipmesa
@IF %disablemesapatch%==1 IF %cannotmesapatch%==0 echo WARNING: Patching is forcefully disabled for debugging purposes.
@IF %disablemesapatch%==1 IF %cannotmesapatch%==0 echo.
@IF %disablemesapatch%==1 if NOT %gitstate%==0 echo Reverting out of tree patches...
@IF %disablemesapatch%==1 if NOT %gitstate%==0 git checkout .
@IF %disablemesapatch%==1 if NOT %gitstate%==0 echo.
@IF %disablemesapatch%==1 GOTO configmesabuild

@REM Collect information about Mesa3D code. Apply out of tree patches.
@rem Force static linking zlib in MSYS2
@call %devroot%\%projectname%\buildscript\modules\applypatch.cmd forcestaticzlib
@rem Enable S3TC texture cache
@call %devroot%\%projectname%\buildscript\modules\applypatch.cmd s3tc
@rem Fix swrAVX512 build
@IF %intmesaver% LSS 20000 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd swravx512
@IF %intmesaver% GEQ 20000 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd swravx512-post-static-link
@rem Make possible to build both osmesa gallium and swrast at the same time with Meson
@call %devroot%\%projectname%\buildscript\modules\applypatch.cmd dual-osmesa
@IF %intmesaver% LSS 20200 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd dual-osmesa-part2a
@IF %intmesaver% GEQ 20200 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd dual-osmesa-part2b
@rem Fix regression when building with native mingw toolchains affecting Mesa 20.1 branch
@IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd winepath
@rem Fix swr build
@IF %intmesaver% LSS 20152 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd swrbuildfix

:configmesabuild
@rem Configure Mesa build.
@set buildconf=%mesonloc% _build/%abi% --default-library=static --buildtype=release --prefix=%devroot:\=/%/%projectname%/dist/%abi%
@IF %toolchain%==msvc set buildconf=%buildconf% -Db_vscrt=mt
@IF NOT %toolchain%==msvc set buildconf=%buildconf% -Dc_args='-march=core2 -pipe' -Dcpp_args='-march=core2 -pipe' -Dc_link_args='-static -s' -Dcpp_link_args='-static -s'
@IF %toolchain%==clang set CC=clang
@IF %toolchain%==clang set CXX=clang++
@set buildcmd=msbuild /p^:Configuration=release,Platform=Win32 mesa.sln /m^:%throttle%
@IF %abi%==x64 set buildcmd=msbuild /p^:Configuration=release,Platform=x64 mesa.sln /m^:%throttle%

@set havellvm=0
@IF %toolchain%==msvc IF EXIST %devroot%\llvm\%abi% set havellvm=1
@IF NOT %toolchain%==msvc set havellvm=1
@set llvmless=n
@if %havellvm%==0 set llvmless=y
@if %havellvm%==1 set /p llvmless=Build Mesa without LLVM (y/n). llvmpipe and swr drivers and high performance JIT won't be available for other drivers and libraries:
@if %havellvm%==1 echo.
@call %devroot%\%projectname%\buildscript\modules\mesonsubprojects.cmd
@if /I NOT "%llvmless%"=="y" set buildconf=%buildconf% -Dllvm=true
@if /I NOT "%llvmless%"=="y" IF %llvmconfigbusted% EQU 0 set buildconf=%buildconf% -Dshared-llvm=false
@if /I NOT "%llvmless%"=="y" IF %toolchain%==msvc SET PATH=%devroot%\llvm\%abi%\bin\;%PATH%
@if /I NOT "%llvmless%"=="y" IF %llvmconfigbusted% EQU 1 set buildconf=%buildconf% -Dwrap_mode=forcefallback
@if /I "%llvmless%"=="y" set buildconf=%buildconf% -Dllvm=false

@set useninja=n
@IF NOT %toolchain%==msvc set useninja=y
@if NOT %ninjastate%==0 IF %toolchain%==msvc set /p useninja=Use Ninja build system instead of MsBuild (y/n); less storage device strain and maybe faster build:
@if NOT %ninjastate%==0 IF %toolchain%==msvc echo.
@if /I "%useninja%"=="y" if %ninjastate%==1 IF %toolchain%==msvc set PATH=%devroot%\ninja\;%PATH%
@if /I "%useninja%"=="y" set buildconf=%buildconf% --backend=ninja
@if /I "%useninja%"=="y" IF %toolchain%==msvc set buildcmd=ninja -C %devroot:\=/%/mesa/_build/%abi% -j %throttle%
@IF NOT %toolchain%==msvc set buildcmd=%msysloc%\usr\bin\bash --login -c "
@IF NOT %toolchain%==msvc IF %gitstate% GTR 0 set buildcmd=%buildcmd%PATH=${PATH}:${gitloc};
@IF NOT %toolchain%==msvc set buildcmd=%buildcmd%${MINGW_PREFIX}/bin/ninja -C $(/usr/bin/cygpath -m ${devroot})/mesa/_build/${abi} -j ${throttle}"
@if /I NOT "%useninja%"=="y" set buildconf=%buildconf% --backend=vs

@set buildconf=%buildconf% -Dgallium-drivers=swrast

@set zink=n
@rem IF NOT %toolchain%==msvc set /p zink=Do you want to build Mesa3D OpenGL driver over Vulkan - zink (y/n):
@rem IF NOT %toolchain%==msvc echo.
@IF /I "%zink%"=="y" set buildconf=%buildconf%,zink

@set swrdrv=n
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% LSS 20152 IF %disablemesapatch%==0 set /p swrdrv=Do you want to build swr drivers? (y=yes):
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% LSS 20152 IF %disablemesapatch%==0 echo.
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% GEQ 20152 set /p swrdrv=Do you want to build swr drivers? (y=yes):
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% GEQ 20152 echo.
@if /I "%swrdrv%"=="y" set buildconf=%buildconf%,swr
@if /I "%swrdrv%"=="y" IF %disablemesapatch%==0 set buildconf=%buildconf% -Dswr-arches=avx,avx2,skx,knl

@set /p gles=Do you want to build GLAPI as a shared library and standalone GLES libraries (y/n):
@echo.
@if /I "%gles%"=="y" set buildconf=%buildconf% -Dshared-glapi=true -Dgles1=true -Dgles2=true

@set osmesa=n
@set /p osmesa=Do you want to build off-screen rendering drivers (y/n):
@echo.
@IF /I "%osmesa%"=="y" set buildconf=%buildconf% -Dosmesa=gallium,classic
@IF /I "%osmesa%"=="y" IF %toolchain%==msvc IF %disablemesapatch%==1 set buildconf=%buildconf:~0,-8%
@rem Disable osmesa classic when building with Meson and Mingw toolchains due to build failure
@IF /I "%osmesa%"=="y" IF NOT %toolchain%==msvc set buildconf=%buildconf:~0,-8%

@set graw=n
@set /p graw=Do you want to build graw library (y/n):
@echo.
@if /I "%graw%"=="y" set buildconf=%buildconf% -Dbuild-tests=true

@set opencl=n
@rem According to Mesa source code clover OpenCL state tracker requires LLVM built with RTTI so it won't work with Mingw and it depends on libclc.
@rem IF %intmesaver% GEQ 20000 if /I NOT "%llvmless%"=="y" IF %toolchain%==msvc set /p opencl=Build Mesa3D clover OpenCL state tracker (y/):
@rem IF %intmesaver% GEQ 20000 if /I NOT "%llvmless%"=="y" IF %toolchain%==msvc echo.
@IF /I "%opencl%"=="y" set buildconf=%buildconf% -Dgallium-opencl=standalone

@if NOT %toolchain%==msvc set buildconf=%buildconf%"

@if EXIST _build\%abi% echo WARNING: Meson build always performs clean build. This is last chance to cancel build.
@if EXIST _build\%abi% pause
@if EXIST _build\%abi% echo.
@IF EXIST _build\%abi% RD /S /Q _build\%abi%

@IF %toolchain%==msvc IF %flexstate%==1 set PATH=%devroot%\flexbison\;%PATH%
@IF %toolchain%==msvc set PATH=%pkgconfigloc%\;%PATH%

:build_mesa
@rem Generate dummy header for MSVC build when git is missing.
@IF %toolchain%==msvc if NOT EXIST build md build
@IF %toolchain%==msvc if NOT EXIST _build\%abi% md _build\%abi%
@IF %toolchain%==msvc if NOT EXIST _build\%abi%\src md _build\%abi%\src
@IF %toolchain%==msvc if NOT EXIST _build\%abi%\src\git_sha1.h echo 0 > _build\%abi%\src\git_sha1.h

@rem Load MSVC environment if used.
@IF %toolchain%==msvc echo.
@IF %toolchain%==msvc call %vsenv% %vsabi%
@IF %toolchain%==msvc echo.

@rem Execute build.
@echo Build configuration command: %buildconf%
@echo.
@%buildconf%
@echo.
@if /I NOT "%useninja%"=="y" cd _build\%abi%
@echo Build command: %buildcmd%
@echo.
@pause
@echo.
@%buildcmd%
@echo.
@if /I NOT "%useninja%"=="y" cd ..\..\

:skipmesa
@rem Reset environment.
@endlocal

@setlocal
@rem Check environment
@IF %flexstate%==0 echo Flex and bison are required to build Mesa3D.
@IF %flexstate%==0 echo.
@IF %flexstate%==0 GOTO skipmesa
@if NOT EXIST mesa if %gitstate%==0 echo Fatal: Both Mesa3D code and Git are missing. At least one is required. Execution halted.
@if NOT EXIST mesa if %gitstate%==0 echo.
@if NOT EXIST mesa if %gitstate%==0 GOTO skipmesa
@IF %pkgconfigstate%==0 echo No suitable pkg-config implementation found. pkgconf or pkg-config-lite is required to build Mesa3D with Meson and MSVC.
@IF %pkgconfigstate%==0 echo.
@IF %pkgconfigstate%==0 GOTO skipmesa

@REM Aquire Mesa3D source code if missing.
@cd %devroot%
@if NOT EXIST mesa echo Warning: Mesa3D source code not found.
@if NOT EXIST mesa echo.
@if NOT EXIST mesa set /p buildmesa=Download mesa code and build (y/n):
@if NOT EXIST mesa echo.
@if NOT EXIST mesa if /i NOT "%buildmesa%"=="y" GOTO skipmesa
@if NOT EXIST mesa set branch=master
@if NOT EXIST mesa set /p branch=Enter Mesa source code branch name - defaults to master:
@if NOT EXIST mesa echo.
@if NOT EXIST mesa (
@git clone --recurse-submodules https://gitlab.freedesktop.org/mesa/mesa.git mesa
@echo.
@cd mesa
@IF NOT "%branch%"=="master" git checkout %branch%
@echo.
@cd ..
)

@if EXIST mesa if /i NOT "%buildmesa%"=="y" (
@set /p buildmesa=Begin mesa build. Proceed - y/n :
@echo.
)
@if /i NOT "%buildmesa%"=="y" GOTO skipmesa
@cd mesa

@rem Get Mesa3D version as an integer
@set /p mesaver=<VERSION
@if "%mesaver:~-7%"=="0-devel" set /a intmesaver=%mesaver:~0,2%%mesaver:~3,1%00
@if "%mesaver:~5,4%"=="0-rc" set /a intmesaver=%mesaver:~0,2%%mesaver:~3,1%00+%mesaver:~9%
@if NOT "%mesaver:~5,2%"=="0-" set /a intmesaver=%mesaver:~0,2%%mesaver:~3,1%50+%mesaver:~5%
@IF NOT EXIST %devroot%\mesa\subprojects\.gitignore echo Mesa3D source code you are using is too old. Update to 19.3 or newer.
@IF NOT EXIST %devroot%\mesa\subprojects\.gitignore echo.
@IF NOT EXIST %devroot%\mesa\subprojects\.gitignore GOTO skipmesa

@REM Verify if out of tree patches can be applied.
@IF NOT defined disablemesapatch set disablemesapatch=0
@set cannotmesapatch=0
@if %gitstate%==0 IF NOT EXIST %msysloc%\usr\bin\patch.exe IF %toolchain%==msvc set cannotmesapatch=1
@IF %cannotmesapatch%==1 set disablemesapatch=1
@IF %cannotmesapatch%==1 echo Error: Git and MSYS2 GNU patch are both missing. Auto-patching disabled. This could have many consequences going all the way up to build failure.
@IF %cannotmesapatch%==1 echo.
@IF %disablemesapatch%==1 IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 IF NOT %toolchain%==msvc echo FATAL: Mesa 20.1-devel through 20.1.0-rc2 cannot be built with MinGW without out of tree patches.
@IF %disablemesapatch%==1 IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 IF NOT %toolchain%==msvc echo.
@IF %disablemesapatch%==1 IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 IF NOT %toolchain%==msvc GOTO skipmesa
@IF %disablemesapatch%==1 IF %cannotmesapatch%==0 echo WARNING: Patching is forcefully disabled for debugging purposes.
@IF %disablemesapatch%==1 IF %cannotmesapatch%==0 echo.
@IF %disablemesapatch%==1 if NOT %gitstate%==0 echo Reverting out of tree patches...
@IF %disablemesapatch%==1 if NOT %gitstate%==0 git checkout .
@IF %disablemesapatch%==1 if NOT %gitstate%==0 echo.
@IF %disablemesapatch%==1 GOTO configmesabuild

@REM Collect information about Mesa3D code. Apply out of tree patches.
@rem Force static linking zlib in MSYS2
@call %devroot%\%projectname%\buildscript\modules\applypatch.cmd forcestaticzlib
@rem Enable S3TC texture cache
@call %devroot%\%projectname%\buildscript\modules\applypatch.cmd s3tc
@rem Fix swrAVX512 build
@IF %intmesaver% LSS 20000 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd swravx512
@IF %intmesaver% GEQ 20000 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd swravx512-post-static-link
@rem Make possible to build both osmesa gallium and swrast at the same time with Meson
@call %devroot%\%projectname%\buildscript\modules\applypatch.cmd dual-osmesa
@IF %intmesaver% LSS 20200 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd dual-osmesa-part2a
@IF %intmesaver% GEQ 20200 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd dual-osmesa-part2b
@rem Fix regression when building with native mingw toolchains affecting Mesa 20.1 branch
@IF %intmesaver% GEQ 20100 IF %intmesaver% LSS 20103 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd winepath
@rem Fix swr build
@IF %intmesaver% LSS 20152 call %devroot%\%projectname%\buildscript\modules\applypatch.cmd swrbuildfix

:configmesabuild
@rem Configure Mesa build.
@set buildconf=%mesonloc% _build/%abi% --default-library=shared --buildtype=release --prefix=%devroot:\=/%/%projectname%/dist/%abi%
@IF %toolchain%==msvc set buildconf=%buildconf% -Db_vscrt=mt
@IF NOT %toolchain%==msvc set buildconf=%buildconf% -Dc_args='-march=core2 -pipe' -Dcpp_args='-march=core2 -pipe' -Dc_link_args='-static -s' -Dcpp_link_args='-static -s'
@IF %toolchain%==clang set CC=clang
@IF %toolchain%==clang set CXX=clang++
@set buildcmd=msbuild /p^:Configuration=release,Platform=Win32 mesa.sln /m^:%throttle%
@IF %abi%==x64 set buildcmd=msbuild /p^:Configuration=release,Platform=x64 mesa.sln /m^:%throttle%

@set havellvm=0
@IF %toolchain%==msvc IF EXIST %devroot%\llvm\%abi% set havellvm=1
@IF NOT %toolchain%==msvc set havellvm=1
@set llvmless=n
@if %havellvm%==0 set llvmless=y
@if %havellvm%==1 set /p llvmless=Build Mesa without LLVM (y/n). llvmpipe and swr drivers and high performance JIT won't be available for other drivers and libraries:
@if %havellvm%==1 echo.
@call %devroot%\%projectname%\buildscript\modules\mesonsubprojects.cmd
@if /I NOT "%llvmless%"=="y" set buildconf=%buildconf% -Dllvm=true
@if /I NOT "%llvmless%"=="y" IF %llvmconfigbusted% EQU 0 set buildconf=%buildconf% -Dshared-llvm=false
@if /I NOT "%llvmless%"=="y" IF %toolchain%==msvc SET PATH=%devroot%\llvm\%abi%\bin\;%PATH%
@if /I NOT "%llvmless%"=="y" IF %llvmconfigbusted% EQU 1 set buildconf=%buildconf% -Dwrap_mode=forcefallback
@if /I "%llvmless%"=="y" set buildconf=%buildconf% -Dllvm=false

@set useninja=n
@IF NOT %toolchain%==msvc set useninja=y
@if NOT %ninjastate%==0 IF %toolchain%==msvc set /p useninja=Use Ninja build system instead of MsBuild (y/n); less storage device strain and maybe faster build:
@if NOT %ninjastate%==0 IF %toolchain%==msvc echo.
@if /I "%useninja%"=="y" if %ninjastate%==1 IF %toolchain%==msvc set PATH=%devroot%\ninja\;%PATH%
@if /I "%useninja%"=="y" set buildconf=%buildconf% --backend=ninja
@if /I "%useninja%"=="y" IF %toolchain%==msvc set buildcmd=ninja -C %devroot:\=/%/mesa/_build/%abi% -j %throttle%
@IF NOT %toolchain%==msvc set buildcmd=%msysloc%\usr\bin\bash --login -c "
@IF NOT %toolchain%==msvc IF %gitstate% GTR 0 set buildcmd=%buildcmd%PATH=${PATH}:${gitloc};
@IF NOT %toolchain%==msvc set buildcmd=%buildcmd%${MINGW_PREFIX}/bin/ninja -C $(/usr/bin/cygpath -m ${devroot})/mesa/_build/${abi} -j ${throttle}"
@if /I NOT "%useninja%"=="y" set buildconf=%buildconf% --backend=vs

@set buildconf=%buildconf% -Dgallium-drivers=swrast

@set zink=n
@rem IF NOT %toolchain%==msvc set /p zink=Do you want to build Mesa3D OpenGL driver over Vulkan - zink (y/n):
@rem IF NOT %toolchain%==msvc echo.
@IF /I "%zink%"=="y" set buildconf=%buildconf%,zink

@set swrdrv=n
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% LSS 20152 IF %disablemesapatch%==0 set /p swrdrv=Do you want to build swr drivers? (y=yes):
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% LSS 20152 IF %disablemesapatch%==0 echo.
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% GEQ 20152 set /p swrdrv=Do you want to build swr drivers? (y=yes):
@if /I NOT "%llvmless%"=="y" if %abi%==x64 IF %toolchain%==msvc IF %intmesaver% GEQ 20152 echo.
@if /I "%swrdrv%"=="y" set buildconf=%buildconf%,swr
@if /I "%swrdrv%"=="y" IF %disablemesapatch%==0 set buildconf=%buildconf% -Dswr-arches=avx,avx2,skx,knl

@set /p gles=Do you want to build GLAPI as a shared library and standalone GLES libraries (y/n):
@echo.
@if /I "%gles%"=="y" set buildconf=%buildconf% -Dshared-glapi=true -Dgles1=true -Dgles2=true

@set osmesa=n
@set /p osmesa=Do you want to build off-screen rendering drivers (y/n):
@echo.
@IF /I "%osmesa%"=="y" set buildconf=%buildconf% -Dosmesa=gallium,classic
@IF /I "%osmesa%"=="y" IF %toolchain%==msvc IF %disablemesapatch%==1 set buildconf=%buildconf:~0,-8%
@rem Disable osmesa classic when building with Meson and Mingw toolchains due to build failure
@IF /I "%osmesa%"=="y" IF NOT %toolchain%==msvc set buildconf=%buildconf:~0,-8%

@set graw=n
@set /p graw=Do you want to build graw library (y/n):
@echo.
@if /I "%graw%"=="y" set buildconf=%buildconf% -Dbuild-tests=true

@set opencl=n
@rem According to Mesa source code clover OpenCL state tracker requires LLVM built with RTTI so it won't work with Mingw and it depends on libclc.
@rem IF %intmesaver% GEQ 20000 if /I NOT "%llvmless%"=="y" IF %toolchain%==msvc set /p opencl=Build Mesa3D clover OpenCL state tracker (y/):
@rem IF %intmesaver% GEQ 20000 if /I NOT "%llvmless%"=="y" IF %toolchain%==msvc echo.
@IF /I "%opencl%"=="y" set buildconf=%buildconf% -Dgallium-opencl=standalone

@if NOT %toolchain%==msvc set buildconf=%buildconf%"

@if EXIST _build\%abi% echo WARNING: Meson build always performs clean build. This is last chance to cancel build.
@if EXIST _build\%abi% pause
@if EXIST _build\%abi% echo.
@IF EXIST _build\%abi% RD /S /Q _build\%abi%

@IF %toolchain%==msvc IF %flexstate%==1 set PATH=%devroot%\flexbison\;%PATH%
@IF %toolchain%==msvc set PATH=%pkgconfigloc%\;%PATH%

:build_mesa
@rem Generate dummy header for MSVC build when git is missing.
@IF %toolchain%==msvc if NOT EXIST build md build
@IF %toolchain%==msvc if NOT EXIST _build\%abi% md _build\%abi%
@IF %toolchain%==msvc if NOT EXIST _build\%abi%\src md _build\%abi%\src
@IF %toolchain%==msvc if NOT EXIST _build\%abi%\src\git_sha1.h echo 0 > _build\%abi%\src\git_sha1.h

@rem Load MSVC environment if used.
@IF %toolchain%==msvc echo.
@IF %toolchain%==msvc call %vsenv% %vsabi%
@IF %toolchain%==msvc echo.

@rem Execute build.
@echo Build configuration command: %buildconf%
@echo.
@%buildconf%
@echo.
@if /I NOT "%useninja%"=="y" cd _build\%abi%
@echo Build command: %buildcmd%
@echo.
@pause
@echo.
@%buildcmd%
@echo.
@if /I NOT "%useninja%"=="y" cd ..\..\

:skipmesa
@rem Reset environment.
@endlocal

Switch Mesa3D internal libraaries to shared linking like upstream did in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5689/diffs?commit_id=ee056dfef6e3567d49e82fe4af8604885ef736f5


@echo off
setlocal

:: Check prerequisites
if not "%VisualStudioVersion%" == "14.0" (
    echo Error: build.cmd should be run from a Visual Studio 2015 Command Prompt.
    echo        Please see https://github.com/Microsoft/msbuild/wiki/Building-Testing-and-Debugging for build instructions.
    exit /b 1
)

:: Check for a custom MSBuild path. If not defined, default to the one in your path.
if not defined MSBUILDCUSTOMPATH (
    set MSBUILDCUSTOMPATH=MSBuild.exe
)

echo ** MSBuild Path: %MSBUILDCUSTOMPATH%
echo ** Building all sources

:: Call MSBuild
echo ** "%MSBUILDCUSTOMPATH%" "%~dp0build.proj" /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%~dp0msbuild.log" %*
"%MSBUILDCUSTOMPATH%" "%~dp0build.proj" /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%~dp0msbuild.log" %*
set BUILDERRORLEVEL=%ERRORLEVEL%
echo.

:: Pull the build summary from the log file
findstr /ir /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" "%~dp0msbuild.log"
echo ** Build completed. Exit code: %BUILDERRORLEVEL%

exit /b %BUILDERRORLEVEL%

@echo off
setlocal

:: Check prerequisites
if not "%VisualStudioVersion%" == "14.0" (
    echo Error: build.cmd should be run from a Visual Studio 2015 Command Prompt.
    echo        Please see https://github.com/Microsoft/msbuild/wiki/Building-Testing-and-Debugging for build instructions.
    exit /b 1
)

:: Check for a custom MSBuild path. If not defined, default to the one in your path.
if not defined MSBUILDCUSTOMPATH (
    set MSBUILDCUSTOMPATH=MSBuild.exe
)

set NUGETEXEPATH="%~dp0packages\NuGet.exe"

if not exist "%~dp0packages" mkdir "%~dp0packages"
if not exist "%NUGETEXEPATH%" (
    :: This will need to be fixed for non-windows
    echo ** Downloading NuGet.exe from https://nuget.org/NuGet.exe...
    echo PS^> Invoke-WebRequest -OutFile %NUGETEXEPATH% "https://nuget.org/NuGet.exe"
    powershell -Command "Invoke-WebRequest -OutFile %NUGETEXEPATH% "https://nuget.org/NuGet.exe""
)

echo Restoring NuGet packages
"%NUGETEXEPATH%" install "%~dp0src\.nuget\packages.config" -o "%~dp0packages"

echo ** MSBuild Path: %MSBUILDCUSTOMPATH%
echo ** Building all sources

:: Call MSBuild
echo ** "%MSBUILDCUSTOMPATH%" "%~dp0build.proj" /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%~dp0msbuild.log" %*
"%MSBUILDCUSTOMPATH%" "%~dp0build.proj" /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%~dp0msbuild.log" %*
set BUILDERRORLEVEL=%ERRORLEVEL%
echo.

:: Pull the build summary from the log file
findstr /ir /c:".*Warning(s)" /c:".*Error(s)" /c:"Time Elapsed.*" "%~dp0msbuild.log"
echo ** Build completed. Exit code: %BUILDERRORLEVEL%

exit /b %BUILDERRORLEVEL%

Add NuGet download and pgk install in build.cmd Closes #165


@echo off
cls

.paket\paket.exe
if errorlevel 1 (
  exit /b %errorlevel%
)

.paket\paket.exe restore
if errorlevel 1 (
  exit /b %errorlevel%
)

packages\build\FAKE\tools\FAKE.exe build.fsx %*

@echo off
cls

.paket\paket.exe restore
if errorlevel 1 (
  exit /b %errorlevel%
)

packages\build\FAKE\tools\FAKE.exe build.fsx %*

Fix windows build.cmd script

Fix windows build.cmd script


echo "Start build"
git clone https://github.com/SFML/SFML.git
cd SFML

mkdir install
mkdir build
cd build

cmake .. -G "Visual Studio 15 Win64" -DCMAKE_INSTALL_PREFIX=../install -DSFML_DEPENDENCIES_INSTALL_PREFIX=../install -DSFML_BUILD_FRAMEWORKS=FALSE -DBUILD_SHARED_LIBS=TRUE

msbuild INSTALL.vcxproj
echo "After SFML build"

cd ../../
echo "Process TIMLE project"
cd TIMLE
echo "cd into TIMLE project"

mkdir build
echo "mkdir build"

mkdir build/TIMLE
echo "mkdir build/TIMLE"

cmake . -G "Visual Studio 15 Win64" -DCMAKE_INSTALL_PREFIX=./build/TIMLE -DCMAKE_PREFIX_PATH=./SFML/install
echo "Process TIMLE by CMake"

echo "Start build"
git clone https://github.com/SFML/SFML.git
cd SFML

mkdir install
mkdir build
cd build

cmake .. -G "Visual Studio 15 Win64" -DCMAKE_INSTALL_PREFIX=../install -DSFML_DEPENDENCIES_INSTALL_PREFIX=../install -DSFML_BUILD_FRAMEWORKS=FALSE -DBUILD_SHARED_LIBS=TRUE

msbuild INSTALL.vcxproj
echo "After SFML build"

cd ../../
echo "Process TIMLE project"
cd TIMLE
echo "cd into TIMLE project"

mkdir build
echo "mkdir build"

echo "call ls"
ls
echo "end ls"

mkdir build/TIMLE
echo "mkdir build/TIMLE"

cmake . -G "Visual Studio 15 Win64" -DCMAKE_INSTALL_PREFIX=./build/TIMLE -DCMAKE_PREFIX_PATH=./SFML/install
echo "Process TIMLE by CMake"

Add ls command

Add ls command


@echo off
if exist glfw-Win32 rmdir /s /q glfw-Win32
if exist glfw-Win32 rmdir /s /q glfw-x64
if exist glfw-Win32 rmdir /s /q mercury-Win32
if exist glfw-Win32 rmdir /s /q mercury-x64

Add clean batch file

Add clean batch file


::/**************************************************************************
:: * The MIT License                                                        *
:: * Copyright (c) 2013 Antony Arciuolo.                                    *
:: * arciuolo@gmail.com                                                     *
:: *                                                                        *
:: * Permission is hereby granted, free of charge, to any person obtaining  *
:: * a copy of this software and associated documentation files (the        *
:: * "Software"), to deal in the Software without restriction, including    *
:: * without limitation the rights to use, copy, modify, merge, publish,    *
:: * distribute, sublicense, and/or sell copies of the Software, and to     *
:: * permit persons to whom the Software is furnished to do so, subject to  *
:: * the following conditions:                                              *
:: *                                                                        *
:: * The above copyright notice and this permission notice shall be         *
:: * included in all copies or substantial portions of the Software.        *
:: *                                                                        *
:: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        *
:: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     *
:: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND                  *
:: * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE *
:: * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION *
:: * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  *
:: * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.        *
:: **************************************************************************/

:: This command script takes in a path to a file with several HLSL shaders, a
:: file with a list of entry points and an output directory. This will use fxc
:: to compile each entry point to its own .h file in the output directory.

@echo off
setlocal enabledelayedexpansion

:: Set and verify arguments
set input_path=%~1
set entry_list=%~2
set output_dir=%~3
set all_args_present=true
if "!input_path!"=="" set all_args_present=false
if "!entry_list!"=="" set all_args_present=false
if "!output_dir!"=="" set all_args_present=false
if not "!all_args_present!"=="true" (
	echo usage: %~0 input_path entry_list output_dir
	echo  input_path=!input_path!
	echo  entry_list=!entry_list!
	echo  output_dir=!output_dir!
	goto end
)

:: Find FXC: before Windows 8 check for the DirectX SDK
set fxc_exe="%ProgramFiles(x86)\Windows Kits\8.0\bin\x64\fxc.exe"
if not exist !fxc_exe! (
	if "!DXSDK_DIR!"=="" (
		echo cannot find Windows Kits or DirectX SDK
		goto end
	)

	set fxc_exe="%DXSDK_DIR%\Utilities\bin\x64\fxc.exe"
	if not exist !fxc_exe! (
		echo cannot find fxc in Windows Kits or %%DXSDK_DIR%%
		goto end
	)
)

:: Parse extra arguments to pass to fxc (first move past 3 required args)
set extra_fxc_args=
shift & shift & shift
:args_loop
if not "%1"=="" (
	set __new=!extra_fxc_args! %1
	set extra_fxc_args=!__new!
	shift
	goto args_loop
)

:: Read each entry point from the input file and compile it
for /f %%i in (!entry_list!) do call:CompileShader %%i "!extra_fxc_args!"
goto end

:CompileShader
pushd .
setlocal
set entry_point=%~1
set extra_args=%~2
set output_path=!output_dir!\!entry_point!.h

:: determine the shader model from the first letter of the entry point
set entry_prefix=!entry_point:~0,1!
echo !entry_prefix! | findstr /i "V v H h D d G g P p C c" > nul
if not %ERRORLEVEL%==0 (
	echo entry point must begin with a letter indicating the type of shader it is ^(VHDGPC^)
	goto end
)

:: ensure it's all lowercase
if "!entry_prefix!"=="V" set entry_prefix=v
if "!entry_prefix!"=="H" set entry_prefix=h
if "!entry_prefix!"=="D" set entry_prefix=d
if "!entry_prefix!"=="G" set entry_prefix=g
if "!entry_prefix!"=="P" set entry_prefix=p
if "!entry_prefix!"=="C" set entry_prefix=c
set shader_model=!entry_prefix!s_5_0

!fxc_exe! /D oHLSL !extra_args! /nologo /O3 /T !shader_model! /E !entry_point! /Vn !entry_point! /Fh "!output_path!" "!input_path!"

endlocal
popd
goto end

:end

::/**************************************************************************
:: * The MIT License                                                        *
:: * Copyright (c) 2013 Antony Arciuolo.                                    *
:: * arciuolo@gmail.com                                                     *
:: *                                                                        *
:: * Permission is hereby granted, free of charge, to any person obtaining  *
:: * a copy of this software and associated documentation files (the        *
:: * "Software"), to deal in the Software without restriction, including    *
:: * without limitation the rights to use, copy, modify, merge, publish,    *
:: * distribute, sublicense, and/or sell copies of the Software, and to     *
:: * permit persons to whom the Software is furnished to do so, subject to  *
:: * the following conditions:                                              *
:: *                                                                        *
:: * The above copyright notice and this permission notice shall be         *
:: * included in all copies or substantial portions of the Software.        *
:: *                                                                        *
:: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        *
:: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     *
:: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND                  *
:: * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE *
:: * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION *
:: * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  *
:: * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.        *
:: **************************************************************************/

:: This command script takes in a path to a file with several HLSL shaders, a
:: file with a list of entry points and an output directory. This will use fxc
:: to compile each entry point to its own .h file in the output directory.

@echo off
setlocal enabledelayedexpansion

:: Set and verify arguments
set input_path=%~1
set entry_list=%~2
set output_dir=%~3
set all_args_present=true
if "!input_path!"=="" set all_args_present=false
if "!entry_list!"=="" set all_args_present=false
if "!output_dir!"=="" set all_args_present=false
if not "!all_args_present!"=="true" (
	echo usage: %~0 input_path entry_list output_dir
	echo  input_path=!input_path!
	echo  entry_list=!entry_list!
	echo  output_dir=!output_dir!
	goto end
)

:: Find FXC: before Windows 8 check for the DirectX SDK
set fxc_exe="%ProgramFiles(x86)%\Windows Kits\8.0\bin\x64\fxc.exe"
if not exist !fxc_exe! (
	if "!DXSDK_DIR!"=="" (
		echo cannot find Windows Kits or DirectX SDK
		goto end
	)

	set fxc_exe="%DXSDK_DIR%\Utilities\bin\x64\fxc.exe"
	if not exist !fxc_exe! (
		echo cannot find fxc in Windows Kits or %%DXSDK_DIR%%
		goto end
	)
)

:: Parse extra arguments to pass to fxc (first move past 3 required args)
set extra_fxc_args=
shift & shift & shift
:args_loop
if not "%1"=="" (
	set __new=!extra_fxc_args! %1
	set extra_fxc_args=!__new!
	shift
	goto args_loop
)

:: Read each entry point from the input file and compile it
for /f %%i in (!entry_list!) do call:CompileShader %%i "!extra_fxc_args!"
goto end

:CompileShader
pushd .
setlocal
set entry_point=%~1
set extra_args=%~2
set output_path=!output_dir!\!entry_point!.h

:: determine the shader model from the first letter of the entry point
set entry_prefix=!entry_point:~0,1!
echo !entry_prefix! | findstr /i "V v H h D d G g P p C c" > nul
if not %ERRORLEVEL%==0 (
	echo entry point must begin with a letter indicating the type of shader it is ^(VHDGPC^)
	goto end
)

:: ensure it's all lowercase
if "!entry_prefix!"=="V" set entry_prefix=v
if "!entry_prefix!"=="H" set entry_prefix=h
if "!entry_prefix!"=="D" set entry_prefix=d
if "!entry_prefix!"=="G" set entry_prefix=g
if "!entry_prefix!"=="P" set entry_prefix=p
if "!entry_prefix!"=="C" set entry_prefix=c
set shader_model=!entry_prefix!s_5_0

!fxc_exe! /D oHLSL !extra_args! /nologo /O3 /T !shader_model! /E !entry_point! /Vn !entry_point! /Fh "!output_path!" "!input_path!"

endlocal
popd
goto end

:end

Fix typo

Fix typo


@echo off

:: change directory to etherpad-lite root
cd /D "%~dp0\.."

:: Is node installed?
cmd /C node -e "" || ( echo "Please install node.js ( http://nodejs.org )" && exit /B 1 )

echo _
echo Checking node version...
set check_version="if(['6','8'].indexOf(process.version.split('.')[1].toString()) === -1) { console.log('You are running a wrong version of Node. Etherpad Lite requires v0.6.x or v0.8.x'); process.exit(1) }"
cmd /C node -e %check_version% || exit /B 1

echo _
echo Installing etherpad-lite and dependencies...
cmd /C npm install src/ --loglevel warn || exit /B 1

echo _
echo Copying custom templates...
set custom_dir=node_modules\ep_etherpad-lite\static\custom
FOR %%f IN (index pad timeslider) DO (
  if NOT EXIST "%custom_dir%\%%f.js" copy "%custom_dir%\js.template" "%custom_dir%\%%f.js"
  if NOT EXIST "%custom_dir%\%%f.css" copy "%custom_dir%\css.template" "%custom_dir%\%%f.css"
)

echo _
echo Clearing cache...
del /S var\minified*

echo _
echo Setting up settings.json...
IF NOT EXIST settings.json (
  echo Can't find settings.json.
  echo Copying settings.json.template...
  cmd /C copy settings.json.template settings.json || exit /B 1
)

echo _
echo Installed Etherpad-lite!  To run Etherpad type start.bat

@echo off

:: change directory to etherpad-lite root
cd /D "%~dp0\.."

:: Is node installed?
cmd /C node -e "" || ( echo "Please install node.js ( http://nodejs.org )" && exit /B 1 )

echo _
echo Checking node version...
set check_version="if(['6','8'].indexOf(process.version.split('.')[1].toString()) === -1) { console.log('You are running a wrong version of Node. Etherpad Lite requires v0.6.x or v0.8.x'); process.exit(1) }"
cmd /C node -e %check_version% || exit /B 1

echo _
echo Ensure that all dependencies are up to date...  If this is the first time you have run Etherpad please be patient.
cmd /C npm install src/ --loglevel warn || exit /B 1

echo _
echo Copying custom templates...
set custom_dir=node_modules\ep_etherpad-lite\static\custom
FOR %%f IN (index pad timeslider) DO (
  if NOT EXIST "%custom_dir%\%%f.js" copy "%custom_dir%\js.template" "%custom_dir%\%%f.js"
  if NOT EXIST "%custom_dir%\%%f.css" copy "%custom_dir%\css.template" "%custom_dir%\%%f.css"
)

echo _
echo Clearing cache...
del /S var\minified*

echo _
echo Setting up settings.json...
IF NOT EXIST settings.json (
  echo Can't find settings.json.
  echo Copying settings.json.template...
  cmd /C copy settings.json.template settings.json || exit /B 1
)

echo _
echo Installed Etherpad!  To run Etherpad type start.bat

change message

change message


set PATH=C:\Ruby192\bin;%PATH%

ruby -v
call bundle install --binstubs --without docgen --path vendor/bundle || ( call rm Gemfile.lock && call bundle install --binstubs --path vendor/bundle )
ruby bin\rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec/functional spec/unit spec/stress
set RSPEC_ERRORLVL=%ERRORLEVEL%

REM Return the error level from rspec
exit /B %RSPEC_ERRORLVL%

set PATH=C:\Ruby192\bin;%PATH%

ruby -v
call bundle install --binstubs --without docgen --path vendor/bundle || ( call rm Gemfile.lock && call bundle install --binstubs --path vendor/bundle )
ruby bin\rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec/unit
set RSPEC_ERRORLVL=%ERRORLEVEL%

REM Return the error level from rspec
exit /B %RSPEC_ERRORLVL%

fix jenkins script for windows

fix jenkins script for windows


:: build the solution
@echo OFF
cd ..
premake5-win32.exe clean
premake5-win32.exe vs2015 windows

if exist .\build_logs  rd /S /Q .\build_logs

md .\build_logs

if exist local_install rd /S /Q local_install

md local_install
md local_install\oolua

call "%VS140COMNTOOLS%vsvars32.bat" x86

devenv  "%cd%\oolua.sln" /build debug /project "%cd%\oolua.vcxproj" > .\build_logs\oolua_vs2015_debug.log
devenv  "%cd%\oolua.sln" /build release /project "%cd%\oolua.vcxproj" > .\build_logs\oolua_vs2015_release.log

copy .\include\*.h .\local_install\oolua\*.h
copy .\bin\Debug\*.lib .\local_install\
copy .\bin\Release\*.lib .\local_install\

premake5-win32.exe clean

cd build_scripts

:: build the solution
@echo OFF
cd ..
premake5-win32.exe clean
premake5-win32.exe vs2015 windows

if exist .\build_logs  rd /S /Q .\build_logs

md .\build_logs

if exist local_install rd /S /Q local_install

md local_install
md local_install\oolua

call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86

devenv  "%cd%\oolua.sln" /build debug /project "%cd%\oolua.vcxproj" > .\build_logs\oolua_vs2015_debug.log
devenv  "%cd%\oolua.sln" /build release /project "%cd%\oolua.vcxproj" > .\build_logs\oolua_vs2015_release.log

copy .\include\*.h .\local_install\oolua\*.h
copy .\bin\Debug\*.lib .\local_install\
copy .\bin\Release\*.lib .\local_install\

premake5-win32.exe clean

cd build_scripts

fix vs2015build

fix vs2015build


@echo OFF

set CUR_DIR="%CD%"
set NAME_SOURCE="Source"
set NAME_BUILD="Build"

SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
	set "DEL=%%a"
)

call :ColorText 0C "Build DSTEd"
echo.
call :ColorText 0C "---"
echo.
echo.

:: Create Build & Temp Directory
call :ColorText 1C "...Remove old Directorys"
::if exist "%CUR_DIR%\%NAME_TEMP%" rmdir /s/q %CUR_DIR%\%NAME_TEMP%
::if exist "%CUR_DIR%\%NAME_BUILD%" rmdir /s/q %CUR_DIR%\%NAME_BUILD%

call :ColorText 1C "...Create Build Directory"
md "%CUR_DIR%\%NAME_BUILD%\"

:: Clean-Up Source Folder
::if exist "%CUR_DIR%\%NAME_SOURCE%\npm-debug.log.*<" del /s %CUR_DIR%\%NAME_SOURCE%\npm-debug.log.*
::if exist "%CUR_DIR%\%NAME_SOURCE%\config.json" del %CUR_DIR%\%NAME_SOURCE%\config.json
::if exist "%CUR_DIR%\%NAME_SOURCE%\node_modules" rmdir /s/q %CUR_DIR%\%NAME_SOURCE%\node_modules

:: Move Source to Build Directory
call :ColorText 1C "...Move Source"
@RD /S /Q %CUR_DIR%\%NAME_TEMP%
xcopy /e /v %CUR_DIR%\%NAME_SOURCE% %CUR_DIR%\%NAME_TEMP%

:: Go to Temp and Start NPM for installing Depencies
cd %CUR_DIR%\%NAME_TEMP%
call :ColorText 1C "...Install Depencies"
npm install

:: Create Software
call :ColorText 1C "...Package Application"
electron-packager %CUR_DIR%\%NAME_TEMP% DSTEd --asar=true --overwrite --prune=true --icon=%CUR_DIR%\%NAME_TEMP%\Resources\window_icon.ico --app-version=1.0.0 --out %CUR_DIR%\%NAME_BUILD% --win32metadata.CompanyName="DSTEd - OpenSource" --win32metadata.ProductName="DSTEd" --win32metadata.OriginalFilename="DSTEd.exe"

:: Remove unused files
call :ColorText 1C "...Remove unused Files"

goto :eof

:ColorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof

pause

@echo OFF

set CUR_DIR="%CD%"
set NAME_SOURCE="Source"
set NAME_BUILD="Build"
set NAME_TEMP="Temp"
set UNUSED_FILES=blink_image_resources_200_percent.pak;content_resources_200_percent.pak;d3dcompiler_47.dll;libEGL.dll;libGLESv2.dll;LICENSE;LICENSES.chromium.html;pdf_viewer_resources.pak;ui_resources_200_percent.pak;version;views_resources_200_percent.pak

SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
	set "DEL=%%a"
)

call :ColorText 0C "Build DSTEd"
echo.
call :ColorText 0C "---"
echo.
echo.

:: Create Build & Temp Directory
call :ColorText 1C "...Remove old Directorys"
echo.
if exist "%CUR_DIR%\%NAME_TEMP%" rmdir /s/q %CUR_DIR%\%NAME_TEMP%
if exist "%CUR_DIR%\%NAME_BUILD%" rmdir /s/q %CUR_DIR%\%NAME_BUILD%

call :ColorText 1C "...Create Build Directory"
echo.
md "%CUR_DIR%\%NAME_BUILD%\"

:: Clean-Up Source Folder
if exist "%CUR_DIR%\%NAME_SOURCE%\npm-debug.log.*<" del /s %CUR_DIR%\%NAME_SOURCE%\npm-debug.log.*
if exist "%CUR_DIR%\%NAME_SOURCE%\config.json" del %CUR_DIR%\%NAME_SOURCE%\config.json
if exist "%CUR_DIR%\%NAME_SOURCE%\node_modules" rmdir /s/q %CUR_DIR%\%NAME_SOURCE%\node_modules

:: Move Source to Build Directory
call :ColorText 1C "...Move Source"
echo.
md "%CUR_DIR%\%NAME_TEMP%\"
xcopy /e /v %CUR_DIR%\%NAME_SOURCE% %CUR_DIR%\%NAME_TEMP%

:: Go to Temp and Start NPM for installing Depencies
cd %CUR_DIR%\%NAME_TEMP%
call :ColorText 1C "...Install Depencies"
echo.
call npm install

cd %CUR_DIR%

:: Create Software
cd %CUR_DIR%\%NAME_BUILD%
call :ColorText 1C "...Package Application"
echo.
call electron-packager "%CUR_DIR:"=%\%NAME_TEMP:"=%" DSTEd --asar=true --overwrite --prune=true --icon=%CUR_DIR:"=%\%NAME_TEMP:"=%\Resources\window_icon.ico --app-version=1.0.0 --win32metadata.CompanyName="DSTEd - OpenSource" --win32metadata.ProductName="DSTEd" --win32metadata.OriginalFilename="DSTEd.exe"

:: Remove unused files
call :ColorText 1C "...Remove unused Files"
echo.

(for %%F in (%UNUSED_FILES%) do (
	(for /d %%a in ("DSTEd-*-*") do (
		if exist "%CUR_DIR%\%NAME_BUILD%\%%a\%%F" (
			echo remove %%F
			del %CUR_DIR%\%NAME_BUILD%\%%a\%%F
		)
	))
))

call :ColorText 1C "...Remove Temporary Directory"
echo.
rmdir /s/q %CUR_DIR%\%NAME_TEMP%

goto :eof

:ColorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof

pause

Update Build-Steps for Windows

Update Build-Steps for Windows


set CSProj=XamarinTestRunner\XamarinTestRunner.Android\XamarinTestRunner.Android.csproj
msbuild %CSProj% -t:Restore
msbuild %CSProj% ^
    -t:SignAndroidPackage ^
    -p:Configuration=Debug ^
    -p:EmbedAssembliesIntoApk=true ^
    -p:AndroidSdkDirectory=%ANDROID_HOME%

Add the path for the AndroidSdk to the msbuild for Xamarin (#661)


@IF NOT EXIST %mesa%\mesa-dist-win\buildinfo md %mesa%\mesa-dist-win\buildinfo
@echo Dumping build environment information. This will take a short while...
@echo.

@rem Dump Windows version
@FOR /F "USEBACKQ tokens=4" %%a IN (`ver`) DO @set winver=%%a
@set winver=%winver:~0,-1%
@IF %toolchain%==msvc FOR /F "USEBACKQ" %%a IN (`%pythonloc% -c "print('.'.join('%winver%'.split('.')[:3]))"`) do @set winver=%%a
@IF %toolchain%==gcc echo python2 -c "print('.'.join('%winver%'.split('.')[:3]))">%mesa%\mesa-dist-win\buildinfo\temp.sh
@IF %toolchain%==gcc FOR /F "USEBACKQ" %%a IN (`%msysloc%\usr\bin\bash --login %mesa%\mesa-dist-win\buildinfo\temp.sh`) do @set winver=%%a
@IF %toolchain%==gcc del %mesa%\mesa-dist-win\buildinfo\temp.sh
@IF %toolchain%==gcc echo Windows %winver%>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==msvc echo Windows %winver%>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump Resource Hacker version
@set rhstate=2
@set ERRORLEVEL=0
@where /q ResourceHacker.exe
@IF ERRORLEVEL 1 set rhstate=1
@IF %rhstate%==1 IF NOT EXIST %mesa%\resource-hacker\ResourceHacker.exe set rhstate=0
@IF %rhstate%==1 SET PATH=%mesa%\resource-hacker\;%PATH%
@IF %rhstate% GTR 0 FOR /F "USEBACKQ tokens=*" %%a IN (`where ResourceHacker.exe`) do @set rhloc="%%a"
@IF %rhstate% GTR 0 ResourceHacker.exe -open %rhloc% -action extract -mask VERSIONINFO,, -save %mesa%\mesa-dist-win\buildscript\assets\temp.rc -log NUL
@IF %rhstate% GTR 0 set PATH=%oldpath%
@IF %rhstate% GTR 0 set exitloop=1&FOR /F "tokens=2 skip=2 USEBACKQ" %%a IN (`type %mesa%\mesa-dist-win\buildscript\assets\temp.rc`) do @IF defined exitloop set "exitloop="&set rhver=%%a
@IF %rhstate% GTR 0 IF %toolchain%==gcc echo Ressource Hacker %rhver:,=.%>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %rhstate% GTR 0 IF %toolchain%==msvc echo Ressource Hacker %rhver:,=.%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump 7-Zip version
@IF EXIST %mesa%\mesa-dist-win\buildscript\assets\sevenzip.txt set "sevenzipver=<%mesa%\mesa-dist-win\buildscript\assets\sevenzip.txt"
@IF %toolchain%==gcc IF defined sevenzipver echo 7-Zip %sevenzipver%>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==msvc IF defined sevenzipver echo 7-Zip %sevenzipver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Get Git version
@SET ERRORLEVEL=0
@set gitstate=2
@where /q git.exe
@IF ERRORLEVEL 1 set gitstate=0
@IF NOT %gitstate%==0 FOR /F "USEBACKQ tokens=3" %%a IN (`git --version`) do @set gitver=%%a
@IF NOT %gitstate%==0 set "gitver=%gitver:.windows=%"
@IF defined gitver IF %toolchain%==gcc echo Git %gitver%>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF defined gitver IF %toolchain%==msvc echo Git %gitver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump MSYS2 environment
@IF %toolchain%==gcc echo.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo MSYS2 environment>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo ----------------->>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc %msysloc%\usr\bin\bash --login -c "pacman -Q">>%mesa%\mesa-dist-win\buildinfo\mingw.txt

@rem Dump Visual Studio environment
@IF %toolchain%==msvc echo Visual Studio %msvcver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc call %vsenv% %vsabi%>nul 2>&1
@IF %toolchain%==msvc set PATH=%oldpath%
@IF %toolchain%==msvc echo Windows SDK %WindowsSDKVersion:~0,-1%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump Python environment
@IF %toolchain%==msvc echo Python %fpythonver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo Python packages>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo --------------->>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc FOR /F "USEBACKQ skip=2 tokens=*" %%a IN (`%pythonloc% -W ignore -m pip list --disable-pip-version-check`) do @echo %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Get CMake version
@IF %toolchain%==msvc IF "%cmakestate%"=="1" set PATH=%mesa%\cmake\bin\;%PATH%
@IF %toolchain%==msvc IF NOT "%cmakestate%"=="0" IF NOT "%cmakestate%"=="" set exitloop=1&for /f "tokens=3 USEBACKQ" %%a IN (`cmake --version`) do @if defined exitloop set "exitloop="&echo CMake %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF "%cmakestate%"=="1" set PATH=%oldpath%

@rem Get Ninja version
@IF %toolchain%==msvc IF "%ninjastate%"=="1" set PATH=%mesa%\ninja\;%PATH%
@IF %toolchain%==msvc IF NOT "%ninjastate%"=="0" IF NOT "%ninjastate%"=="" for /f "USEBACKQ" %%a IN (`ninja --version`) do @echo Ninja %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF "%ninjastate%"=="1" set PATH=%oldpath%

@rem Get LLVM version
@IF %toolchain%==msvc IF EXIST %mesa%\llvm\%abi%-%llvmlink%\bin\llvm-config.exe FOR /F "USEBACKQ" %%a IN (`%mesa%\llvm\%abi%-%llvmlink%\bin\llvm-config.exe --version`) do @set llvmver=%%a
@IF %toolchain%==msvc IF EXIST %mesa%\llvm\%abi%-%llvmlink%\bin\llvm-config.exe echo LLVM %llvmver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Get flex and bison version
@IF %toolchain%==msvc IF "%flexstate%"=="1" set PATH=%mesa%\flexbison\;%PATH%
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" for /f "tokens=2 USEBACKQ" %%a IN (`win_flex --version`) do @echo flex %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" set exitloop=1&for /f "tokens=4 USEBACKQ" %%a IN (`win_bison --version`) do @if defined exitloop set "exitloop="&echo Bison %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF "%flexstate%"=="1" set PATH=%oldpath%

@rem Build comands
@IF %toolchain%==gcc echo.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo Build commands>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo -------------->>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo Build commands>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo -------------->>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@IF %toolchain%==gcc echo [2] scons build=release platform=windows machine=x86 toolchain=mingw libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [3] scons build=release platform=windows machine=x86_64 toolchain=mingw libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo Notes>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo ----->>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [0] Apply mesa-dist-win\patches\msys2-mingw_w64-fixes.patch before building Mesa.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [1] Apply mesa-dist-win\patches\s3tc.patch to enable S3TC texture cache.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [2] Navigate to Mesa3D source code in a MSYS2 MINGW32 shell and execute this command.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [3] Navigate to Mesa3D source code in a MSYS2 MINGW64 shell and execute this command.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt

@IF %toolchain%==msvc echo [1] md buildsys-x86-%llvmlink%^&cd buildsys-x86-%llvmlink%^&cmake -G "Ninja" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=%llvmlink% -DLLVM_ENABLE_RTTI=1 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_INSTALL_PREFIX=../x86-%llvmlink% ..>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [2] md buildsys-x64-%llvmlink%^&cd buildsys-x64-%llvmlink%^&cmake -G "Ninja" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=%llvmlink% -DLLVM_ENABLE_RTTI=1 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_INSTALL_PREFIX=../x64-%llvmlink% ..>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [3] ninja install>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [4] scons build=release platform=windows machine=x86 libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [4] scons build=release platform=windows machine=x86_64 libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo Notes>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo ----->>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [0] Apply mesa-dist-win\patches\s3tc.patch to enable S3TC texture cache.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [1] Natigate to LLVM source code in a Visual Studio x64_x86 Cross Tools Command Prompt and execute this command.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [2] Natigate to LLVM source code in a Visual Studio x64 Native Tools Command Prompt and execute this command.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [3] Execute this command after [1] and [2] respectively on same Visual Studio command line console.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [4] Navigate to Mesa3D source code in a standard Windows Command Prompt and execute any or both these commands.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Finished environment information dump.
@echo Done.
@IF %toolchain%==gcc echo Environment information has been written to %mesa%\mesa-dist-win\buildinfo\mingw.txt.
@IF %toolchain%==msvc echo Environment information has been written to %mesa%\mesa-dist-win\buildinfo\msvc.txt.
@echo.

@IF NOT EXIST %mesa%\mesa-dist-win\buildinfo md %mesa%\mesa-dist-win\buildinfo
@echo Dumping build environment information. This will take a short while...
@echo.

@rem Dump Windows version
@FOR /F "USEBACKQ tokens=4" %%a IN (`ver`) DO @set winver=%%a
@set winver=%winver:~0,-1%
@IF %toolchain%==msvc FOR /F "USEBACKQ" %%a IN (`%pythonloc% -c "print('.'.join('%winver%'.split('.')[:3]))"`) do @set winver=%%a
@IF %toolchain%==gcc echo python2 -c "print('.'.join('%winver%'.split('.')[:3]))">%mesa%\mesa-dist-win\buildinfo\temp.sh
@IF %toolchain%==gcc FOR /F "USEBACKQ" %%a IN (`%msysloc%\usr\bin\bash --login %mesa%\mesa-dist-win\buildinfo\temp.sh`) do @set winver=%%a
@IF %toolchain%==gcc del %mesa%\mesa-dist-win\buildinfo\temp.sh
@IF %toolchain%==gcc echo Windows %winver%>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==msvc echo Windows %winver%>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump Resource Hacker version
@set rhstate=2
@set ERRORLEVEL=0
@where /q ResourceHacker.exe
@IF ERRORLEVEL 1 set rhstate=1
@IF %rhstate%==1 IF NOT EXIST %mesa%\resource-hacker\ResourceHacker.exe set rhstate=0
@IF %rhstate%==1 SET PATH=%mesa%\resource-hacker\;%PATH%
@IF %rhstate% GTR 0 FOR /F "USEBACKQ tokens=*" %%a IN (`where ResourceHacker.exe`) do @set rhloc="%%a"
@IF %rhstate% GTR 0 ResourceHacker.exe -open %rhloc% -action extract -mask VERSIONINFO,, -save %mesa%\mesa-dist-win\buildscript\assets\temp.rc -log NUL
@IF %rhstate% GTR 0 set PATH=%oldpath%
@IF %rhstate% GTR 0 set exitloop=1&FOR /F "tokens=2 skip=2 USEBACKQ" %%a IN (`type %mesa%\mesa-dist-win\buildscript\assets\temp.rc`) do @IF defined exitloop set "exitloop="&set rhver=%%a
@IF %rhstate% GTR 0 IF %toolchain%==gcc echo Ressource Hacker %rhver:,=.%>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %rhstate% GTR 0 IF %toolchain%==msvc echo Ressource Hacker %rhver:,=.%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump 7-Zip version
@IF EXIST %mesa%\mesa-dist-win\buildscript\assets\sevenzip.txt set /p sevenzipver=<%mesa%\mesa-dist-win\buildscript\assets\sevenzip.txt
@IF %toolchain%==gcc IF defined sevenzipver echo 7-Zip %sevenzipver%>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==msvc IF defined sevenzipver echo 7-Zip %sevenzipver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Get Git version
@SET ERRORLEVEL=0
@set gitstate=2
@where /q git.exe
@IF ERRORLEVEL 1 set gitstate=0
@IF NOT %gitstate%==0 FOR /F "USEBACKQ tokens=3" %%a IN (`git --version`) do @set gitver=%%a
@IF NOT %gitstate%==0 set "gitver=%gitver:.windows=%"
@IF defined gitver IF %toolchain%==gcc echo Git %gitver%>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF defined gitver IF %toolchain%==msvc echo Git %gitver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump MSYS2 environment
@IF %toolchain%==gcc echo.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo MSYS2 environment>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo ----------------->>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc %msysloc%\usr\bin\bash --login -c "pacman -Q">>%mesa%\mesa-dist-win\buildinfo\mingw.txt

@rem Dump Visual Studio environment
@IF %toolchain%==msvc echo Visual Studio %msvcver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc call %vsenv% %vsabi%>nul 2>&1
@IF %toolchain%==msvc set PATH=%oldpath%
@IF %toolchain%==msvc echo Windows SDK %WindowsSDKVersion:~0,-1%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Dump Python environment
@IF %toolchain%==msvc echo Python %fpythonver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo Python packages>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo --------------->>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc FOR /F "USEBACKQ skip=2 tokens=*" %%a IN (`%pythonloc% -W ignore -m pip list --disable-pip-version-check`) do @echo %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Get CMake version
@IF %toolchain%==msvc IF "%cmakestate%"=="1" set PATH=%mesa%\cmake\bin\;%PATH%
@IF %toolchain%==msvc IF NOT "%cmakestate%"=="0" IF NOT "%cmakestate%"=="" set exitloop=1&for /f "tokens=3 USEBACKQ" %%a IN (`cmake --version`) do @if defined exitloop set "exitloop="&echo CMake %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF "%cmakestate%"=="1" set PATH=%oldpath%

@rem Get Ninja version
@IF %toolchain%==msvc IF "%ninjastate%"=="1" set PATH=%mesa%\ninja\;%PATH%
@IF %toolchain%==msvc IF NOT "%ninjastate%"=="0" IF NOT "%ninjastate%"=="" for /f "USEBACKQ" %%a IN (`ninja --version`) do @echo Ninja %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF "%ninjastate%"=="1" set PATH=%oldpath%

@rem Get LLVM version
@IF %toolchain%==msvc IF EXIST %mesa%\llvm\%abi%-%llvmlink%\bin\llvm-config.exe FOR /F "USEBACKQ" %%a IN (`%mesa%\llvm\%abi%-%llvmlink%\bin\llvm-config.exe --version`) do @set llvmver=%%a
@IF %toolchain%==msvc IF EXIST %mesa%\llvm\%abi%-%llvmlink%\bin\llvm-config.exe echo LLVM %llvmver%>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Get flex and bison version
@IF %toolchain%==msvc IF "%flexstate%"=="1" set PATH=%mesa%\flexbison\;%PATH%
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" for /f "tokens=2 USEBACKQ" %%a IN (`win_flex --version`) do @echo flex %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF NOT "%flexstate%"=="0" IF NOT "%flexstate%"=="" set exitloop=1&for /f "tokens=4 USEBACKQ" %%a IN (`win_bison --version`) do @if defined exitloop set "exitloop="&echo Bison %%a>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc IF "%flexstate%"=="1" set PATH=%oldpath%

@rem Build comands
@IF %toolchain%==gcc echo.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo Build commands>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo -------------->>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo Build commands>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo -------------->>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@IF %toolchain%==gcc echo [2] scons build=release platform=windows machine=x86 toolchain=mingw libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [3] scons build=release platform=windows machine=x86_64 toolchain=mingw libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo Notes>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo ----->>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [0] Apply mesa-dist-win\patches\msys2-mingw_w64-fixes.patch before building Mesa.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [1] Apply mesa-dist-win\patches\s3tc.patch to enable S3TC texture cache.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [2] Navigate to Mesa3D source code in a MSYS2 MINGW32 shell and execute this command.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt
@IF %toolchain%==gcc echo [3] Navigate to Mesa3D source code in a MSYS2 MINGW64 shell and execute this command.>>%mesa%\mesa-dist-win\buildinfo\mingw.txt

@IF %toolchain%==msvc echo [1] md buildsys-x86-%llvmlink%^&cd buildsys-x86-%llvmlink%^&cmake -G "Ninja" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=%llvmlink% -DLLVM_ENABLE_RTTI=1 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_INSTALL_PREFIX=../x86-%llvmlink% ..>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [2] md buildsys-x64-%llvmlink%^&cd buildsys-x64-%llvmlink%^&cmake -G "Ninja" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=%llvmlink% -DLLVM_ENABLE_RTTI=1 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_INSTALL_PREFIX=../x64-%llvmlink% ..>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [3] ninja install>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [4] scons build=release platform=windows machine=x86 libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [4] scons build=release platform=windows machine=x86_64 libgl-gdi osmesa graw-gdi>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo Notes>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo ----->>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [0] Apply mesa-dist-win\patches\s3tc.patch to enable S3TC texture cache.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [1] Natigate to LLVM source code in a Visual Studio x64_x86 Cross Tools Command Prompt and execute this command.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [2] Natigate to LLVM source code in a Visual Studio x64 Native Tools Command Prompt and execute this command.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [3] Execute this command after [1] and [2] respectively on same Visual Studio command line console.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt
@IF %toolchain%==msvc echo [4] Navigate to Mesa3D source code in a standard Windows Command Prompt and execute any or both these commands.>>%mesa%\mesa-dist-win\buildinfo\msvc.txt

@rem Finished environment information dump.
@echo Done.
@IF %toolchain%==gcc echo Environment information has been written to %mesa%\mesa-dist-win\buildinfo\mingw.txt.
@IF %toolchain%==msvc echo Environment information has been written to %mesa%\mesa-dist-win\buildinfo\msvc.txt.
@echo.

Fix 7-zip version information dump.

Fix 7-zip version information dump.


rem Parameters are:
rem doBuild.bat Win32|x64 FULL|INCREMENTAL RELEASE|NIGHTLY UPLOAD|NOUPLOAD

echo %date% - %time%

if "%1"=="x64" (
    set PLATFORM=x64
    set ARCH=64
) else (
    set PLATFORM=Win32
    set ARCH=32
)
set DO_FULL_BUILD=%2
set DO_RELEASE_BUILD=%3
set DO_UPLOAD=%4

echo stop any instances that might already be running.
pskill javaw.exe
pskill java.exe

cd /d %~dp0\..
echo working directory is
cd

if "%DO_FULL_BUILD%"=="FULL" (
    pushd ..\3rdparty
    svn cleanup --non-interactive
    svn update --accept postpone --force --ignore-externals --non-interactive
    popd

    pushd ..\3rdpartypublic
    echo update 3rdpartypublic tree from the repository
    svn cleanup --non-interactive
    rem - been having trouble updating from boost.org, but don't need to do that anyhow for now.
    svn update --accept postpone --force --ignore-externals --non-interactive
    popd
)

echo update micromanager tree from the repository
svn cleanup --non-interactive
svn update --accept postpone --non-interactive
pushd SecretDeviceAdapters
svn cleanup --non-interactive
svn update --accept postpone --non-interactive
popd

echo Building native C++ libraries....

echo setup include path for Visual Studio....
set include=

if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    set VC_PATH=\Program Files (x86)\Microsoft Visual Studio 9.0\VC\
) else (
    set VC_PATH=\Program Files\Microsoft Visual Studio 9.0\VC\
)
pushd "%VC_PATH%"
call vcvarsall.bat
popd

set include=d:\projects\3rdpartypublic\boost;%include%

echo include path is:
set include

echo continue working in:
cd
set buildswitch=/build
IF "%DO_FULL_BUILD%"=="FULL" SET buildswitch=/rebuild

echo building core with command:
echo start /wait vcexpress .\MMCore\MMCore.vcproj %buildswitch% "Release|%PLATFORM%"
start /wait vcexpress .\MMCore\MMCore.vcproj %buildswitch% "Release|%PLATFORM%"

echo building python wrapper with command:
echo start /wait vcexpress .\MMCorePy_wrap\MMCorePy_wrap.sln %buildswitch% "Release|%PLATFORM%"
start /wait vcexpress .\MMCorePy_wrap\MMCorePy_wrap.sln %buildswitch% "Release|%PLATFORM%"
copy .\bin_%PLATFORM%\MMCorePy.py .\Install_%PLATFORM%\micro-manager
copy .\bin_%PLATFORM%\_MMCorePy.pyd .\Install_%PLATFORM%\micro-manager
copy .\MMCorePy_wrap\MMCoreWrapDemo.py .\Install_%PLATFORM%\micro-manager

echo building Java wrapper with command:
echo start /wait vcexpress .\MMCoreJ_wrap\MMCoreJ_wrap.sln %buildswitch% "Release|%PLATFORM%"
start /wait vcexpress .\MMCoreJ_wrap\MMCoreJ_wrap.sln %buildswitch% "Release|%PLATFORM%"

echo Update the version number in MMVersion.java
set mmversion=""
set YYYYMMDD=""
set TARGETNAME=""
call buildscripts\setmmversionvariable
call buildscripts\setyyyymmddvariable
pushd .\mmstudio\src\org\micromanager
del MMVersion.java
svn update --non-interactive
rem for nightly builds we put the version + the date-stamp
if "%DO_RELEASE_BUILD%"=="RELEASE" (
    set TARGETNAME=MMSetup%ARCH%BIT_%mmversion%.exe
    sed -i "s/\"1\.4.*/\"%mmversion%\";/"  MMVersion.java
) else (
    set TARGETNAME=MMSetup%ARCH%BIT_%mmversion%_%YYYYMMDD%.exe
    sed -i "s/\"1\.4.*/\"%mmversion%  %YYYYMMDD%\";/"  MMVersion.java
)
popd

rem remove any installer package with exactly the same name as the current output
echo trying to delete \Projects\micromanager\Install_%PLATFORM%\Output\MMSetup_.exe
del \Projects\micromanager\Install_%PLATFORM%\Output\MMSetup_.exe
echo trying to delete \Projects\micromanager\Install_%PLATFORM%\Output\%TARGETNAME%
del \Projects\micromanager\Install_%PLATFORM%\Output\%TARGETNAME%

ECHO incremental build of Java components...

set cleantarget=
IF "%DO_FULL_BUILD%"=="FULL" SET cleantarget=clean

PUSHD \projects\micromanager\mmStudio\src
echo building mmStudio with command:
echo call ant -buildfile ../build%ARCH%.xml %cleantarget% compile build buildMMReader
call ant -buildfile ../build%ARCH%.xml %cleantarget% compile build buildMMReader
POPD

rem haven't got to the bottom of this yet, but Pixel Calibrator and Slide Explorer need this jar file there....
copy \projects\micromanager\bin_%PLATFORM%\plugins\Micro-Manager\MMJ_.jar \projects\micromanager\bin_%PLATFORM%\

pushd buildscripts
call buildJars %DO_FULL_BUILD%
popd

pushd mmStudio\src
call ant -buildfile ../build%ARCH%.xml install packInstaller
popd

pushd \Projects\micromanager\Install_%PLATFORM%\Output
rename MMSetup_.exe  %TARGETNAME%
popd

REM -- try to install on build machine
set DO_INSTALL=YES
if "%PLATFORM%"=="x64" (
    if not "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
        set DO_INSTALL=NO
    )
)
if "%DO_INSTALL%"=="YES" (
    \Projects\micromanager\Install_%PLATFORM%\Output\%TARGETNAME%  /silent
    ECHO "Done installing"
)

if "%DO_UPLOAD%"=="UPLOAD" (
    pscp -i c:\projects\MM.ppk -batch /projects/micromanager/Install_%PLATFORM%/Output/%TARGETNAME% arthur@valelab.ucsf.edu:../MM/public_html/nightlyBuilds/1.4/Windows/%TARGETNAME%
)

pushd .\mmstudio\src\org\micromanager
del MMVersion.java
svn update --non-interactive
popd

echo %date% - %time%

rem Parameters are:
rem doBuild.bat Win32|x64 FULL|INCREMENTAL RELEASE|NIGHTLY UPLOAD|NOUPLOAD

echo %date% - %time%

if "%1"=="x64" (
    set PLATFORM=x64
    set ARCH=64
) else (
    set PLATFORM=Win32
    set ARCH=32
)
set DO_FULL_BUILD=%2
set DO_RELEASE_BUILD=%3
set DO_UPLOAD=%4

echo stop any instances that might already be running.
pskill javaw.exe
pskill java.exe

cd /d %~dp0\..
echo working directory is
cd

if "%DO_FULL_BUILD%"=="FULL" (
    pushd ..\3rdparty
    svn cleanup --non-interactive
    svn update --accept postpone --force --ignore-externals --non-interactive
    popd

    pushd ..\3rdpartypublic
    echo update 3rdpartypublic tree from the repository
    svn cleanup --non-interactive
    rem - been having trouble updating from boost.org, but don't need to do that anyhow for now.
    svn update --accept postpone --force --ignore-externals --non-interactive
    popd
)

echo update micromanager tree from the repository
svn cleanup --non-interactive
svn update --accept postpone --non-interactive
pushd SecretDeviceAdapters
svn cleanup --non-interactive
svn update --accept postpone --non-interactive
popd

echo Building native C++ libraries....

echo setup include path for Visual Studio....
set include=

set VC_PATH=\Program Files (x86)\Microsoft Visual Studio 9.0\VC\
if not "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    set VC_PATH=\Program Files\Microsoft Visual Studio 9.0\VC\
)
pushd "%VC_PATH%"
call vcvarsall.bat
popd

set include=d:\projects\3rdpartypublic\boost;%include%

echo include path is:
set include

echo continue working in:
cd
set buildswitch=/build
IF "%DO_FULL_BUILD%"=="FULL" SET buildswitch=/rebuild

echo building core with command:
echo start /wait vcexpress .\MMCore\MMCore.vcproj %buildswitch% "Release|%PLATFORM%"
start /wait vcexpress .\MMCore\MMCore.vcproj %buildswitch% "Release|%PLATFORM%"

echo building python wrapper with command:
echo start /wait vcexpress .\MMCorePy_wrap\MMCorePy_wrap.sln %buildswitch% "Release|%PLATFORM%"
start /wait vcexpress .\MMCorePy_wrap\MMCorePy_wrap.sln %buildswitch% "Release|%PLATFORM%"
copy .\bin_%PLATFORM%\MMCorePy.py .\Install_%PLATFORM%\micro-manager
copy .\bin_%PLATFORM%\_MMCorePy.pyd .\Install_%PLATFORM%\micro-manager
copy .\MMCorePy_wrap\MMCoreWrapDemo.py .\Install_%PLATFORM%\micro-manager

echo building Java wrapper with command:
echo start /wait vcexpress .\MMCoreJ_wrap\MMCoreJ_wrap.sln %buildswitch% "Release|%PLATFORM%"
start /wait vcexpress .\MMCoreJ_wrap\MMCoreJ_wrap.sln %buildswitch% "Release|%PLATFORM%"

echo Update the version number in MMVersion.java
set mmversion=""
set YYYYMMDD=""
set TARGETNAME=""
call buildscripts\setmmversionvariable
call buildscripts\setyyyymmddvariable
pushd .\mmstudio\src\org\micromanager
del MMVersion.java
svn update --non-interactive
rem for nightly builds we put the version + the date-stamp
if "%DO_RELEASE_BUILD%"=="RELEASE" (
    set TARGETNAME=MMSetup%ARCH%BIT_%mmversion%.exe
    sed -i "s/\"1\.4.*/\"%mmversion%\";/"  MMVersion.java
) else (
    set TARGETNAME=MMSetup%ARCH%BIT_%mmversion%_%YYYYMMDD%.exe
    sed -i "s/\"1\.4.*/\"%mmversion%  %YYYYMMDD%\";/"  MMVersion.java
)
popd

rem remove any installer package with exactly the same name as the current output
echo trying to delete \Projects\micromanager\Install_%PLATFORM%\Output\MMSetup_.exe
del \Projects\micromanager\Install_%PLATFORM%\Output\MMSetup_.exe
echo trying to delete \Projects\micromanager\Install_%PLATFORM%\Output\%TARGETNAME%
del \Projects\micromanager\Install_%PLATFORM%\Output\%TARGETNAME%

ECHO incremental build of Java components...

set cleantarget=
IF "%DO_FULL_BUILD%"=="FULL" SET cleantarget=clean

PUSHD \projects\micromanager\mmStudio\src
echo building mmStudio with command:
echo call ant -buildfile ../build%ARCH%.xml %cleantarget% compile build buildMMReader
call ant -buildfile ../build%ARCH%.xml %cleantarget% compile build buildMMReader
POPD

rem haven't got to the bottom of this yet, but Pixel Calibrator and Slide Explorer need this jar file there....
copy \projects\micromanager\bin_%PLATFORM%\plugins\Micro-Manager\MMJ_.jar \projects\micromanager\bin_%PLATFORM%\

pushd buildscripts
call buildJars %DO_FULL_BUILD%
popd

pushd mmStudio\src
call ant -buildfile ../build%ARCH%.xml install packInstaller
popd

pushd \Projects\micromanager\Install_%PLATFORM%\Output
rename MMSetup_.exe  %TARGETNAME%
popd

REM -- try to install on build machine
set DO_INSTALL=YES
if "%PLATFORM%"=="x64" (
    if not "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
        set DO_INSTALL=NO
    )
)
if "%DO_INSTALL%"=="YES" (
    \Projects\micromanager\Install_%PLATFORM%\Output\%TARGETNAME%  /silent
    ECHO "Done installing"
)

if "%DO_UPLOAD%"=="UPLOAD" (
    pscp -i c:\projects\MM.ppk -batch /projects/micromanager/Install_%PLATFORM%/Output/%TARGETNAME% arthur@valelab.ucsf.edu:../MM/public_html/nightlyBuilds/1.4/Windows/%TARGETNAME%
)

pushd .\mmstudio\src\org\micromanager
del MMVersion.java
svn update --non-interactive
popd

echo %date% - %time%

Work around batch file quirk in build script.

(Cannot use parentheses in command parameters inside a parenthesized
block.)

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@10980 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd


dnvm upgrade
cd ./src/AspNet.Mvc.Formatters.Protobuf
dnu restore
dnu pack

Remove DNX Install

Remove DNX Install


@ECHO OFF
:: do not run this script manually

SETLOCAL
:: todo: support for authtentication

IF DEFINED YAWDS_CONF_GENERAL_CONSOLE_COLOR (
	COLOR %YAWDS_CONF_GENERAL_CONSOLE_COLOR%
)

IF NOT DEFINED YAWDS_CONF_UPDATE_CHECK_URL (
	ECHO Missing update.check_url config value in environment.ini
	ECHO Cannot checkout for new versions
	GOTO END
)

IF [%1]==[--confirm] (
	GOTO SET_NOCONFIRM
)
GOTO UPDATE

:SET_NOCONFIRM
SET yawds_from_start=1
GOTO UPDATE

:UPDATE

IF [%YAWDS_CONF_UPDATE_ENABLED%]==[0] (
	IF NOT DEFINED yawds_from_start (
		ECHO Environment update is disabled
	)
	GOTO END
)

IF NOT EXIST "%TEMP%" MKDIR "%TEMP%"

IF [%YAWDS_CONF_UPDATE_CHECK_URL_AUTH%]==[1] (
	:: exit if it was called from start.cmd
	IF DEFINED yawds_from_start (
		GOTO END
	)
	ECHO Authentication is required to update
	CALL node "%YAWDS_STACK_PATH%\scripts\node_scripts\prompt\update_auth" "%TEMP%\yawds_update.bat" "update"
	IF NOT ERRORLEVEL 0 (
		ECHO Error setting authtentication credentials
		GOTO END_ERROR
	)
	GOTO CHECK_AUTH_HTTP
) ELSE (
	GOTO CHECK_HTTP
)

:CHECK_AUTH_HTTP
CALL "%TEMP%\yawds_update.bat"
IF NOT DEFINED YAWDS_UPDATE_USER (
	ECHO Authentication required
	GOTO END_ERROR
)
CALL wget -t 2 --timeout 2 -q -nv "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\yawds_latest.ini" "%YAWDS_CONF_UPDATE_CHECK_URL%"
GOTO CONTINUE

:CHECK_HTTP
CALL wget wget -t 2 --timeout 2 -q -nv -O "%TEMP%\yawds_latest.ini" "%YAWDS_CONF_UPDATE_CHECK_URL%"

:CONTINUE
IF NOT ERRORLEVEL 0 (
	ECHO Cannot check out remote version for updates
	ECHO Be sure you have network connection and try again
	GOTO END_ERROR
)

CALL node "%YAWDS_STACK_PATH%\scripts\node_scripts\ini2batch" "%TEMP%\yawds_latest.ini" "update" > "%TEMP%\yawds_update.bat"
CALL "%TEMP%\yawds_update.bat"
IF NOT ERRORLEVEL 0 GOTO CONFIG_ERROR

IF NOT DEFINED YAWDS_UPDATE_VERSION (
	ECHO Cannot check the latest version
	GOTO END_ERROR
)

IF NOT DEFINED YAWDS_UPDATE_DOWNLOAD (
	ECHO Download URL not defined. Cannot update
	GOTO END
)

IF [%YAWDS_VERSION%]==[%YAWDS_UPDATE_VERSION%] (
	IF DEFINED yawds_from_start (
		GOTO END
	)
	ECHO You are on the latest version: %YAWDS_VERSION%
	ECHO Nothing to update
	GOTO END
)

IF DEFINED yawds_from_start ECHO.
ECHO There is a new version available: %YAWDS_UPDATE_VERSION%

IF DEFINED YAWDS_UPDATE_RELEASE_NOTES (
	ECHO.
	ECHO Release notes:
	ECHO "%YAWDS_UPDATE_RELEASE_NOTES%"
	ECHO.
)
IF DEFINED YAWDS_UPDATE_RELEASE_NOTES_URL (
	IF [%YAWDS_CONF_UPDATE_CHECK_URL_AUTH%]==[1] (
		CALL wget -t 2 --timeout 2 -q "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\release_notes" %YAWDS_UPDATE_RELEASE_NOTES_URL%
	) ELSE (
		CALL wget -t 2 --timeout 2 -q -O "%TEMP%\release_notes" "%YAWDS_UPDATE_RELEASE_NOTES_URL%"
	)
	IF EXIST "%TEMP%\release_notes" (
		ECHO.
		ECHO Release notes
		ECHO ---------------------------------------------
		TYPE "%TEMP%\release_notes"
		ECHO.
		ECHO ---------------------------------------------
		ECHO.
	)
)

:: require to run from update.cmd (due to windows files blocking issues)
IF DEFINED yawds_from_start (
	ECHO.
	ECHO To proceed with the update, you must run update.cmd
	ECHO.
	PAUSE
	GOTO END
)

SET /P confirm_update=Do you want to process with the update? [y/n]:
IF NOT [%confirm_update%]==[y] (
	ECHO Canceled
	GOTO END
)

ECHO.
ECHO IMPORTANT:
ECHO You must close all the running processes before continue
ECHO You can use stack\tools\cprocess.exe to see the running processes
ECHO.

PAUSE

ECHO Downloading latest version...

IF [%YAWDS_UPDATE_DOWNLOAD_AUTH%]==[1] SET require_auth=1
IF [%YAWDS_CONF_UPDATE_CHECK_URL_AUTH%]==[1] SET require_auth=1

IF [%require_auth%]==[1] (
	CALL wget -t 2 --timeout 5 --progress=bar "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\yawds-latest-win32.zip" "%YAWDS_UPDATE_DOWNLOAD%"
) ELSE (
	CALL wget -t 2 --timeout 5 --progress=bar -O "%TEMP%\yawds-latest-win32.zip" "%YAWDS_UPDATE_DOWNLOAD%"
)
IF NOT ERRORLEVEL 0 (
	ECHO Download error
	GOTO END
)
IF NOT EXIST "%TEMP%\yawds-latest-win32.zip" (
	ECHO Download error: file do not exist
	ECHO Check your network connectivity
	GOTO END
)

ECHO.
ECHO Download completed!
ECHO.

:: backup filename
FOR /F "tokens=* delims= " %%a IN ("%TIME:~0,2%") DO SET hour=%%a
FOR /F "tokens=* delims= " %%a IN ("%TIME:~3,2%") DO SET minute=%%a
SET backup_file=stack-%YAWDS_VERSION%-%date:~6,4%-%date:~3,2%-%date:~0,2%-%hour%%minute%.zip

:: backup the current stack environment
SET /P backup=Do you want to backup the current environment? [Y/n]:
IF [%backup%]==[y] (
	IF NOT EXIST "%YAWDS_HOME%\backup" MKDIR "%YAWDS_HOME%\backup"
	CD "%YAWDS_HOME%\stack"
	:: create tarball
	CALL 7za -mx7 -y a "%backup_file%" *
	IF NOT ERRORLEVEL 0 (
		ECHO.
		ECHO Error while creating the backup...
		GOTO END_ERROR
	)
	:: move to backup folder
	MOVE /Y "%backup_file%" "%YAWDS_HOME%\backup"

	ECHO.
	ECHO Backup created succesfully in:
	ECHO %YAWDS_HOME%\backup\
	ECHO.
	CD "%YAWDS_HOME%"
	PAUSE
)

MOVE /Y "%YAWDS_HOME%\stack" "%YAWDS_HOME%\stack_old" > nul
IF NOT EXIST "%YAWDS_HOME%\stack_old" (
	ECHO.
	ECHO ERROR: cannot write new files
	ECHO Be sure there is not any blocking process still running
	ECHO You can exec stack\tools\cprocess.exe in to see the running processes
	ECHO.
	GOTO END_ERROR
)

ECHO.
ECHO Installing new version...
ECHO.

:: unzip directory
IF EXIST "%TEMP%\yawds_latest%" (
	DEL /F /Q /S "%TEMP%\yawds_latest%" > nul
)
MKDIR "%TEMP%\yawds_latest%"
CD "%TEMP%\yawds_latest"

:: install new version
CALL "%YAWDS_HOME%\stack_old\tools\7za.exe" -y e "%TEMP%\yawds-latest-win32.zip"
IF NOT EXIST "%TEMP%\yawds_latest\stack" (
	ECHO.
	ECHO ERROR: cannot extract and write new files
	ECHO Restoring old stack environment version...
	ECHO.
	MOVE /Y "%YAWDS_HOME%\stack_old" "%YAWDS_HOME%\stack"
	GOTO END_ERROR
)

MOVE /Y "%TEMP%\yawds_latest\stack" "%YAWDS_HOME%\stack"
IF NOT EXIST "%YAWDS_HOME%\stack" (
	ECHO.
	ECHO ERROR: cannot write stack directory
	ECHO Restoring old stack environment version...
	ECHO.
	MOVE /Y "%YAWDS_HOME%\stack_old" "%YAWDS_HOME%\stack"
	GOTO END_ERROR)

:: removing old version
ECHO Removing old version...
DEL /F /Q /S "%YAWDS_HOME%\stack_old" > nul
:: removing old version
ECHO Cleaning download files...
DEL /F /Q /S "%TEMP%\yawds_latest" > nul

ECHO.
ECHO %YAWDS_CONF_GENERAL_SHORTNAME% was updated succesfully!
ECHO.

IF DEFINED YAWDS_UPDATE_POST_UPDATE_SCRIPT (
	IF EXIST "%YAWDS_STACK_PATH%\%YAWDS_UPDATE_POST_UPDATE_SCRIPT%" (
		CALL "%YAWDS_STACK_PATH%\%YAWDS_UPDATE_POST_UPDATE_SCRIPT%"
	)
)

GOTO END

:VERSION_ERROR
ECHO Cannot check the latest version: error while reading the ini file
ECHO Cannot update. Try it again

:END
ECHO.
GOTO CLEAN

:END_ERROR
ECHO Cannot update. Try it again

:CLEAN
ECHO Cleaning temporary files...
IF EXIST "%TEMP%\yawds_update.bat" DEL /Q /F "%TEMP%\yawds_update.bat" > nul
IF EXIST "%TEMP%\yawds_latest.ini" DEL /Q /F "%TEMP%\yawds_latest.ini" > nul
IF EXIST "%TEMP%\release_notes" DEL /Q /F "%TEMP%\release_notes" > nul
IF EXIST "%TEMP%\yawds-latest-win32.zip" DEL /Q /F "%TEMP%\yawds-latest-win32.zip" > nul
IF DEFINED yawds_from_start CLS

ENDLOCAL

@ECHO OFF
:: do not run this script manually

SETLOCAL
:: todo: support for authtentication

IF DEFINED YAWDS_CONF_GENERAL_CONSOLE_COLOR (
	COLOR %YAWDS_CONF_GENERAL_CONSOLE_COLOR%
)

IF NOT DEFINED YAWDS_CONF_UPDATE_CHECK_URL (
	ECHO Missing update.check_url config value in environment.ini
	ECHO Cannot checkout for new versions
	GOTO END
)

IF [%1]==[--confirm] (
	GOTO SET_NOCONFIRM
)
GOTO UPDATE

:SET_NOCONFIRM
SET yawds_from_start=1
GOTO UPDATE

:UPDATE

IF [%YAWDS_CONF_UPDATE_ENABLED%]==[0] (
	IF NOT DEFINED yawds_from_start (
		ECHO Environment update is disabled
	)
	GOTO END
)

IF NOT EXIST "%TEMP%" MKDIR "%TEMP%"

IF [%YAWDS_CONF_UPDATE_CHECK_URL_AUTH%]==[1] (
	:: exit if it was called from start.cmd
	IF DEFINED yawds_from_start (
		GOTO END
	)
	ECHO Authentication is required to update
	CALL node "%YAWDS_STACK_PATH%\scripts\node_scripts\prompt\update_auth" "%TEMP%\yawds_update.bat" "update"
	IF NOT ERRORLEVEL 0 (
		ECHO Error setting authtentication credentials
		GOTO END_ERROR
	)
	GOTO CHECK_AUTH_HTTP
) ELSE (
	GOTO CHECK_HTTP
)

:CHECK_AUTH_HTTP
CALL "%TEMP%\yawds_update.bat"
IF NOT DEFINED YAWDS_UPDATE_USER (
	ECHO Authentication required
	GOTO END_ERROR
)
CALL wget -t 2 --timeout 2 -q -nv "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\yawds_latest.ini" "%YAWDS_CONF_UPDATE_CHECK_URL%"
GOTO CONTINUE

:CHECK_HTTP
CALL wget wget -t 2 --timeout 2 -q -nv -O "%TEMP%\yawds_latest.ini" "%YAWDS_CONF_UPDATE_CHECK_URL%"

:CONTINUE
IF NOT ERRORLEVEL 0 (
	ECHO Cannot check out remote version for updates
	ECHO Be sure you have network connection and try again
	GOTO END_ERROR
)

CALL node "%YAWDS_STACK_PATH%\scripts\node_scripts\ini2batch" "%TEMP%\yawds_latest.ini" "update" > "%TEMP%\yawds_update.bat"
CALL "%TEMP%\yawds_update.bat"
IF NOT ERRORLEVEL 0 GOTO CONFIG_ERROR

IF NOT DEFINED YAWDS_UPDATE_VERSION (
	ECHO Cannot check the latest version
	GOTO END_ERROR
)

IF NOT DEFINED YAWDS_UPDATE_DOWNLOAD (
	ECHO Download URL not defined. Cannot update
	GOTO END
)

IF [%YAWDS_VERSION%]==[%YAWDS_UPDATE_VERSION%] (
	IF DEFINED yawds_from_start (
		GOTO END
	)
	ECHO You are on the latest version: %YAWDS_VERSION%
	ECHO Nothing to update
	GOTO END
)

IF DEFINED yawds_from_start ECHO.
ECHO There is a new version available: %YAWDS_UPDATE_VERSION%

IF DEFINED YAWDS_UPDATE_RELEASE_NOTES (
	ECHO.
	ECHO Release notes:
	ECHO "%YAWDS_UPDATE_RELEASE_NOTES%"
	ECHO.
)
IF DEFINED YAWDS_UPDATE_RELEASE_NOTES_URL (
	IF [%YAWDS_CONF_UPDATE_CHECK_URL_AUTH%]==[1] (
		CALL wget -t 2 --timeout 2 -q "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\release_notes" %YAWDS_UPDATE_RELEASE_NOTES_URL%
	) ELSE (
		CALL wget -t 2 --timeout 2 -q -O "%TEMP%\release_notes" "%YAWDS_UPDATE_RELEASE_NOTES_URL%"
	)
	IF EXIST "%TEMP%\release_notes" (
		ECHO.
		ECHO Release notes
		ECHO ---------------------------------------------
		TYPE "%TEMP%\release_notes"
		ECHO.
		ECHO ---------------------------------------------
		ECHO.
	)
)

:: require to run from update.cmd (due to windows files blocking issues)
IF DEFINED yawds_from_start (
	ECHO.
	ECHO To proceed with the update, you must run update.cmd
	ECHO.
	PAUSE
	GOTO END
)

SET /P confirm_update=Do you want to process with the update? [y/n]:
IF NOT [%confirm_update%]==[y] (
	ECHO Canceled
	GOTO END
)

ECHO.
ECHO IMPORTANT:
ECHO You must close all the running processes before continue
ECHO You can use stack\tools\cprocess.exe to see the running processes
ECHO.

PAUSE

ECHO Downloading latest version...

IF [%YAWDS_UPDATE_DOWNLOAD_AUTH%]==[1] SET require_auth=1
IF [%YAWDS_CONF_UPDATE_CHECK_URL_AUTH%]==[1] SET require_auth=1

IF [%require_auth%]==[1] (
	CALL wget -t 2 --timeout 5 --progress=bar "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\yawds-latest-win32.zip" "%YAWDS_UPDATE_DOWNLOAD%"
) ELSE (
	CALL wget -t 2 --timeout 5 --progress=bar -O "%TEMP%\yawds-latest-win32.zip" "%YAWDS_UPDATE_DOWNLOAD%"
)
IF NOT ERRORLEVEL 0 (
	ECHO Download error
	GOTO END
)
IF NOT EXIST "%TEMP%\yawds-latest-win32.zip" (
	ECHO Download error: file do not exist
	ECHO Check your network connectivity
	GOTO END
)

ECHO.
ECHO Download completed!
ECHO.

:: backup filename
FOR /F "tokens=* delims= " %%a IN ("%TIME:~0,2%") DO SET hour=%%a
FOR /F "tokens=* delims= " %%a IN ("%TIME:~3,2%") DO SET minute=%%a
SET backup_file=stack-%YAWDS_VERSION%-%date:~6,4%-%date:~3,2%-%date:~0,2%-%hour%%minute%.zip

:: backup the current stack environment
SET /P backup=Do you want to backup the current environment? [Y/n]:
IF [%backup%]==[y] (
	IF NOT EXIST "%YAWDS_HOME%\backup" MKDIR "%YAWDS_HOME%\backup"
	CD "%YAWDS_HOME%\stack"
	:: create tarball
	CALL 7za -mx7 -y a "%backup_file%" *
	IF NOT ERRORLEVEL 0 (
		ECHO.
		ECHO Error while creating the backup...
		GOTO END_ERROR
	)
	:: move to backup folder
	MOVE /Y "%backup_file%" "%YAWDS_HOME%\backup"

	ECHO.
	ECHO Backup created succesfully in:
	ECHO %YAWDS_HOME%\backup\
	ECHO.
	CD "%YAWDS_HOME%"
	PAUSE
)

MOVE /Y "%YAWDS_HOME%\stack" "%YAWDS_HOME%\stack_old" > nul
IF NOT EXIST "%YAWDS_HOME%\stack_old" (
	ECHO.
	ECHO ERROR: cannot write new files
	ECHO Be sure there is not any blocking process still running
	ECHO You can exec stack\tools\cprocess.exe in to see the running processes
	ECHO.
	GOTO END_ERROR
)

ECHO.
ECHO Installing new version...
ECHO.

:: unzip directory
IF EXIST "%TEMP%\yawds_latest%" (
	DEL /Q /S "%TEMP%\yawds_latest%" > nul
)
MKDIR "%TEMP%\yawds_latest%"
CD "%TEMP%\yawds_latest"

:: install new version
CALL "%YAWDS_HOME%\stack_old\tools\7za.exe" -y e "%TEMP%\yawds-latest-win32.zip"
IF NOT EXIST "%TEMP%\yawds_latest\stack" (
	ECHO.
	ECHO ERROR: cannot extract and write new files
	ECHO Restoring old stack environment version...
	ECHO.
	MOVE /Y "%YAWDS_HOME%\stack_old" "%YAWDS_HOME%\stack"
	GOTO END_ERROR
)

MOVE /Y "%TEMP%\yawds_latest\stack" "%YAWDS_HOME%\stack"
IF NOT EXIST "%YAWDS_HOME%\stack" (
	ECHO.
	ECHO ERROR: cannot write stack directory
	ECHO Restoring old stack environment version...
	ECHO.
	MOVE /Y "%YAWDS_HOME%\stack_old" "%YAWDS_HOME%\stack"
	GOTO END_ERROR)

:: removing old version
ECHO Removing old version...
DEL /Q /S "%YAWDS_HOME%\stack_old" > nul
:: removing old version
ECHO Cleaning download files...
DEL /Q /S "%TEMP%\yawds_latest" > nul

ECHO.
ECHO %YAWDS_CONF_GENERAL_SHORTNAME% was updated succesfully!
ECHO.

IF DEFINED YAWDS_UPDATE_POST_UPDATE_SCRIPT (
	IF EXIST "%YAWDS_STACK_PATH%\%YAWDS_UPDATE_POST_UPDATE_SCRIPT%" (
		CALL "%YAWDS_STACK_PATH%\%YAWDS_UPDATE_POST_UPDATE_SCRIPT%"
	)
)

GOTO END

:VERSION_ERROR
ECHO Cannot check the latest version: error while reading the ini file
ECHO Cannot update. Try it again

:END
ECHO.
GOTO CLEAN

:END_ERROR
ECHO Cannot update. Try it again

:CLEAN
ECHO Cleaning temporary files...
IF EXIST "%TEMP%\yawds_update.bat" DEL /Q /F "%TEMP%\yawds_update.bat" > nul
IF EXIST "%TEMP%\yawds_latest.ini" DEL /Q /F "%TEMP%\yawds_latest.ini" > nul
IF EXIST "%TEMP%\release_notes" DEL /Q /F "%TEMP%\release_notes" > nul
IF EXIST "%TEMP%\yawds-latest-win32.zip" DEL /Q /F "%TEMP%\yawds-latest-win32.zip" > nul
IF DEFINED yawds_from_start CLS

ENDLOCAL

Update script general improvements

Update script general improvements


setlocal enabledelayedexpansion
set VSBAT="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"
set SCRIPT="x_tmp_build_x.bat"

set BUILDS[0]="d:\proj\1.0"
set BUILDS[0]="d:\proj\1.5"
set BUILDS[0]="d:\proj\2.0"

for %%i in (0,1,2) do (

rem === Temp build file ===
  type %VSBAT% > %SCRIPT%

  echo pushd !BUILDS[%%i]! >> %SCRIPT%

  echo svn update . >> %SCRIPT%

  echo rem devenv my.sln /clean >> %SCRIPT%
  echo devenv my.sln /build Debug >> %SCRIPT%
  echo rem devenv my.sln /build Release >> %SCRIPT%

  echo popd >> %SCRIPT%
rem === Temp build file end ===

  call %SCRIPT%

  del %SCRIPT%
)

Create msvcnightbuilder.bat

Create msvcnightbuilder.bat


mkdir build
cd build

cmake ^
    -G "NMake Makefiles" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DBUILD_TESTING=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
if errorlevel 1 exit 1

mkdir build
cd build

cmake ^
    -G "NMake Makefiles" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DBUILD_TESTING=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

fix typo

fix typo


set EIGEN_INCLUDE_DIR=%PREFIX%\Library\include\eigen3

"%PYTHON%" setup.py install

Update bld.bat

Update bld.bat


Fix architecture detection

Fix architecture detection


echo on
SetLocal EnableDelayedExpansion

REM This is the recommended way to choose the toolchain version, according to
REM Appveyor's documentation.
SET PATH=C:\Program Files (x86)\MSBuild\%TOOLCHAIN_VERSION%\Bin;%PATH%

set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio %TOOLCHAIN_VERSION%\VC\vcvarsall.bat"
set MSVCYEAR=vs2015
set MSVCVERSION=v140

if [%Platform%] NEQ [x64] goto win32
set TARGET_ARCH=x86_64
set TARGET_PROGRAM_FILES=%ProgramFiles%
rem call %VCVARSALL% amd64
rem if %ERRORLEVEL% NEQ 0 exit 1
goto download

:win32
echo on
if [%Platform%] NEQ [Win32] exit 1
set TARGET_ARCH=i686
set TARGET_PROGRAM_FILES=%ProgramFiles(x86)%
rem call %VCVARSALL% amd64_x86
rem if %ERRORLEVEL% NEQ 0 exit 1
goto download

:download
REM vcvarsall turns echo off
echo on

cd %ORIGINAL_PATH%

git clone https://github.com/Microsoft/vcpkg packages
cd packages
powershell -exec bypass scripts\bootstrap.ps1
vcpkg install zlib:x64-windows
vcpkg integrate install

cd ..
echo on

set RUST_URL=https://static.rust-lang.org/dist/rust-%RUST%-%TARGET_ARCH%-pc-windows-msvc.msi
echo Downloading %RUST_URL%...
mkdir build
powershell -Command "(New-Object Net.WebClient).DownloadFile('%RUST_URL%', 'build\rust-%RUST%-%TARGET_ARCH%-pc-windows-msvc.msi')"
if %ERRORLEVEL% NEQ 0 (
  echo ...downloading Rust failed.
  exit 1
)

start /wait msiexec /i build\rust-%RUST%-%TARGET_ARCH%-pc-windows-msvc.msi INSTALLDIR="%TARGET_PROGRAM_FILES%\Rust %RUST%" /quiet /qn /norestart
if %ERRORLEVEL% NEQ 0 exit 1

set PATH="%TARGET_PROGRAM_FILES%\Rust %RUST%\bin";%PATH%

if [%Configuration%] == [Release] set CARGO_MODE=--release

link /?
cl /?
rustc --version
cargo --version

set RUST_BACKTRACE=1

cargo build --all

cargo test --all

REM cargo build --manifest-path vcpkg\Cargo.toml
REM cargo build --manifest-path vcpkg_cli\Cargo.toml

REM cargo test --manifest-path vcpkg\Cargo.toml
REM cargo test --manifest-path vcpkg\Cargo.toml

cargo run --manifest-path vcpkg_cli\Cargo.toml -- probe zlib

echo on
SetLocal EnableDelayedExpansion

REM This is the recommended way to choose the toolchain version, according to
REM Appveyor's documentation.
SET PATH=C:\Program Files (x86)\MSBuild\%TOOLCHAIN_VERSION%\Bin;%PATH%

set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio %TOOLCHAIN_VERSION%\VC\vcvarsall.bat"
set MSVCYEAR=vs2015
set MSVCVERSION=v140

if [%Platform%] NEQ [x64] goto win32
set TARGET_ARCH=x86_64
set TARGET_PROGRAM_FILES=%ProgramFiles%
rem call %VCVARSALL% amd64
rem if %ERRORLEVEL% NEQ 0 exit 1
goto download

:win32
echo on
if [%Platform%] NEQ [Win32] exit 1
set TARGET_ARCH=i686
set TARGET_PROGRAM_FILES=%ProgramFiles(x86)%
rem call %VCVARSALL% amd64_x86
rem if %ERRORLEVEL% NEQ 0 exit 1
goto download

:download
REM vcvarsall turns echo off
echo on

cd %ORIGINAL_PATH%

git clone https://github.com/Microsoft/vcpkg packages
cd packages
powershell -exec bypass scripts\bootstrap.ps1
vcpkg install sqlite3:x64-windows
vcpkg integrate install

cd ..
echo on

set RUST_URL=https://static.rust-lang.org/dist/rust-%RUST%-%TARGET_ARCH%-pc-windows-msvc.msi
echo Downloading %RUST_URL%...
mkdir build
powershell -Command "(New-Object Net.WebClient).DownloadFile('%RUST_URL%', 'build\rust-%RUST%-%TARGET_ARCH%-pc-windows-msvc.msi')"
if %ERRORLEVEL% NEQ 0 (
  echo ...downloading Rust failed.
  exit 1
)

start /wait msiexec /i build\rust-%RUST%-%TARGET_ARCH%-pc-windows-msvc.msi INSTALLDIR="%TARGET_PROGRAM_FILES%\Rust %RUST%" /quiet /qn /norestart
if %ERRORLEVEL% NEQ 0 exit 1

set PATH="%TARGET_PROGRAM_FILES%\Rust %RUST%\bin";%PATH%

if [%Configuration%] == [Release] set CARGO_MODE=--release

link /?
cl /?
rustc --version
cargo --version

set RUST_BACKTRACE=1

cargo build --all

cargo test --all

REM cargo build --manifest-path vcpkg\Cargo.toml
REM cargo build --manifest-path vcpkg_cli\Cargo.toml

REM cargo test --manifest-path vcpkg\Cargo.toml
REM cargo test --manifest-path vcpkg\Cargo.toml

cargo run --manifest-path vcpkg_cli\Cargo.toml -- probe sqlite3

test probing for sqlite3 not zlib

test probing for sqlite3 not zlib


echo OFF

set REPOSITORY="PkgTk"
set DEFAULT_BUILD_TARGETS=python-parse python-pkgtk

set ANACONDA_BUILD_FLAGS=-c conda-forge %ANACONDA_BUILD_FLAGS%
if "%ANACONDA_CHANNEL%" == "" (
    set ANACONDA_CHANNEL=statiskit
) else (
    echo "Using anaconda channel: "%ANACONDA_CHANNEL%
    set ANACONDA_BUILD_FLAGS=-c statiskit %ANACONDA_BUILD_FLAGS%
)

if "%BUILD_TARGETS%" == "" (
    set BUILD_TARGETS=%DEFAULT_BUILD_TARGETS%
) else (
    echo "Targets to build: "%BUILD_TARGETS%
)

echo ON

if not exist bld.bat (
    if exist %REPOSITORY% (
        rmdir %REPOSITORY% /s /q
    )
    git clone https://github.com/%ANACONDA_CHANNEL%/%REPOSITORY%.git
    if %errorlevel% neq 0 (
        exit /b %errorlevel%
    )
    cd %REPOSITORY%/conda
)

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
if %errorlevel% neq 0 (
    if exist %REPOSITORY% (
        rmdir %REPOSITORY% /s /q
    )
    exit /b %errorlevel%
)
cd toolchain
call config.bat
if %errorlevel% neq 0 (
    cd ..
    if exist %REPOSITORY% (
        rmdir %REPOSITORY% /s /q
    )
    rmdir toolchain /s /q
    exit /b %errorlevel%
)
cd ..
rmdir toolchain /s /q

for %%x in (%BUILD_TARGETS%) do (
    conda build %%x -c %ANACONDA_CHANNEL% %ANACONDA_BUILD_FLAGS%
    if %errorlevel% neq 0 (
        if exist %REPOSITORY% (
            rmdir %REPOSITORY% /s /q
        )
        exit /b %errorlevel%
    )
)

if exist %REPOSITORY% (
    rmdir %REPOSITORY% /s /q
)

echo OFF

set REPOSITORY=PkgTk
set DEFAULT_BUILD_TARGETS=python-parse python-pkgtk

set ANACONDA_BUILD_FLAGS=-c conda-forge %ANACONDA_BUILD_FLAGS%
if "%ANACONDA_CHANNEL%" == "" (
    set ANACONDA_CHANNEL=statiskit
) else (
    echo "Using anaconda channel: "%ANACONDA_CHANNEL%
    set ANACONDA_BUILD_FLAGS=-c statiskit %ANACONDA_BUILD_FLAGS%
)

if "%BUILD_TARGETS%" == "" (
    set BUILD_TARGETS=%DEFAULT_BUILD_TARGETS%
) else (
    echo "Targets to build: "%BUILD_TARGETS%
)

echo ON

if not exist bld.bat (
    if exist %REPOSITORY% (
        rmdir %REPOSITORY% /s /q
    )
    git clone https://github.com/%ANACONDA_CHANNEL%/%REPOSITORY%.git
    if %errorlevel% neq 0 (
        exit /b %errorlevel%
    )
    cd %REPOSITORY%/conda
)

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
if %errorlevel% neq 0 (
    if exist %REPOSITORY% (
        rmdir %REPOSITORY% /s /q
    )
    exit /b %errorlevel%
)
cd toolchain
call config.bat
if %errorlevel% neq 0 (
    cd ..
    if exist %REPOSITORY% (
        rmdir %REPOSITORY% /s /q
    )
    rmdir toolchain /s /q
    exit /b %errorlevel%
)
cd ..
rmdir toolchain /s /q

for %%x in (%BUILD_TARGETS%) do (
    conda build %%x -c %ANACONDA_CHANNEL% %ANACONDA_BUILD_FLAGS%
    if %errorlevel% neq 0 (
        if exist %REPOSITORY% (
            rmdir %REPOSITORY% /s /q
        )
        exit /b %errorlevel%
    )
)

if exist %REPOSITORY% (
    rmdir %REPOSITORY% /s /q
)

Update bld.bat

Update bld.bat