@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 [%YAWDS_CONF_UPDATE_ENABLED%]==[0] (
	ECHO Environment update is disabled
	GOTO END
)

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 ASK_CONFIRMATION

:SET_NOCONFIRM
SET yawds_from_start=1
GOTO UPDATE

:ASK_CONFIRMATION
SET /P confirm_update=Do you want to check for updates? [y/n]:
IF NOT [%confirm_update%]==[y] (
	ECHO Canceled
	GOTO END
)
ECHO.

:UPDATE

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 -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 -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%]==[0.1.2] (
	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 -q "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\release_notes" %YAWDS_UPDATE_RELEASE_NOTES_URL%
	) ELSE (
		CALL wget -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 --progress=bar "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\yawds-latest-win32.zip" "%YAWDS_UPDATE_DOWNLOAD%"
) ELSE (
	CALL wget --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 File do not exist
	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.

MKDIR "%YAWDS_HOME%\stack"
CD "%YAWDS_HOME%\stack"

:: install new version
CALL "%YAWDS_HOME%\stack_old\tools\7za.exe" -y e "%TEMP%\yawds-latest-win32.zip"
IF NOT EXIST "%YAWDS_HOME%\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
)

:: removing old version
DEL /F /Q /S "%YAWDS_HOME%\stack_old"

ECHO.
ECHO %YAWDS_CONF_GENERA_SHORTNAME% was updated succesfully!
ECHO.
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
IF EXIST "%TEMP%\yawds_update.bat" DEL /Q /F "%TEMP%\yawds_update.bat"
IF EXIST "%TEMP%\yawds_latest.ini" DEL /Q /F "%TEMP%\yawds_latest.ini"
IF EXIST "%TEMP%\release_notes" DEL /Q /F "%TEMP%\release_notes"
IF EXIST "%TEMP%\yawds-latest-win32.zip" DEL /Q /F "%TEMP%\yawds-latest-win32.zip"
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 [%YAWDS_CONF_UPDATE_ENABLED%]==[0] (
	ECHO Environment update is disabled
	GOTO END
)

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 ASK_CONFIRMATION

:SET_NOCONFIRM
SET yawds_from_start=1
GOTO UPDATE

:ASK_CONFIRMATION
SET /P confirm_update=Do you want to check for updates? [y/n]:
IF NOT [%confirm_update%]==[y] (
	ECHO Canceled
	GOTO END
)
ECHO.

:UPDATE

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 -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 -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 -q "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\release_notes" %YAWDS_UPDATE_RELEASE_NOTES_URL%
	) ELSE (
		CALL wget -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 --progress=bar "--http-user=%YAWDS_UPDATE_USER%" "--http-passwd=%YAWDS_UPDATE_PASSWORD%" -O "%TEMP%\yawds-latest-win32.zip" "%YAWDS_UPDATE_DOWNLOAD%"
) ELSE (
	CALL wget --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 File do not exist
	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.

MKDIR "%YAWDS_HOME%\stack"
CD "%YAWDS_HOME%\stack"

:: install new version
CALL "%YAWDS_HOME%\stack_old\tools\7za.exe" -y e "%TEMP%\yawds-latest-win32.zip"
IF NOT EXIST "%YAWDS_HOME%\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
)

:: removing old version
DEL /F /Q /S "%YAWDS_HOME%\stack_old"

ECHO.
ECHO %YAWDS_CONF_GENERA_SHORTNAME% was updated succesfully!
ECHO.
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
IF EXIST "%TEMP%\yawds_update.bat" DEL /Q /F "%TEMP%\yawds_update.bat"
IF EXIST "%TEMP%\yawds_latest.ini" DEL /Q /F "%TEMP%\yawds_latest.ini"
IF EXIST "%TEMP%\release_notes" DEL /Q /F "%TEMP%\release_notes"
IF EXIST "%TEMP%\yawds-latest-win32.zip" DEL /Q /F "%TEMP%\yawds-latest-win32.zip"
IF DEFINED yawds_from_start CLS

ENDLOCAL

update script

update script


@echo on
setlocal

:: setup compil env
set VC_DIR="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
:: find the varsall parameters
if "%PLATFORM%" == "msvc2017_64" set VC_VARSALL=amd64
if "%PLATFORM%" == "winrt_x64_msvc2017" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "winrt_x86_msvc2017" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "winrt_armv7_msvc2017" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "msvc2015_64" set VC_VARSALL=amd64
if "%PLATFORM%" == "msvc2015" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "static" set VC_VARSALL=amd64

call %VC_DIR% %VC_VARSALL%
echo "step 1"

set qtplatform=%PLATFORM%
for %%* in (.) do set CurrDirName=%%~nx*

echo "step 2"

echo C:\Qt\%QT_VER%\%qtplatform%\bin\qmake
ls C:\Qt\%QT_VER%\%qtplatform%\bin\
C:\Qt\%QT_VER%\%qtplatform%\bin\qmake .\app\ || exit /B 1
echo "step 3"

nmake qmake_all || exit /B 1
echo "step 4"

nmake || exit /B 1
echo "step 5"

nmake lrelease || exit /B 1
echo "step 6"

nmake INSTALL_ROOT=\projects\%CurrDirName%\install install || exit /B 1

@echo on
setlocal

:: setup compil env
set VC_DIR="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
:: find the varsall parameters
if "%PLATFORM%" == "msvc2017_64" set VC_VARSALL=amd64
if "%PLATFORM%" == "winrt_x64_msvc2017" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "winrt_x86_msvc2017" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "winrt_armv7_msvc2017" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "msvc2015_64" set VC_VARSALL=amd64
if "%PLATFORM%" == "msvc2015" set VC_VARSALL=amd64_x86
if "%PLATFORM%" == "static" set VC_VARSALL=amd64

call %VC_DIR% %VC_VARSALL%
echo "step 1"

for %%* in (.) do set CurrDirName=%%~nx*

echo "step 2"

echo C:\Qt\%QT_VER%\%PLATFORM%\bin\qmake
ls C:\Qt\%QT_VER%\%PLATFORM%\bin\
C:\Qt\%QT_VER%\%PLATFORM%\bin\qmake .\app\ || exit /B 1
echo "step 3"

nmake qmake_all || exit /B 1
echo "step 4"

nmake || exit /B 1
echo "step 5"

nmake lrelease || exit /B 1
echo "step 6"

nmake INSTALL_ROOT=\projects\%CurrDirName%\install install || exit /B 1

Update build-msvc.bat

Update build-msvc.bat


@echo off
echo Download and install Nodejs for windows from https://nodejs.org/en/#download
start https://nodejs.org/en/#download
echo Press a key when the installation of Nodejs has completed.
pause
cd /d "%~dp0\src"
"C:\Program Files\nodejs\npm" install

call npm install

call npm install


fake\fake.exe fake.fsx ver=%1
scripts\BuildHelpers\GDocUploader\bin\Debug\GDocUploader.exe -l %2 -p %3 -c %4 -f workdir\zip\YaccConstructor_%1.zip

fake\fake.exe fake.fsx ver=%1
scripts\BuildHelpers\GDocUploader\bin\Release\GDocUploader.exe -l %2 -p %3 -c %4 -f workdir\zip\YaccConstructor_%1.zip

Debug -> Release

Debug -> Release


:: Configure.
cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%PREFIX% .
if errorlevel 1 exit 1

:: Build.
nmake
if errorlevel 1 exit 1

:: Install.
nmake install
if errorlevel 1 exit 1

:: Configure.
cmake -D CMAKE_INSTALL_PREFIX=%PREFIX% .
if errorlevel 1 exit 1

:: Build.
nmake
if errorlevel 1 exit 1

:: Install.
nmake install
if errorlevel 1 exit 1

Remove option to produce NMake make files - lets see what the default does


@echo off
REM This file is part of the Zephir.
REM
REM (c) Zephir Team <team@zephir-lang.com>
REM
REM For the full copyright and license information, please view the LICENSE
REM file that was distributed with this source code.
cls

if "%PHP_PEAR_PHP_BIN%" neq "" (
	set PHPBIN=%PHP_PEAR_PHP_BIN%
) else set PHPBIN=php

SET mypath=%~dp0
echo %mypath:~0,-1%
"%PHPBIN%" "%mypath%\zephir" %*

@echo off
rem This file is part of the Zephir.
rem
rem (c) Zephir Team <team@zephir-lang.com>
rem
rem For the full copyright and license information, please view the LICENSE
rem file that was distributed with this source code.
cls

if "%PHP_PEAR_PHP_BIN%" neq "" (
	set PHPBIN=%PHP_PEAR_PHP_BIN%
) else set PHPBIN=php

SET mypath=%~dp0
echo %mypath:~0,-1%
"%PHPBIN%" "%mypath%\zephir" %*

Correct code style for batch file

Correct code style for batch file


@ECHO OFF
SETLOCAL

PUSHD %~dp0

SET "SUBWCREV=SubWCRev.exe"

"%SUBWCREV%" . "src\Version.h.in" "src\VersionRev.h" -f
IF %ERRORLEVEL% NEQ 0 GOTO NoSubWCRev

"%SUBWCREV%" . "res\Notepad2.exe.manifest.conf" "res\Notepad2.exe.manifest" -f >NUL
IF %ERRORLEVEL% NEQ 0 GOTO NoSubWCRev

GOTO END

:NoSubWCRev
ECHO. & ECHO SubWCRev, which is part of TortoiseSVN, wasn't found!
ECHO You should (re)install TortoiseSVN.
ECHO I'll use VERSION_REV=0 for now.

TYPE "res\Notepad2.exe.manifest.template" > "res\Notepad2.exe.manifest"
TYPE "src\VersionRev.h.template"          > "src\VersionRev.h"

:END
POPD
ENDLOCAL
EXIT /B

@ECHO OFF
SETLOCAL

PUSHD %~dp0

IF EXIST "SubWCRev.exe" SET "SUBWCREV=SubWCRev.exe"
FOR %%A IN (SubWCRev.exe) DO (SET SUBWCREV=%%~$PATH:A)
IF NOT DEFINED SUBWCREV GOTO SubNoSubWCRev

"%SUBWCREV%" . "src\Version.h.in" "src\VersionRev.h" -f
IF %ERRORLEVEL% NEQ 0 GOTO SubError

"%SUBWCREV%" . "res\Notepad2.exe.manifest.conf" "res\Notepad2.exe.manifest" -f >NUL
IF %ERRORLEVEL% NEQ 0 GOTO SubError
:END
POPD
ENDLOCAL
EXIT /B

:SubNoSubWCRev
ECHO. & ECHO SubWCRev, which is part of TortoiseSVN, wasn't found!
ECHO You should (re)install TortoiseSVN.
GOTO SubCommon

:SubError
ECHO Something went wrong when generating the revision number.

:SubCommon
ECHO I'll use VERSION_REV=0 for now.

TYPE "res\Notepad2.exe.manifest.template" > "res\Notepad2.exe.manifest"
TYPE "src\VersionRev.h.template"          > "src\VersionRev.h"
GOTO END

improve update_rev.bat

improve update_rev.bat

git-svn-id: 756506b3b0ea8c31733a8f0a5bb416c7e269da3d@739 28bd50df-7adb-d945-0439-6e466c6a13cc


set QL_DIR=C:\Miniconda\lib

nmake -C Python

nmake -C Python check

nmake -C Python wheel

pip install Python/dist/QuantLib-*.whl

set QL_DIR=C:\Miniconda\lib

cd Python
nmake
nmake check
nmake wheel
pip install Python/dist/QuantLib-*.whl

update build script

update build script


@echo off
set NANT=%~dp0\Tools\nant\bin\NAnt.exe -t:net-3.5

echo --- SETUP ---
echo A.  Set up for Visual Studio (creates AssemblyInfo.cs files).
echo.
echo --- TESTING ---
echo B.  Learn how to set up database and connection string for testing.
echo C.  How to increase the window scroll/size so you can see more test output.
echo D.  Build and run all tests.
echo.
echo --- BUILD ---
echo E.  Build NHibernate (Debug)
echo F.  Build NHibernate (Release)
echo G.  Build Release Package (Also runs tests and creates documentation)
echo.
choice /C abcdefg

if errorlevel 255 goto end
if errorlevel 7 goto build-release-package
if errorlevel 6 goto build-release
if errorlevel 5 goto build-debug
if errorlevel 4 goto build-test
if errorlevel 3 goto help-larger-window
if errorlevel 2 goto help-test-setup
if errorlevel 1 goto build-visual-studio
if errorlevel 0 goto end

:help-test-setup
echo.
echo 1.  Install SQL Server 2008 (or use the database included with VS).
echo 2.  Edit connection settings in build-common\nhibernate-properties.xml
echo.
echo 3.  If you want to run NUnit tests in Visual Studio directly,
echo     edit src\NHibernate.Test\App.config and change this property:
echo         connection.connection_string
echo     Note that you will need a third party tool to run tests in VS.
echo.
echo     You will also need to create a database called "nhibernate"
echo     if you just run the tests directly from VS.
echo.
goto end

:help-larger-window
echo.
echo 1.  Right click on the title bar of this window.
echo 2.  Select "Properties".
echo 3.  Select the "Layout" tab.
echo 4.  Set the following options.
echo         Screen Buffer Size
echo             Width: 160
echo             Height: 9999
echo         Window Size
echo             Width: 160
echo             Height: 50
echo.
goto end

:build-visual-studio
%NANT% visual-studio
goto end

:build-debug
%NANT% clean build
echo.
echo Assuming the build succeeded, your results will be in the build folder.
echo.
goto end

:build-release
%NANT% -D:project.config=release clean build
echo.
echo Assuming the build succeeded, your results will be in the build folder.
echo.
goto end

:build-release-package
%NANT% -D:project.config=release clean package
echo.
echo Assuming the build succeeded, your results will be in the build folder.
echo.
goto end

:build-test
%NANT% test
goto end

:end
pause

Build menu batch file to help newcomers with common tasks.

SVN: 488784591515bd4cdaa016be4ec9b172dc4e7caf@5293


@echo off
setlocal enableDelayedExpansion

REM Setup initial vars
set "script_name="
set "thisDir=%~dp0"
set /a tried=0
set "toask=yes"
set "pause_on_error=yes"
set "py2v="
set "py2path="
set "py3v="
set "py3path="
set "pypath="

REM use_py3:
REM   TRUE  = Use if found, use py2 otherwise
REM   FALSE = Use py2
REM   FORCE = Use py3
set "use_py3=TRUE"

REM Get the system32 (or equivalent) path
call :setcomspec
set "syspath=%ComSpec:cmd.exe=%"

goto checkscript

:checkscript
REM Check for our script first
set "looking_for=!script_name!"
if "!script_name!" == "" (
    set "looking_for=%~n0.py or %~n0.command"
    set "script_name=%~n0.py"
    if not exist "!thisDir!\!script_name!" (
        set "script_name=%~n0.command"
    )
)
if not exist "!thisDir!\!script_name!" (
    echo Could not find !looking_for!.
    echo Please make sure to run this script from the same directory
    echo as !looking_for!.
    echo.
    echo Press [enter] to quit.
    pause > nul
    exit /b
)
goto checkpy

:setcomspec
REM Helper method to return the "proper" path to cmd.exe, reg.exe, and where.exe by walking the ComSpec var
REM Prep the LF variable to use the "line feed" approach
(SET LF=^
%=this line is empty=%
)
REM Strip double semi-colons
call :undouble "ComSpec" ";"
set "testpath=%ComSpec:;=!LF!%"
REM Let's walk each path and test if cmd.exe, reg.exe, and where.exe exist there
set /a found=0
for /f "tokens=* delims=" %%i in ("!testpath!") do (
    REM Only continue if we haven't found it yet
    if NOT "%%i" == "" (
        if !found! lss 1 (
            set "temppath=%%i"
            REM Remove "cmd.exe" from the end if it exists
            if /i "!temppath:~-7!" == "cmd.exe" (
                set "temppath=!temppath:~0,-7!"
            )
            REM Pad the end with a backslash if needed
            if NOT "!temppath:~-1!" == "\" (
                set "temppath=!temppath!\"
            )
            REM Let's see if cmd, reg, and where exist there - and set it if so
            if EXIST "!temppath!cmd.exe" (
                if EXIST "!temppath!reg.exe" (
                    if EXIST "!temppath!where.exe" (
                        set /a found=1
                        set "ComSpec=!temppath!cmd.exe"
                    )
                )
            )
        )
    )
)
goto :EOF

:updatepath
set "spath="
set "upath="
for /f "USEBACKQ tokens=2* delims= " %%i in (`!syspath!reg.exe query "HKCU\Environment" /v "Path" 2^> nul`) do ( if not "%%j" == "" set "upath=%%j" )
for /f "USEBACKQ tokens=2* delims= " %%i in (`!syspath!reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "Path" 2^> nul`) do ( if not "%%j" == "" set "spath=%%j" )
if not "%spath%" == "" (
    REM We got something in the system path
    set "PATH=%spath%"
    if not "!upath!" == "" (
        REM We also have something in the user path
        set "PATH=%PATH%;%upath%"
    )
) else if not "%upath%" == "" (
    set "PATH=%upath%"
)
REM Remove double semicolons from the adjusted PATH
call :undouble "PATH" ";"
goto :EOF

:undouble <string_name> <character>
REM Helper function to strip doubles of a single character out of a string recursively
set "string_name=%~1"
set "character=%~2"
set "check=!%string_name%:%character%%character%=%character%!"
if not "!check!" == "!%~1!" (
    set "!string_name!=!check!"
    call :undouble "%~1" "%~2"
)
goto :EOF

:checkpy
call :updatepath
for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe python 2^> nul`) do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" )
for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe python3 2^> nul`) do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" )
for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe py 2^> nul`) do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" )
set "targetpy=3"
if /i "!use_py3!" == "FALSE" (
    set "targetpy=2"
    set "pypath=!py2path!"
) else if /i "!use_py3!" == "FORCE" (
    set "pypath=!py3path!"
) else if /i "!use_py3!" == "TRUE" (
    set "pypath=!py3path!"
    if "!pypath!" == "" set "pypath=!py2path!"
)
if not "!pypath!" == "" (
    goto runscript
)

if "!pypath!" == "" (
    if %tried% lss 1 (
        if /i "!toask!"=="yes" (
            REM Better ask permission first
            goto askinstall
        ) else (
            goto installpy
        )
    ) else (
        cls
        echo   ###     ###
        echo  # Warning #
        echo ###     ###
        echo.
        REM Couldn't install for whatever reason - give the error message
        echo Python is not installed or not found in your PATH var.
        echo Please install it from https://www.python.org/downloads/windows/
        echo.
        echo Make sure you check the box labeled:
        echo.
        echo "Add Python X.X to PATH"
        echo.
        echo Where X.X is the py version you're installing.
        echo.
        echo Press [enter] to quit.
        pause > nul
        exit /b
    )
)
goto runscript

:checkpyversion <path> <py2v> <py2path> <py3v> <py3path>
set "version="&for /f "tokens=2* USEBACKQ delims= " %%a in (`"%~1" -V 2^>^&1`) do (
    REM Ensure we have a version number
    call :isnumber "%%a"
    if not "!errorlevel!" == "0" goto :EOF
    set "version=%%a"
)
if not defined version goto :EOF
if "!version:~0,1!" == "2" (
    REM Python 2
    call :comparepyversion "!version!" "!%~2!"
    if "!errorlevel!" == "1" (
        set "%~2=!version!"
        set "%~3=%~1"
    )
) else (
    REM Python 3
    call :comparepyversion "!version!" "!%~4!"
    if "!errorlevel!" == "1" (
        set "%~4=!version!"
        set "%~5=%~1"
    )
)
goto :EOF

:isnumber <check_value>
set "var="&for /f "delims=0123456789." %%i in ("%~1") do set var=%%i
if defined var (exit /b 1)
exit /b 0

:comparepyversion <version1> <version2> <return>
REM Exits with status 0 if equal, 1 if v1 gtr v2, 2 if v1 lss v2
for /f "tokens=1,2,3 delims=." %%a in ("%~1") do (
    set a1=%%a
    set a2=%%b
    set a3=%%c
)
for /f "tokens=1,2,3 delims=." %%a in ("%~2") do (
    set b1=%%a
    set b2=%%b
    set b3=%%c
)
if not defined a1 set a1=0
if not defined a2 set a2=0
if not defined a3 set a3=0
if not defined b1 set b1=0
if not defined b2 set b2=0
if not defined b3 set b3=0
if %a1% gtr %b1% exit /b 1
if %a1% lss %b1% exit /b 2
if %a2% gtr %b2% exit /b 1
if %a2% lss %b2% exit /b 2
if %a3% gtr %b3% exit /b 1
if %a3% lss %b3% exit /b 2
exit /b 0

:askinstall
cls
echo   ###              ###
echo  # Python Not Found #
echo ###              ###
echo.
echo Python !targetpy! was not found on the system or in the PATH var.
echo.
set /p "menu=Would you like to install it now? [y/n]: "
if /i "!menu!"=="y" (
    REM We got the OK - install it
    goto installpy
) else if "!menu!"=="n" (
    REM No OK here...
    set /a tried=%tried%+1
    goto checkpy
)
REM Incorrect answer - go back
goto askinstall

:installpy
REM This will attempt to download and install python
REM First we get the html for the python downloads page for Windows
set /a tried=%tried%+1
cls
echo   ###               ###
echo  # Installing Python #
echo ###               ###
echo.
echo Gathering info from https://www.python.org/downloads/windows/...
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('https://www.python.org/downloads/windows/','%TEMP%\pyurl.txt')"
if not exist "%TEMP%\pyurl.txt" (
    goto checkpy
)

echo Parsing for latest...
pushd "%TEMP%"
:: Version detection code slimmed by LussacZheng (https://github.com/corpnewt/gibMacOS/issues/20)
for /f "tokens=9 delims=< " %%x in ('findstr /i /c:"Latest Python !targetpy! Release" pyurl.txt') do ( set "release=%%x" )
popd

echo Found Python !release! -  Downloading...
REM Let's delete our txt file now - we no longer need it
del "%TEMP%\pyurl.txt"

REM At this point - we should have the version number.
REM We can build the url like so: "https://www.python.org/ftp/python/[version]/python-[version]-amd64.exe"
set "url=https://www.python.org/ftp/python/!release!/python-!release!-amd64.exe"
set "pytype=exe"
if "!targetpy!" == "2" (
    set "url=https://www.python.org/ftp/python/!release!/python-!release!.amd64.msi"
    set "pytype=msi"
)
REM Now we download it with our slick powershell command
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('!url!','%TEMP%\pyinstall.!pytype!')"
REM If it doesn't exist - we bail
if not exist "%TEMP%\pyinstall.!pytype!" (
    goto checkpy
)
REM It should exist at this point - let's run it to install silently
echo Installing...
pushd "%TEMP%"
if /i "!pytype!" == "exe" (
    echo pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
    pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
) else (
    set "foldername=!release:.=!"
    echo msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
    msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
)
popd
echo Installer finished with %ERRORLEVEL% status.
REM Now we should be able to delete the installer and check for py again
del "%TEMP%\pyinstall.!pytype!"
REM If it worked, then we should have python in our PATH
REM this does not get updated right away though - let's try
REM manually updating the local PATH var
call :updatepath
goto checkpy
exit /b

:runscript
REM Python found
cls
set "args=%*"
set "args=!args:"=!"
if "!args!"=="" (
    "!pypath!" "!thisDir!!script_name!"
) else (
    "!pypath!" "!thisDir!!script_name!" %*
)
if /i "!pause_on_error!" == "yes" (
    if not "%ERRORLEVEL%" == "0" (
        echo.
        echo Script exited with error code: %ERRORLEVEL%
        echo.
        echo Press [enter] to exit...
        pause > nul
    )
)
goto :EOF

@echo off
setlocal enableDelayedExpansion

REM Setup initial vars
set "script_name="
set "thisDir=%~dp0"
set /a tried=0
set "toask=yes"
set "pause_on_error=yes"
set "py2v="
set "py2path="
set "py3v="
set "py3path="
set "pypath="

REM use_py3:
REM   TRUE  = Use if found, use py2 otherwise
REM   FALSE = Use py2
REM   FORCE = Use py3
set "use_py3=TRUE"

REM Get the system32 (or equivalent) path
call :setcomspec
set "syspath=%ComSpec:cmd.exe=%"

goto checkscript

:checkscript
REM Check for our script first
set "looking_for=!script_name!"
if "!script_name!" == "" (
    set "looking_for=%~n0.py or %~n0.command"
    set "script_name=%~n0.py"
    if not exist "!thisDir!\!script_name!" (
        set "script_name=%~n0.command"
    )
)
if not exist "!thisDir!\!script_name!" (
    echo Could not find !looking_for!.
    echo Please make sure to run this script from the same directory
    echo as !looking_for!.
    echo.
    echo Press [enter] to quit.
    pause > nul
    exit /b
)
goto checkpy

:setcomspec
REM Helper method to return the "proper" path to cmd.exe, reg.exe, and where.exe by walking the ComSpec var
REM Prep the LF variable to use the "line feed" approach
(SET LF=^
%=this line is empty=%
)
REM Strip double semi-colons
call :undouble "ComSpec" ";"
set "testpath=%ComSpec:;=!LF!%"
REM Let's walk each path and test if cmd.exe, reg.exe, and where.exe exist there
set /a found=0
for /f "tokens=* delims=" %%i in ("!testpath!") do (
    REM Only continue if we haven't found it yet
    if NOT "%%i" == "" (
        if !found! lss 1 (
            set "temppath=%%i"
            REM Remove "cmd.exe" from the end if it exists
            if /i "!temppath:~-7!" == "cmd.exe" (
                set "temppath=!temppath:~0,-7!"
            )
            REM Pad the end with a backslash if needed
            if NOT "!temppath:~-1!" == "\" (
                set "temppath=!temppath!\"
            )
            REM Let's see if cmd, reg, and where exist there - and set it if so
            if EXIST "!temppath!cmd.exe" (
                if EXIST "!temppath!reg.exe" (
                    if EXIST "!temppath!where.exe" (
                        set /a found=1
                        set "ComSpec=!temppath!cmd.exe"
                    )
                )
            )
        )
    )
)
goto :EOF

:updatepath
set "spath="
set "upath="
for /f "USEBACKQ tokens=2* delims= " %%i in (`!syspath!reg.exe query "HKCU\Environment" /v "Path" 2^> nul`) do ( if not "%%j" == "" set "upath=%%j" )
for /f "USEBACKQ tokens=2* delims= " %%i in (`!syspath!reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "Path" 2^> nul`) do ( if not "%%j" == "" set "spath=%%j" )
if not "%spath%" == "" (
    REM We got something in the system path
    set "PATH=%spath%"
    if not "!upath!" == "" (
        REM We also have something in the user path
        set "PATH=%PATH%;%upath%"
    )
) else if not "%upath%" == "" (
    set "PATH=%upath%"
)
REM Remove double semicolons from the adjusted PATH
call :undouble "PATH" ";"
goto :EOF

:undouble <string_name> <character>
REM Helper function to strip doubles of a single character out of a string recursively
set "string_name=%~1"
set "character=%~2"
set "check=!%string_name%:%character%%character%=%character%!"
if not "!check!" == "!%~1!" (
    set "!string_name!=!check!"
    call :undouble "%~1" "%~2"
)
goto :EOF

:checkpy
call :updatepath
for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe python 2^> nul`) do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" )
for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe python3 2^> nul`) do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" )
for /f "USEBACKQ tokens=*" %%x in (`!syspath!where.exe py 2^> nul`) do ( call :checkpylauncher "%%x" "py2v" "py2path" "py3v" "py3path" )
set "targetpy=3"
if /i "!use_py3!" == "FALSE" (
    set "targetpy=2"
    set "pypath=!py2path!"
) else if /i "!use_py3!" == "FORCE" (
    set "pypath=!py3path!"
) else if /i "!use_py3!" == "TRUE" (
    set "pypath=!py3path!"
    if "!pypath!" == "" set "pypath=!py2path!"
)
if not "!pypath!" == "" (
    goto runscript
)

if "!pypath!" == "" (
    if %tried% lss 1 (
        if /i "!toask!"=="yes" (
            REM Better ask permission first
            goto askinstall
        ) else (
            goto installpy
        )
    ) else (
        cls
        echo   ###     ###
        echo  # Warning #
        echo ###     ###
        echo.
        REM Couldn't install for whatever reason - give the error message
        echo Python is not installed or not found in your PATH var.
        echo Please install it from https://www.python.org/downloads/windows/
        echo.
        echo Make sure you check the box labeled:
        echo.
        echo "Add Python X.X to PATH"
        echo.
        echo Where X.X is the py version you're installing.
        echo.
        echo Press [enter] to quit.
        pause > nul
        exit /b
    )
)
goto runscript

:checkpylauncher <path> <py2v> <py2path> <py3v> <py3path>
REM Attempt to check the latest python 2 and 3 versions via the py launcher
for /f "USEBACKQ tokens=*" %%x in (`%~1 -2 -c "import sys; print(sys.executable)" 2^> nul`) do ( call :checkpyversion "%%x" "%~2" "%~3" "%~4" "%~5" )
for /f "USEBACKQ tokens=*" %%x in (`%~1 -3 -c "import sys; print(sys.executable)" 2^> nul`) do ( call :checkpyversion "%%x" "%~2" "%~3" "%~4" "%~5" )
goto :EOF

:checkpyversion <path> <py2v> <py2path> <py3v> <py3path>
set "version="&for /f "tokens=2* USEBACKQ delims= " %%a in (`"%~1" -V 2^>^&1`) do (
    REM Ensure we have a version number
    call :isnumber "%%a"
    if not "!errorlevel!" == "0" goto :EOF
    set "version=%%a"
)
if not defined version goto :EOF
if "!version:~0,1!" == "2" (
    REM Python 2
    call :comparepyversion "!version!" "!%~2!"
    if "!errorlevel!" == "1" (
        set "%~2=!version!"
        set "%~3=%~1"
    )
) else (
    REM Python 3
    call :comparepyversion "!version!" "!%~4!"
    if "!errorlevel!" == "1" (
        set "%~4=!version!"
        set "%~5=%~1"
    )
)
goto :EOF

:isnumber <check_value>
set "var="&for /f "delims=0123456789." %%i in ("%~1") do set var=%%i
if defined var (exit /b 1)
exit /b 0

:comparepyversion <version1> <version2> <return>
REM Exits with status 0 if equal, 1 if v1 gtr v2, 2 if v1 lss v2
for /f "tokens=1,2,3 delims=." %%a in ("%~1") do (
    set a1=%%a
    set a2=%%b
    set a3=%%c
)
for /f "tokens=1,2,3 delims=." %%a in ("%~2") do (
    set b1=%%a
    set b2=%%b
    set b3=%%c
)
if not defined a1 set a1=0
if not defined a2 set a2=0
if not defined a3 set a3=0
if not defined b1 set b1=0
if not defined b2 set b2=0
if not defined b3 set b3=0
if %a1% gtr %b1% exit /b 1
if %a1% lss %b1% exit /b 2
if %a2% gtr %b2% exit /b 1
if %a2% lss %b2% exit /b 2
if %a3% gtr %b3% exit /b 1
if %a3% lss %b3% exit /b 2
exit /b 0

:askinstall
cls
echo   ###              ###
echo  # Python Not Found #
echo ###              ###
echo.
echo Python !targetpy! was not found on the system or in the PATH var.
echo.
set /p "menu=Would you like to install it now? [y/n]: "
if /i "!menu!"=="y" (
    REM We got the OK - install it
    goto installpy
) else if "!menu!"=="n" (
    REM No OK here...
    set /a tried=%tried%+1
    goto checkpy
)
REM Incorrect answer - go back
goto askinstall

:installpy
REM This will attempt to download and install python
REM First we get the html for the python downloads page for Windows
set /a tried=%tried%+1
cls
echo   ###               ###
echo  # Installing Python #
echo ###               ###
echo.
echo Gathering info from https://www.python.org/downloads/windows/...
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('https://www.python.org/downloads/windows/','%TEMP%\pyurl.txt')"
if not exist "%TEMP%\pyurl.txt" (
    goto checkpy
)

echo Parsing for latest...
pushd "%TEMP%"
:: Version detection code slimmed by LussacZheng (https://github.com/corpnewt/gibMacOS/issues/20)
for /f "tokens=9 delims=< " %%x in ('findstr /i /c:"Latest Python !targetpy! Release" pyurl.txt') do ( set "release=%%x" )
popd

echo Found Python !release! -  Downloading...
REM Let's delete our txt file now - we no longer need it
del "%TEMP%\pyurl.txt"

REM At this point - we should have the version number.
REM We can build the url like so: "https://www.python.org/ftp/python/[version]/python-[version]-amd64.exe"
set "url=https://www.python.org/ftp/python/!release!/python-!release!-amd64.exe"
set "pytype=exe"
if "!targetpy!" == "2" (
    set "url=https://www.python.org/ftp/python/!release!/python-!release!.amd64.msi"
    set "pytype=msi"
)
REM Now we download it with our slick powershell command
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('!url!','%TEMP%\pyinstall.!pytype!')"
REM If it doesn't exist - we bail
if not exist "%TEMP%\pyinstall.!pytype!" (
    goto checkpy
)
REM It should exist at this point - let's run it to install silently
echo Installing...
pushd "%TEMP%"
if /i "!pytype!" == "exe" (
    echo pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
    pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
) else (
    set "foldername=!release:.=!"
    echo msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
    msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
)
popd
echo Installer finished with %ERRORLEVEL% status.
REM Now we should be able to delete the installer and check for py again
del "%TEMP%\pyinstall.!pytype!"
REM If it worked, then we should have python in our PATH
REM this does not get updated right away though - let's try
REM manually updating the local PATH var
call :updatepath
goto checkpy
exit /b

:runscript
REM Python found
cls
set "args=%*"
set "args=!args:"=!"
if "!args!"=="" (
    "!pypath!" "!thisDir!!script_name!"
) else (
    "!pypath!" "!thisDir!!script_name!" %*
)
if /i "!pause_on_error!" == "yes" (
    if not "%ERRORLEVEL%" == "0" (
        echo.
        echo Script exited with error code: %ERRORLEVEL%
        echo.
        echo Press [enter] to exit...
        pause > nul
    )
)
goto :EOF

Add support for py launcher

Add support for py launcher


"%PYTHON%" setup.py bdist_wheel --universal
"%PYTHON%" -m wheel install dist/*

if errorlevel 1 exit 1

"%PYTHON%" setup.py bdist_wheel --universal
"%PYTHON%" -m wheel install dist\*

if errorlevel 1 exit 1

fix win

fix win


@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET UPSTREAMURL=https://github.com/ShiftMediaProject
SET DEPENDENCIES=( ^
libgcrypt ^
)

REM Get passed in list of dependencies to skip
SET PASSDEPENDENCIES=%~1

REM Check if git is installed and available
IF "%MSVC_VER%"=="" (
    git status >NUL 2>&1
    IF %ERRORLEVEL% NEQ 0 (
      ECHO A working copy of git was not found. To use this script you must first install git for windows.
      EXIT /B 1
    )
)

REM Store current directory and ensure working directory is the location of current .bat
SET CURRDIR=%CD%
cd %~dp0

cd ..\..
FOR %%I IN %DEPENDENCIES% DO (
    ECHO !PASSDEPENDENCIES! | FINDSTR /C:"%%I" >NUL 2>&1 || (
        REM Check if MSVC_VER environment variable is set
        IF "%MSVC_VER%"=="" (
            CALL :cloneOrUpdateRepo "%%I"
        ) ELSE (
            CALL :downloadLibs "%%I"
        )
    )
)
cd %CURRDIR% >NUL
GOTO exit

REM Function to clone or update a repo
REM  cloneOrUpdateRepo: RepoName
REM    RepoName = Name of the repository
:cloneOrUpdateRepo
SET REPONAME=%~1
REM Check if the repo folder already exists
IF EXIST "%REPONAME%" (
    ECHO %REPONAME%: Existing folder found. Checking for updates...
    cd %REPONAME%
    REM Check if any updates are available
    FOR /f %%J IN ('git rev-parse HEAD') do set CURRHEAD=%%J
    FOR /f %%J IN ('git ls-remote origin HEAD') do set ORIGHEAD=%%J
    IF "!CURRHEAD!"=="!ORIGHEAD!" (
        ECHO %REPONAME%: Repository up to date.
    ) ELSE (
        REM Stash any uncommited changes then update from origin
        ECHO %REPONAME%: Updates available. Updating repository...
        git checkout master --quiet
        git stash --quiet
        git pull origin master --quiet -ff
        git stash pop --quiet
    )
    cd ..\
) ELSE (
    ECHO %REPONAME%: Existing folder not found. Cloning repository...
    REM Clone from the origin repo
    SET REPOURL=%UPSTREAMURL%/%REPONAME%.git
    git clone !REPOURL! --quiet
    REM Initialise autocrlf options to fix cross platform interoperation
    REM  Once updated the repo needs to be reset to correct the local line endings
    cd %REPONAME%
    git config --local core.autocrlf false
    git rm --cached -r . --quiet
    git reset --hard --quiet
    cd ..\
)
REM Add current repo to list of already passed dependencies
SET PASSDEPENDENCIES=%PASSDEPENDENCIES% %REPONAME%
REM Check if the repo itself has required dependencies
IF EXIST "%REPONAME%\SMP\project_get_dependencies.bat" (
    ECHO %REPONAME%: Found additional dependencies...
    ECHO.
    cd %REPONAME%\SMP
    project_get_dependencies.bat "!PASSDEPENDENCIES!" || GOTO exitOnError
    cd ..\..
)
ECHO.
EXIT /B %ERRORLEVEL%

REM Function to download existing prebuilt libraries
REM  downloadLibs: RepoName
REM    RepoName = Name of the repository
:downloadLibs
SET REPONAME=%~1
REM Get latest release
SET UPSTREAMAPIURL=%UPSTREAMURL:github.com=api.github.com/repos%
powershell -nologo -noprofile -command "try { Invoke-RestMethod -Uri %UPSTREAMAPIURL%/%REPONAME%/releases/latest > latest.json } catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed getting latest %REPONAME% release & GOTO exitOnError )
REM Get tag for latest release
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR /B "tag_name"`) DO SET TAG=%%F
FOR /F "tokens=2 delims=: " %%F in ("%TAG%") DO SET TAG=%%F
IF "%TAG%"=="" ( ECHO Failed getting latest %REPONAME% release tag information & GOTO exitOnError )
REM Get download name of latest release
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR "name="`) DO SET LIBNAME=%%F
SET LIBNAME=%LIBNAME:*name=%
FOR /F "tokens=1 delims=_" %%F in ("%LIBNAME:~1%") DO SET LIBNAME=%%F
IF "%LIBNAME%"=="" ( ECHO Failed getting latest %REPONAME% release name information & GOTO exitOnError )
DEL /F /Q latest.json
REM Get the download location for the required tag
SET DLURL=%UPSTREAMURL%/%REPONAME%/releases/download/%TAG%/%LIBNAME%_%TAG%_msvc%MSVC_VER%.zip
REM Download a pre-built archive and extract
SET PREBUILTDIR=prebuilt
MKDIR %PREBUILTDIR% >NUL 2>&1
powershell -nologo -noprofile -command "try { (New-Object Net.WebClient).DownloadFile('%DLURL%', '%PREBUILTDIR%\temp.zip') } catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed downloading %DLURL% & GOTO exitOnError )
powershell -nologo -noprofile -command "try { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('%PREBUILTDIR%\temp.zip', '%PREBUILTDIR%'); } catch [System.IO.IOException] {exit 0} catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed extracting downloaded archive & GOTO exitOnError )
DEL /F /Q %PREBUILTDIR%\\temp.zip
EXIT /B %ERRORLEVEL%

:exitOnError
cd %CURRDIR%

:exit
REM Directly exit if an AppVeyor build
IF NOT "%APPVEYOR%"=="" (
    GOTO return
)
REM Return the passed dependency list
(
    ENDLOCAL
    SET PASSDEPENDENCIES=%PASSDEPENDENCIES%
)

REM Check if this was launched from an existing terminal or directly from .bat
REM  If launched by executing the .bat then pause on completion
ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
IF %ERRORLEVEL% == 0 IF "%~1"=="" PAUSE

:return
EXIT /B 0

@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET UPSTREAMURL=https://github.com/ShiftMediaProject
SET DEPENDENCIES=( ^
libgcrypt ^
)

REM Get passed in list of dependencies to skip
SET PASSDEPENDENCIES=%~1

REM Check if git is installed and available
IF "%MSVC_VER%"=="" (
    git status >NUL 2>&1
    IF %ERRORLEVEL% NEQ 0 (
      ECHO A working copy of git was not found. To use this script you must first install git for windows.
      EXIT /B 1
    )
)

REM Store current directory and ensure working directory is the location of current .bat
SET CURRDIR=%CD%
cd %~dp0

cd ..\..
FOR %%I IN %DEPENDENCIES% DO (
    ECHO !PASSDEPENDENCIES! | FINDSTR /C:"%%I" >NUL 2>&1 || (
        REM Check if MSVC_VER environment variable is set
        IF "%MSVC_VER%"=="" (
            CALL :cloneOrUpdateRepo "%%I"
        ) ELSE (
            CALL :downloadLibs "%%I"
        )
    )
)
cd %CURRDIR% >NUL
GOTO exit

REM Function to clone or update a repo
REM  cloneOrUpdateRepo: RepoName
REM    RepoName = Name of the repository
:cloneOrUpdateRepo
SET REPONAME=%~1
REM Check if the repo folder already exists
IF EXIST "%REPONAME%" (
    ECHO %REPONAME%: Existing folder found. Checking for updates...
    cd %REPONAME%
    REM Check if any updates are available
    FOR /f %%J IN ('git rev-parse HEAD') do set CURRHEAD=%%J
    FOR /f %%J IN ('git ls-remote origin HEAD') do set ORIGHEAD=%%J
    IF "!CURRHEAD!"=="!ORIGHEAD!" (
        ECHO %REPONAME%: Repository up to date.
    ) ELSE (
        REM Stash any uncommited changes then update from origin
        ECHO %REPONAME%: Updates available. Updating repository...
        git checkout master --quiet
        git stash --quiet
        git pull origin master --quiet -ff
        git stash pop --quiet
    )
    cd ..\
) ELSE (
    ECHO %REPONAME%: Existing folder not found. Cloning repository...
    REM Clone from the origin repo
    SET REPOURL=%UPSTREAMURL%/%REPONAME%.git
    git clone !REPOURL! --quiet
    REM Initialise autocrlf options to fix cross platform interoperation
    REM  Once updated the repo needs to be reset to correct the local line endings
    cd %REPONAME%
    git config --local core.autocrlf false
    git rm --cached -r . --quiet
    git reset --hard --quiet
    cd ..\
)
REM Add current repo to list of already passed dependencies
SET PASSDEPENDENCIES=%PASSDEPENDENCIES% %REPONAME%
REM Check if the repo itself has required dependencies
IF EXIST "%REPONAME%\SMP\project_get_dependencies.bat" (
    ECHO %REPONAME%: Found additional dependencies...
    ECHO.
    cd %REPONAME%\SMP
    project_get_dependencies.bat "!PASSDEPENDENCIES!" || GOTO exitOnError
    cd ..\..
)
ECHO.
EXIT /B %ERRORLEVEL%

REM Function to download existing prebuilt libraries
REM  downloadLibs: RepoName
REM    RepoName = Name of the repository
:downloadLibs
SET REPONAME=%~1
REM Get latest release
ECHO %REPONAME%: Getting latest release...
SET UPSTREAMAPIURL=%UPSTREAMURL:github.com=api.github.com/repos%
powershell -nologo -noprofile -command "try { Invoke-RestMethod -Uri %UPSTREAMAPIURL%/%REPONAME%/releases/latest > latest.json } catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed getting latest %REPONAME% release & GOTO exitOnError )
REM Get tag for latest release
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR /B "tag_name"`) DO SET TAG=%%F
FOR /F "tokens=2 delims=: " %%F in ("%TAG%") DO SET TAG=%%F
IF "%TAG%"=="" ( ECHO Failed getting latest %REPONAME% release tag information & GOTO exitOnError )
REM Get download name of latest release
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR "name="`) DO SET LIBNAME=%%F
SET LIBNAME=%LIBNAME:*name=%
FOR /F "tokens=1 delims=_" %%F in ("%LIBNAME:~1%") DO SET LIBNAME=%%F
IF "%LIBNAME%"=="" ( ECHO Failed getting latest %REPONAME% release name information & GOTO exitOnError )
DEL /F /Q latest.json
REM Get the download location for the required tag
SET TAG2=%TAG:+=.%
SET DLURL=%UPSTREAMURL%/%REPONAME%/releases/download/%TAG%/%LIBNAME%_%TAG2%_msvc%MSVC_VER%.zip
REM Download a pre-built archive and extract
ECHO %REPONAME%: Downloading %LIBNAME%_%TAG%_msvc%MSVC_VER%.zip...
SET PREBUILTDIR=prebuilt
MKDIR %PREBUILTDIR% >NUL 2>&1
powershell -nologo -noprofile -command "try { (New-Object Net.WebClient).DownloadFile('%DLURL%', '%PREBUILTDIR%\temp.zip') } catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed downloading %DLURL% & GOTO exitOnError )
powershell -nologo -noprofile -command "try { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('%PREBUILTDIR%\temp.zip', '%PREBUILTDIR%'); } catch [System.IO.IOException] {exit 0} catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed extracting downloaded archive & GOTO exitOnError )
DEL /F /Q %PREBUILTDIR%\\temp.zip
ECHO.
EXIT /B %ERRORLEVEL%

:exitOnError
cd %CURRDIR%

:exit
REM Directly exit if an AppVeyor build
IF NOT "%APPVEYOR%"=="" (
    GOTO return
)
REM Return the passed dependency list
(
    ENDLOCAL
    SET PASSDEPENDENCIES=%PASSDEPENDENCIES%
)

REM Check if this was launched from an existing terminal or directly from .bat
REM  If launched by executing the .bat then pause on completion
ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
IF %ERRORLEVEL% == 0 IF "%~1"=="" PAUSE

:return
EXIT /B 0

project: Update get_dependency.bat for appveyor artifact naming.


@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET UPSTREAMURL=https://github.com/ShiftMediaProject
SET DEPENDENCIES=( ^
libgcrypt ^
)

REM Get passed in list of dependencies to skip
SET PASSDEPENDENCIES=%~1

REM Check if git is installed and available
git status >NUL 2>&1
IF %ERRORLEVEL% NEQ 0 (
  ECHO A working copy of git was not found. To use this script you must first install git for windows.
  EXIT /B 1
)

SET CURRDIR=%~dp1

cd ..\..
FOR %%I IN %DEPENDENCIES% DO (
    ECHO !PASSDEPENDENCIES! | FINDSTR /C:"%%I" >NUL 2>&1 || (
        CALL :cloneOrUpdateRepo "%%I" )
)
cd %CURRDIR% >NUL
GOTO exit

REM Function to clone or update a repo
REM  cloneOrUpdateRepo: RepoName
REM    RepoName = Name of the repository
:cloneOrUpdateRepo
SET REPONAME=%~1
REM Check if the repo folder already exists
IF EXIST "%REPONAME%" (
    ECHO %REPONAME%: Existing folder found. Checking for updates...
    cd %REPONAME%
    REM Check if any updates are available
    FOR /f %%J IN ('git rev-parse HEAD') do set CURRHEAD=%%J
    FOR /f %%J IN ('git ls-remote origin HEAD') do set ORIGHEAD=%%J
    IF "!CURRHEAD!"=="!ORIGHEAD!" (
        ECHO %REPONAME%: Repository up to date.
    ) ELSE (
        REM Stash any uncommited changes then update from origin
        ECHO %REPONAME%: Updates available. Updating repository...
        git checkout master --quiet
        git stash --quiet
        git pull origin master --quiet -ff
        git stash pop --quiet
    )
    cd ..\
) ELSE (
    ECHO %REPONAME%: Existing folder not found. Cloning repository...
    REM Clone from the origin repo
    SET REPOURL=%UPSTREAMURL%/%REPONAME%.git
    git clone !REPOURL! --quiet
    REM Initialise autocrlf options to fix cross platform interoperation
    REM  Once updated the repo needs to be reset to correct the local line endings
    cd %REPONAME%
    git config --local core.autocrlf false
    git rm --cached -r . --quiet
    git reset --hard --quiet
    cd ..\
)
REM Add current repo to list of already passed dependencies
SET PASSDEPENDENCIES=%PASSDEPENDENCIES% %REPONAME%
REM Check if the repo itself has required dependencies
IF EXIST "%REPONAME%\SMP\project_get_dependencies.bat" (
    ECHO %REPONAME%: Found additional dependencies...
    ECHO.
    cd %REPONAME%\SMP
    project_get_dependencies.bat "!PASSDEPENDENCIES!" || GOTO exitOnError
    cd ..\..
)
ECHO.
EXIT /B %ERRORLEVEL%

:exitOnError
cd %CURRDIR%

:exit
REM Return the passed dependency list
(
    ENDLOCAL
    SET PASSDEPENDENCIES=%PASSDEPENDENCIES%
)

REM Check if this was laucnhed from an existing terminal or directly from .bat
REM  If launched by executing the .bat then pause on completion
ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
IF %ERRORLEVEL% == 0 IF "%~1"=="" PAUSE

EXIT /B 0

@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET UPSTREAMURL=https://github.com/ShiftMediaProject
SET DEPENDENCIES=( ^
libgcrypt ^
)

REM Get passed in list of dependencies to skip
SET PASSDEPENDENCIES=%~1

REM Check if git is installed and available
IF "%MSVC_VER%"=="" (
    git status >NUL 2>&1
    IF %ERRORLEVEL% NEQ 0 (
      ECHO A working copy of git was not found. To use this script you must first install git for windows.
      EXIT /B 1
    )
)

REM Store current directory and ensure working directory is the location of current .bat
SET CURRDIR=%CD%
cd %~dp0

cd ..\..
FOR %%I IN %DEPENDENCIES% DO (
    ECHO !PASSDEPENDENCIES! | FINDSTR /C:"%%I" >NUL 2>&1 || (
        REM Check if MSVC_VER environment variable is set
        IF "%MSVC_VER%"=="" (
            CALL :cloneOrUpdateRepo "%%I"
        ) ELSE (
            CALL :downloadLibs "%%I"
        )
    )
)
cd %CURRDIR% >NUL
GOTO exit

REM Function to clone or update a repo
REM  cloneOrUpdateRepo: RepoName
REM    RepoName = Name of the repository
:cloneOrUpdateRepo
SET REPONAME=%~1
REM Check if the repo folder already exists
IF EXIST "%REPONAME%" (
    ECHO %REPONAME%: Existing folder found. Checking for updates...
    cd %REPONAME%
    REM Check if any updates are available
    FOR /f %%J IN ('git rev-parse HEAD') do set CURRHEAD=%%J
    FOR /f %%J IN ('git ls-remote origin HEAD') do set ORIGHEAD=%%J
    IF "!CURRHEAD!"=="!ORIGHEAD!" (
        ECHO %REPONAME%: Repository up to date.
    ) ELSE (
        REM Stash any uncommited changes then update from origin
        ECHO %REPONAME%: Updates available. Updating repository...
        git checkout master --quiet
        git stash --quiet
        git pull origin master --quiet -ff
        git stash pop --quiet
    )
    cd ..\
) ELSE (
    ECHO %REPONAME%: Existing folder not found. Cloning repository...
    REM Clone from the origin repo
    SET REPOURL=%UPSTREAMURL%/%REPONAME%.git
    git clone !REPOURL! --quiet
    REM Initialise autocrlf options to fix cross platform interoperation
    REM  Once updated the repo needs to be reset to correct the local line endings
    cd %REPONAME%
    git config --local core.autocrlf false
    git rm --cached -r . --quiet
    git reset --hard --quiet
    cd ..\
)
REM Add current repo to list of already passed dependencies
SET PASSDEPENDENCIES=%PASSDEPENDENCIES% %REPONAME%
REM Check if the repo itself has required dependencies
IF EXIST "%REPONAME%\SMP\project_get_dependencies.bat" (
    ECHO %REPONAME%: Found additional dependencies...
    ECHO.
    cd %REPONAME%\SMP
    project_get_dependencies.bat "!PASSDEPENDENCIES!" || GOTO exitOnError
    cd ..\..
)
ECHO.
EXIT /B %ERRORLEVEL%

REM Function to download existing prebuilt libraries
REM  downloadLibs: RepoName
REM    RepoName = Name of the repository
:downloadLibs
SET REPONAME=%~1
REM Get latest release
SET UPSTREAMAPIURL=%UPSTREAMURL:github.com=api.github.com/repos%
powershell -nologo -noprofile -command "try { Invoke-RestMethod -Uri %UPSTREAMAPIURL%/%REPONAME%/releases/latest > latest.json } catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed getting latest %REPONAME% release & GOTO exitOnError )
REM Get tag for latest release
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR /B "tag_name"`) DO SET TAG=%%F
FOR /F "tokens=2 delims=: " %%F in ("%TAG%") DO SET TAG=%%F
IF "%TAG%"=="" ( ECHO Failed getting latest %REPONAME% release tag information & GOTO exitOnError )
REM Get download name of latest release
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR "name="`) DO SET LIBNAME=%%F
SET LIBNAME=%LIBNAME:*name=%
FOR /F "tokens=1 delims=_" %%F in ("%LIBNAME:~1%") DO SET LIBNAME=%%F
IF "%LIBNAME%"=="" ( ECHO Failed getting latest %REPONAME% release name information & GOTO exitOnError )
DEL /F /Q latest.json
REM Get the download location for the required tag
SET DLURL=%UPSTREAMURL%/%REPONAME%/releases/download/%TAG%/%LIBNAME%_%TAG%_msvc%MSVC_VER%.zip
REM Download a pre-built archive and extract
SET PREBUILTDIR=prebuilt
MKDIR %PREBUILTDIR% >NUL 2>&1
powershell -nologo -noprofile -command "try { (New-Object Net.WebClient).DownloadFile('%DLURL%', '%PREBUILTDIR%\temp.zip') } catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed downloading %DLURL% & GOTO exitOnError )
powershell -nologo -noprofile -command "try { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('%PREBUILTDIR%\temp.zip', '%PREBUILTDIR%'); } catch [System.IO.IOException] {exit 0} catch {exit 1}"
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed extracting downloaded archive & GOTO exitOnError )
DEL /F /Q %PREBUILTDIR%\\temp.zip
EXIT /B %ERRORLEVEL%

:exitOnError
cd %CURRDIR%

:exit
REM Directly exit if an AppVeyor build
IF NOT "%APPVEYOR%"=="" (
    GOTO return
)
REM Return the passed dependency list
(
    ENDLOCAL
    SET PASSDEPENDENCIES=%PASSDEPENDENCIES%
)

REM Check if this was launched from an existing terminal or directly from .bat
REM  If launched by executing the .bat then pause on completion
ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
IF %ERRORLEVEL% == 0 IF "%~1"=="" PAUSE

:return
EXIT /B 0

project: Allow get dependency script to optionally download prebuilt releases.


if not exist "C:\Windows\Temp\7z920-x64.msi" (
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
)
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi

if "%PACKER_BUILDER_TYPE%" equ "vmware-iso" goto :vmware
if "%PACKER_BUILDER_TYPE%" equ "virtualbox-iso" goto :virtualbox
if "%PACKER_BUILDER_TYPE%" equ "parallels-iso" goto :parallels
goto :done

:vmware

if exist "C:\Users\vagrant\windows.iso" (
    move /Y C:\Users\vagrant\windows.iso C:\Windows\Temp
)

if not exist "C:\Windows\Temp\windows.iso" (
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://softwareupdate.vmware.com/cds/vmw-desktop/ws/12.5.2/4638234/windows/packages/tools-windows.tar', 'C:\Windows\Temp\vmware-tools.tar')" <NUL
    cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\vmware-tools.tar -oC:\Windows\Temp"
    FOR /r "C:\Windows\Temp" %%a in (VMware-tools-windows-*.iso) DO REN "%%~a" "windows.iso"
    rd /S /Q "C:\Program Files (x86)\VMWare"
)

cmd /c ""C:\Program Files\7-Zip\7z.exe" x "C:\Windows\Temp\windows.iso" -oC:\Windows\Temp\VMWare"
cmd /c C:\Windows\Temp\VMWare\setup.exe /S /v"/qn REBOOT=R\"

rd /Q "C:\Windows\Temp\vmware-tools.tar"
rd /Q "C:\Windows\Temp\windows.iso"
rd /S /Q "C:\Windows\Temp\VMware"
goto :done

:virtualbox

:: There needs to be Oracle CA (Certificate Authority) certificates installed in order
:: to prevent user intervention popups which will undermine a silent installation.
cmd /c certutil -addstore -f "TrustedPublisher" A:\oracle-cert.cer

if exist "C:\Users\vagrant\VBoxGuestAdditions.iso" (
    move /Y C:\Users\vagrant\VBoxGuestAdditions.iso C:\Windows\Temp
)

if not exist "C:\Windows\Temp\VBoxGuestAdditions.iso" (
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.virtualbox.org/virtualbox/5.1.12/VBoxGuestAdditions_5.1.12.iso', 'C:\Windows\Temp\VBoxGuestAdditions.iso')" <NUL
)

cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox"
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha256-r3.cer
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha256.cer
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha1.cer
cmd /c C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe /S
rd /S /Q "C:\Windows\Temp\virtualbox"
goto :done

:parallels
if exist "C:\Users\vagrant\prl-tools-win.iso" (
	move /Y C:\Users\vagrant\prl-tools-win.iso C:\Windows\Temp
	cmd /C "C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\prl-tools-win.iso -oC:\Windows\Temp\parallels
	cmd /C C:\Windows\Temp\parallels\PTAgent.exe /install_silent
	rd /S /Q "C:\Windows\Temp\parallels"
)

:done
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi

if not exist "C:\Windows\Temp\7z920-x64.msi" (
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
)
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi

if "%PACKER_BUILDER_TYPE%" equ "vmware-iso" goto :vmware
if "%PACKER_BUILDER_TYPE%" equ "virtualbox-iso" goto :virtualbox
if "%PACKER_BUILDER_TYPE%" equ "parallels-iso" goto :parallels
goto :done

:vmware

if exist "C:\Users\vagrant\windows.iso" (
    move /Y C:\Users\vagrant\windows.iso C:\Windows\Temp
)

if not exist "C:\Windows\Temp\windows.iso" (
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://softwareupdate.vmware.com/cds/vmw-desktop/ws/12.5.3/5115892/windows/packages/tools-windows.tar', 'C:\Windows\Temp\vmware-tools.tar')" <NUL
    cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\vmware-tools.tar -oC:\Windows\Temp"
    FOR /r "C:\Windows\Temp" %%a in (VMware-tools-windows-*.iso) DO REN "%%~a" "windows.iso"
    rd /S /Q "C:\Program Files (x86)\VMWare"
)

cmd /c ""C:\Program Files\7-Zip\7z.exe" x "C:\Windows\Temp\windows.iso" -oC:\Windows\Temp\VMWare"
cmd /c C:\Windows\Temp\VMWare\setup.exe /S /v"/qn REBOOT=R\"

rd /Q "C:\Windows\Temp\vmware-tools.tar"
rd /Q "C:\Windows\Temp\windows.iso"
rd /S /Q "C:\Windows\Temp\VMware"
goto :done

:virtualbox

:: There needs to be Oracle CA (Certificate Authority) certificates installed in order
:: to prevent user intervention popups which will undermine a silent installation.
cmd /c certutil -addstore -f "TrustedPublisher" A:\oracle-cert.cer

if exist "C:\Users\vagrant\VBoxGuestAdditions.iso" (
    move /Y C:\Users\vagrant\VBoxGuestAdditions.iso C:\Windows\Temp
)

if not exist "C:\Windows\Temp\VBoxGuestAdditions.iso" (
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.virtualbox.org/virtualbox/5.1.12/VBoxGuestAdditions_5.1.12.iso', 'C:\Windows\Temp\VBoxGuestAdditions.iso')" <NUL
)

cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox"
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha256-r3.cer
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha256.cer
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha1.cer
cmd /c C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe /S
rd /S /Q "C:\Windows\Temp\virtualbox"
goto :done

:parallels
if exist "C:\Users\vagrant\prl-tools-win.iso" (
	move /Y C:\Users\vagrant\prl-tools-win.iso C:\Windows\Temp
	cmd /C "C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\prl-tools-win.iso -oC:\Windows\Temp\parallels
	cmd /C C:\Windows\Temp\parallels\PTAgent.exe /install_silent
	rd /S /Q "C:\Windows\Temp\parallels"
)

:done
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi

Update VMware Tools

Update VMware Tools


@echo off
setlocal
set MAIN_CLASS=com.thaiopensource.relaxng.util.Driver
set JAR_FILE=jing.jar
set JRE_KEY=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment
if not exist "%JAVA_HOME%\bin\java.exe" (
  for /f "tokens=2*" %%u in ('reg query "%JRE_KEY%" /v CurrentVersion') do for /f "tokens=2*" %%i in ('reg query "%JRE_KEY%\%%v" /v JavaHome') do set JAVA_HOME=%%j
) 2>nul
if exist "%JAVA_HOME%\bin\java.exe" goto found_java
echo Could not find a Java Runtime Environment. Download one from <http://java.sun.com/javase/downloads/>.
exit /b 1
:found_java
set JAR_DIR=%~dp0
if exist "%JAR_DIR%%JAR_FILE%" goto found_jar
echo Could not find %JAR_FILE%. Must be in the same directory as %~nx0 (%JAR_DIR%).
exit /b 1
:found_jar
"%JAVA_HOME%\bin\java.exe" -classpath "%JAR_DIR%%JAR_FILE%" %MAIN_CLASS% %*

@echo off
setlocal
set MAIN_CLASS=com.thaiopensource.relaxng.util.Driver
set JAR_FILE=jing.jar
set JAVA_PROBLEM_EXIT_CODE=1
set JRE_KEY=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment
set JAVA_VERSION=unknown
if not exist "%JAVA_HOME%\bin\java.exe" (
  for /f "tokens=2* skip=2" %%u in ('reg query "%JRE_KEY%" /v CurrentVersion') do for /f "tokens=2* skip=2" %%i in ('reg query "%JRE_KEY%\%%v" /v JavaHome') do (
    set JAVA_VERSION=%%v
    set JAVA_HOME=%%j
  )
) 2>nul
if exist "%JAVA_HOME%\bin\java.exe" goto found_java
echo Could not find a Java Runtime Environment. Download one from http://java.sun.com/javase/downloads/.
exit /b %JAVA_PROBLEM_EXIT_CODE%
:found_java
if not x1.4==x%JAVA_VERSION% if not x1.3==x%JAVA_VERSION% goto java_version_ok
echo Version 5.0 or newer of the Java Runtime Environment is required. Download one from http://java.sun.com/javase/downloads/.
exit /b %JAVA_PROBLEM_EXIT_CODE%
:java_version_ok
set JAR_DIR=%~dp0
if exist "%JAR_DIR%%JAR_FILE%" goto found_jar
echo Could not find %JAR_FILE%. Must be in the same directory as %~nx0 (%JAR_DIR%).
exit /b %JAVA_PROBLEM_EXIT_CODE%
:found_jar
"%JAVA_HOME%\bin\java.exe" -classpath "%JAR_DIR%%JAR_FILE%" %MAIN_CLASS% %*

Check for appropriate java version in jing.bat

git-svn-id: ca8e9bb6f3f9b50a093b443c23951d3c25ca0913@2299 369101cc-9a96-11dd-8e58-870c635edf7a


if "%1"=="" goto default_value:
set pythonexe=%1
goto nextn:

:default_value:
if exist c:\Python34_x64 goto py64:
set pythonexe=c:\Python34
goto nextn:

:py64:
set pythonexe=c:\Python34_x64

:nextn:
set path=%path%;%pythonexe%;%pythonexe%\Scripts
ipython3 notebook --notebook-dir=_doc\notebooks

update open_ipython_notebook to accept a custom path


C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat x86
CL /I C:\OpenSSL-Win32\include /INCREMENTAL bmpow.c /MT /link /DLL /OUT:bmpow32.dll /LIBPATH:"C:\OpenSSL-Win32\lib" libeay32.lib ws2_32.lib

Use full path to vcvarsall

Use full path to vcvarsall


@echo off
setlocal
set PATH=%PATH%;%ProgramFiles(x86)%\MSBuild\14.0\Bin\;%WINDIR%\Microsoft.NET\Framework\v4.0.30319

:getopts
if "%1"=="" (goto :default) else (goto :%1)
goto :exit

:default
goto :release

:debug
set _target=Build
set _flavour=Debug
goto :main

:clean-debug
set _target=Clean
set _flavour=Debug
goto :main

:stage-debug
set _target=Stage
set _flavour=Debug
goto :main

:release
set _target=Build
set _flavour=Release
goto :main

:clean-release
set _target=Clean
set _flavour=Release
goto :main

:stage-release
set _target=Stage
set _flavour=Release
goto :main

:package-release
set _target=Package
set _flavour=Release
goto :main

:clean
echo No target 'clean'. Try 'clean-debug' or 'clean-release'.
goto :exit

:stage
echo No target 'stage'. Try 'stage-debug' or 'stage-release'.
goto :exit

:package
echo No target 'package'. Try 'package-release'.
goto :exit

:test
echo No target 'test'. Try 'test-smoke', 'test-ironpython', 'test-cpython', or 'test-all'.
goto :exit

:test-smoke
pushd bin\Release
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net40-release-result.xml
popd
goto :exit

:test-smoke-debug
pushd bin\Debug
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net45-debug-result.xml
popd
pushd bin\v4Debug
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net40-debug-result.xml
popd
goto :exit

:test-ironpython
pushd bin\Release
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net40-release-result.xml
popd
goto :exit

:test-ironpython-debug
pushd bin\Release
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net45-debug-result.xml
popd
pushd bin\v4Debug
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net40-debug-result.xml
popd
goto :exit

:test-cpython
pushd bin\Release
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net40-release-result.xml
popd
goto :exit

:test-cpython-debug
pushd bin\Debug
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net45-debug-result.xml
popd
pushd bin\v4Debug
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net40-debug-result.xml
popd
goto :exit

:test-all
pushd bin\Release
IronPythonTest.exe --labels=All --result:all-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --result:all-net40-release-result.xml
popd
goto :exit

:test-all-debug
pushd bin\Debug
IronPythonTest.exe --labels=All --result:all-net45-debug-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --result:all-net40-debug-result.xml
popd
goto :exit

:test-custom
pushd bin\Release
shift
IronPythonTest.exe --labels=All --result:custom-result.xml %1 %2 %3 %4 %5 %6 %7 %8 %9
popd
goto :exit

:restore
set _target=RestoreReferences
set _flavour=Release
goto :main

:distclean
msbuild /t:DistClean /p:BuildFlavour=Release /verbosity:minimal /nologo /p:Platform="Any CPU"
msbuild /t:DistClean /p:BuildFlavour=Debug /verbosity:minimal /nologo /p:Platform="Any CPU"
goto :main

:ngen
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe install bin\Release\ipy.exe
goto :exit

:main
msbuild Build.proj /t:%_target% /p:BuildFlavour=%_flavour% /verbosity:minimal /nologo /p:Platform="Any CPU"
echo "Copying %_flavour% test dlls"
xcopy /y /q Src\DLR\bin\%_flavour%\*.dll bin\%_flavour%\
echo "Copying v4%_flavour% test dlls"
xcopy /y /q Src\DLR\bin\v4%_flavour%\*.dll bin\v4%_flavour%\
goto :exit

:exit
endlocal

@echo off
setlocal
set PATH=%PATH%;%ProgramFiles(x86)%\MSBuild\14.0\Bin\;%WINDIR%\Microsoft.NET\Framework\v4.0.30319

:getopts
if "%1"=="" (goto :default) else (goto :%1)
goto :exit

:default
goto :release

:debug
set _target=Build
set _flavour=Debug
goto :main

:clean-debug
set _target=Clean
set _flavour=Debug
goto :main

:stage-debug
set _target=Stage
set _flavour=Debug
goto :main

:release
set _target=Build
set _flavour=Release
goto :main

:clean-release
set _target=Clean
set _flavour=Release
goto :main

:stage-release
set _target=Stage
set _flavour=Release
goto :main

:package-release
set _target=Package
set _flavour=Release
goto :main

:clean
echo No target 'clean'. Try 'clean-debug' or 'clean-release'.
goto :exit

:stage
echo No target 'stage'. Try 'stage-debug' or 'stage-release'.
goto :exit

:package
echo No target 'package'. Try 'package-release'.
goto :exit

:test
echo No target 'test'. Try 'test-smoke', 'test-ironpython', 'test-cpython', or 'test-all'.
goto :exit

:test-smoke
pushd bin\Release
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net40-release-result.xml
popd
goto :exit

:test-smoke-debug
pushd bin\Debug
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net45-debug-result.xml
popd
pushd bin\v4Debug
IronPythonTest.exe --labels=All --where:Category==StandardCPython --result:smoke-net40-debug-result.xml
popd
goto :exit

:test-ironpython
pushd bin\Release
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net40-release-result.xml
popd
goto :exit

:test-ironpython-debug
pushd bin\Release
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net45-debug-result.xml
popd
pushd bin\v4Debug
IronPythonTest.exe --labels=All --where:Category==IronPython --result:ironpython-net40-debug-result.xml
popd
goto :exit

:test-cpython
pushd bin\Release
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net40-release-result.xml
popd
goto :exit

:test-cpython-debug
pushd bin\Debug
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net45-debug-result.xml
popd
pushd bin\v4Debug
IronPythonTest.exe --labels=All --where:"Category==StandardCPython || Category==AllCPython" --result:cpython-net40-debug-result.xml
popd
goto :exit

:test-all
pushd bin\Release
IronPythonTest.exe --labels=All --result:all-net45-release-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --result:all-net40-release-result.xml
popd
goto :exit

:test-all-debug
pushd bin\Debug
IronPythonTest.exe --labels=All --result:all-net45-debug-result.xml
popd
pushd bin\v4Release
IronPythonTest.exe --labels=All --result:all-net40-debug-result.xml
popd
goto :exit

:test-custom
pushd bin\Release
shift
IronPythonTest.exe --labels=All --result:custom-result.xml %1 %2 %3 %4 %5 %6 %7 %8 %9
popd
goto :exit

:restore
set _target=RestoreReferences
set _flavour=Release
goto :main

:distclean
msbuild /t:DistClean /p:BuildFlavour=Release /verbosity:minimal /nologo /p:Platform="Any CPU"
msbuild /t:DistClean /p:BuildFlavour=Debug /verbosity:minimal /nologo /p:Platform="Any CPU"
goto :main

:ngen
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe install bin\Release\ipy.exe
goto :exit

:main
msbuild Build.proj /t:%_target% /p:BuildFlavour=%_flavour% /verbosity:minimal /nologo /p:Platform="Any CPU"
if "%_target%" == "Build" (
    echo "Copying %_flavour% test dlls"
    xcopy /y /q Src\DLR\bin\%_flavour%\*.dll bin\%_flavour%\
    echo "Copying v4%_flavour% test dlls"
    xcopy /y /q Src\DLR\bin\v4%_flavour%\*.dll bin\v4%_flavour%\
)
goto :exit

:exit
endlocal

Fix #150

Fix #150


Create start.bat

Create start.bat

Easier for noobs


@echo off
REM /!\ THIS SCRIPT SUPPOSE A FIXED PATH FOR PYTHON /!\
REM Each blocks could be triggered independently (i.e. commenting others)
REM run it as:
REM cmd /c tools\release\build_delivery_win.cmd all

REM make few tools available
set PATH=%PATH%;tools;tools\win
set PRG=%0

REM Print version
make.exe print-OR_TOOLS_VERSION | tee.exe build.log

:: Display help if no argument
if "%1"=="" (
call :PRINT_HELP
exit /B %ERRORLEVEL%
)

if "%1"=="help" (
call :PRINT_HELP
exit /B %ERRORLEVEL%
)

if "%ORTOOLS_TOKEN%"=="" (
echo ORTOOLS_TOKEN: NOT FOUND | tee.exe -a build.log
exit /B 1
)

FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --abbrev-ref HEAD`) DO (SET BRANCH=%%F)
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --verify HEAD`) DO (SET SHA1=%%F)
echo BRANCH: %BRANCH%
echo SHA1: %SHA1%

md export

if "%1"=="java" (
call :BUILD_CXX
call :BUILD_JAVA
exit /B %ERRORLEVEL%
)

if "%1"=="dotnet" (
call :BUILD_CXX
call :BUILD_DOTNET
exit /B %ERRORLEVEL%
)

if "%1"=="python" (
call :BUILD_CXX
call :BUILD_PYTHON
exit /B %ERRORLEVEL%
)

if "%1"=="archive" (
call :BUILD_CXX
call :BUILD_JAVA
call :BUILD_DOTNET
call :BUILD_ARCHIVE
exit /B %ERRORLEVEL%
)

if "%1"=="examples" (
call :BUILD_EXAMPLES
exit /B %ERRORLEVEL%
)

if "%1"=="all" (
call :BUILD_CXX
call :BUILD_JAVA
call :BUILD_DOTNET
call :BUILD_ARCHIVE
call :BUILD_EXAMPLES
call :BUILD_PYTHON
exit /B %ERRORLEVEL%
)

if "%1"=="reset" (
rm.exe -rf export
for %%i in (*.log) DO del %%i
exit /B %ERRORLEVEL%
)

echo unknow target %1
exit /B 1

:PRINT_HELP
echo NAME
echo   %PRG% - Build delivery using the local host system.
echo SYNOPSIS
echo   %PRG% [help] dotnet^|java^|python^|archive^|examples^|all^|reset
echo DESCRIPTION
echo   Build Google OR-Tools deliveries.
echo   You MUST define the following variables before running this script:
echo   * ORTOOLS_TOKEN: secret use to decrypt key to sign dotnet and java package.
echo.
echo OPTIONS
echo   help: show this help text (default)
echo   dotnet: Build dotnet packages
echo   java: Build java packages
echo   python: Build python packages
echo   archive: Build archive
echo   examples: Build examples archives
echo   all: build everything
echo   reset: delete all artifacts and suppress cache file
echo.
echo EXAMPLES
echo   cmd /c %PRG%
exit /B 0

:BUILD_CXX
title Build C++
set HASH=
for /F "tokens=* delims=" %%x in (build_cxx.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo C++ build seems up to date, skipping
exit /B 0
)

REM Check C++
which.exe cmake || exit 1
which.exe cmake | tee.exe -a build.log

REM clean everything
echo clean everything... | tee.exe -a build.log
make.exe clean_third_party || exit 1
make.exe clean || exit 1

REM THIRD PARTY
echo make third_party: ... | tee.exe -a build.log
make.exe third_party WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make third_party: DONE | tee.exe -a build.log

echo make cc: ... | tee.exe -a build.log
make.exe cc WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make cc: DONE | tee.exe -a build.log
REM make.exe test_cc WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
REM echo make test_cc: DONE | tee.exe -a build.log

echo make fz: ... | tee.exe -a build.log
make.exe fz WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make fz: DONE | tee.exe -a build.log

echo %BRANCH% %SHA1%>build_cxx.log
exit /B 0

:BUILD_JAVA
title Build Java
set HASH=
for /F "tokens=* delims=" %%x in (build_java.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Java build seems up to date, skipping
exit /B 0
)

REM Check Java
echo JAVA_HOME: %JAVA_HOME% | tee.exe -a build.log
which.exe java || exit 1
which.exe java | tee.exe -a build.log
which.exe mvn || exit 1
which.exe mvn | tee.exe -a build.log

which.exe gpg || exit 1
which.exe gpg | tee.exe -a build.log
which.exe openssl || exit 1
which.exe openssl | tee.exe -a build.log

REM Install Java GPG
echo Install Java GPG: ... | tee.exe -a build.log
openssl aes-256-cbc -iter 42 -pass pass:%ORTOOLS_TOKEN% -in tools\release\private-key.gpg.enc -out private-key.gpg -d
gpg --batch --import private-key.gpg
del private-key.gpg
mkdir -p %userprofile%/.m2
openssl aes-256-cbc -iter 42 -pass pass:%ORTOOLS_TOKEN% -in tools\release\settings.xml.enc -out %userprofile%/.m2/settings.xml -d
echo Install Java GPG: DONE | tee -a build.log

echo make java: ... | tee.exe -a build.log
make.exe java WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make java: DONE | tee.exe -a build.log
REM make.exe test_java WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
REM echo make test_java: DONE | tee.exe -a build.log

for %%i in (temp_java\ortools-win32-x86-64\target\*.jar*) do copy %%i export\.
for %%i in (temp_java\ortools-java\target\*.jar*) do copy %%i export\.
echo %BRANCH% %SHA1%>build_java.log
exit /B 0

:BUILD_DOTNET
title Build .Net
set HASH=
for /F "tokens=* delims=" %%x in (build_dotnet.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo .Net build seems up to date, skipping
exit /B 0
)

REM Check .Net
which.exe dotnet || exit 1
which.exe dotnet | tee.exe -a build.log

REM Install .Net snk
echo Install .Net snk | tee.exe -a build.log
openssl aes-256-cbc -iter 42 -pass pass:%ORTOOLS_TOKEN% -in tools\release\or-tools.snk.enc -out or-tools.snk -d
set DOTNET_SNK=or-tools.snk

echo make dotnet: ... | tee.exe -a build.log
make.exe dotnet WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make dotnet: DONE | tee.exe -a build.log
REM make.exe test_dotnet WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
REM echo make test_dotnet: DONE | tee.exe -a build.log

for %%i in (packages\*nupkg*) do copy %%i export\.
echo %BRANCH% %SHA1%>build_dotnet.log
exit /B 0

REM Create Archive
:BUILD_ARCHIVE
title Build archives
set HASH=
for /F "tokens=* delims=" %%x in (build_archive.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Archive build seems up to date, skipping
exit /B 0
)

make.exe archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make archive: DONE | tee.exe -a build.log
make.exe test_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make test_archive: DONE | tee.exe -a build.log
make.exe fz_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make fz_archive: DONE | tee.exe -a build.log
make.exe test_fz_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make test_fz_archive: DONE | tee.exe -a build.log

echo %BRANCH% %SHA1%>build_archive.log
exit /B 0

REM Build Examples Archives
:BUILD_EXAMPLES
title Build examples
set HASH=
for /F "tokens=* delims=" %%x in (build_examples.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Examples build seems up to date, skipping
exit /B 0
)

rm.exe -rf temp *.zip || exit 1
echo Build examples archives... | tee.exe -a build.log
echo   C++ examples archive... | tee.exe -a build.log
make.exe cc_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo   Python examples archive... | tee.exe -a build.log
make.exe python_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo   Java examples archive... | tee.exe -a build.log
make.exe java_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo   .Net examples archive... | tee.exe -a build.log
make.exe dotnet_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo DONE | tee.exe -a build.log

echo %BRANCH% %SHA1%>build_examples.log
exit /B 0

REM PYTHON 3.6,3.7,3.8,3.9
:BUILD_PYTHON
title Build Python
set HASH=
for /F "tokens=* delims=" %%x in (build_python.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Python build seems up to date, skipping
exit /B 0
)

for %%v in (6 7 8 9) do (
title Build Python 3.%%v
REM Check Python
which.exe C:\python3%%v-64\python.exe || exit 1
echo C:\python3%%v-64\python.exe: FOUND | tee.exe -a build.log
C:\python3%%v-64\python.exe -m pip install --user absl-py mypy-protobuf

echo Cleaning Python... | tee.exe -a build.log
make.exe clean_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64
echo Cleaning Python...DONE | tee.exe -a build.log

REM make.exe python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
REM echo make python3.%%v: DONE | tee.exe -a build.log
REM make.exe test_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
REM echo make test_python3.%%v: DONE | tee.exe -a build.log
echo Rebuild Python3.%%v pypi archive... | tee.exe -a build.log
make.exe package_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
echo Rebuild Python3.%%v pypi archive...DONE | tee.exe -a build.log
echo Test Python3.%%v pypi archive... | tee.exe -a build.log
make.exe test_package_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
echo Test Python3.%%v pypi archive...DONE | tee.exe -a build.log

set TEMP_DIR=temp_python3%%v
for %%i in (%TEMP_DIR%\ortools\dist\*.whl) do copy %%i export\.
)

echo %BRANCH% %SHA1%>build_python.log
exit /B 0

@echo off
REM /!\ THIS SCRIPT SUPPOSE A FIXED PATH FOR PYTHON /!\
REM Each blocks could be triggered independently (i.e. commenting others)
REM run it as:
REM cmd /c tools\release\build_delivery_win.cmd all

REM make few tools available
set PATH=%PATH%;tools;tools\win
set PRG=%0

REM Print version
make.exe print-OR_TOOLS_VERSION | tee.exe build.log

:: Display help if no argument
if "%1"=="" (
call :PRINT_HELP
exit /B %ERRORLEVEL%
)

if "%1"=="help" (
call :PRINT_HELP
exit /B %ERRORLEVEL%
)

if "%ORTOOLS_TOKEN%"=="" (
echo ORTOOLS_TOKEN: NOT FOUND | tee.exe -a build.log
exit /B 1
)

FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --abbrev-ref HEAD`) DO (SET BRANCH=%%F)
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --verify HEAD`) DO (SET SHA1=%%F)
echo BRANCH: %BRANCH% | tee.exe -a build.log
echo SHA1: %SHA1% | tee.exe -a build.log

md export

if "%1"=="java" (
call :BUILD_CXX
call :BUILD_JAVA
exit /B %ERRORLEVEL%
)

if "%1"=="dotnet" (
call :BUILD_CXX
call :BUILD_DOTNET
exit /B %ERRORLEVEL%
)

if "%1"=="python" (
call :BUILD_CXX
call :BUILD_PYTHON
exit /B %ERRORLEVEL%
)

if "%1"=="archive" (
call :BUILD_CXX
call :BUILD_JAVA
call :BUILD_DOTNET
call :BUILD_ARCHIVE
exit /B %ERRORLEVEL%
)

if "%1"=="examples" (
call :BUILD_EXAMPLES
exit /B %ERRORLEVEL%
)

if "%1"=="all" (
call :BUILD_CXX
call :BUILD_JAVA
call :BUILD_DOTNET
call :BUILD_ARCHIVE
call :BUILD_EXAMPLES
call :BUILD_PYTHON
exit /B %ERRORLEVEL%
)

if "%1"=="reset" (
echo clean everything... | tee.exe -a build.log
make.exe clean || exit 1
make.exe clean_third_party || exit 1
rm.exe -rf export
del or-tools.snk
for %%i in (*.zip) DO del %%i
for %%i in (*.whl) DO del %%i
for %%i in (*.log) DO del %%i
exit /B %ERRORLEVEL%
)

echo unknow target %1
exit /B 1

:PRINT_HELP
echo NAME
echo   %PRG% - Build delivery using the local host system.
echo SYNOPSIS
echo   %PRG% [help] dotnet^|java^|python^|archive^|examples^|all^|reset
echo DESCRIPTION
echo   Build Google OR-Tools deliveries.
echo   You MUST define the following variables before running this script:
echo   * ORTOOLS_TOKEN: secret use to decrypt key to sign dotnet and java package.
echo.
echo OPTIONS
echo   help: show this help text (default)
echo   dotnet: Build dotnet packages
echo   java: Build java packages
echo   python: Build python packages
echo   archive: Build archive
echo   examples: Build examples archives
echo   all: build everything
echo   reset: delete all artifacts and suppress cache file
echo.
echo EXAMPLES
echo   cmd /c %PRG%
exit /B 0

:BUILD_CXX
title Build C++
set HASH=
for /F "tokens=* delims=" %%x in (build_cxx.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo C++ build seems up to date, skipping
exit /B 0
)

REM Check C++
which.exe cmake || exit 1
which.exe cmake | tee.exe -a build.log

REM clean everything
echo clean everything... | tee.exe -a build.log
make.exe clean_third_party || exit 1
make.exe clean || exit 1

REM THIRD PARTY
echo make third_party: ... | tee.exe -a build.log
make.exe third_party WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make third_party: DONE | tee.exe -a build.log

echo make cc: ... | tee.exe -a build.log
make.exe cc WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make cc: DONE | tee.exe -a build.log
REM make.exe test_cc WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
REM echo make test_cc: DONE | tee.exe -a build.log

echo make fz: ... | tee.exe -a build.log
make.exe fz WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make fz: DONE | tee.exe -a build.log

echo %BRANCH% %SHA1%>build_cxx.log
exit /B 0

:BUILD_JAVA
title Build Java
set HASH=
for /F "tokens=* delims=" %%x in (build_java.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Java build seems up to date, skipping
exit /B 0
)

REM Check Java
echo JAVA_HOME: %JAVA_HOME% | tee.exe -a build.log
which.exe java || exit 1
which.exe java | tee.exe -a build.log
which.exe mvn || exit 1
which.exe mvn | tee.exe -a build.log

which.exe gpg || exit 1
which.exe gpg | tee.exe -a build.log
which.exe openssl || exit 1
which.exe openssl | tee.exe -a build.log

REM Install Java GPG
echo Install Java GPG: ... | tee.exe -a build.log
openssl aes-256-cbc -iter 42 -pass pass:%ORTOOLS_TOKEN% -in tools\release\private-key.gpg.enc -out private-key.gpg -d
gpg --batch --import private-key.gpg
del private-key.gpg
mkdir -p %userprofile%/.m2
openssl aes-256-cbc -iter 42 -pass pass:%ORTOOLS_TOKEN% -in tools\release\settings.xml.enc -out %userprofile%/.m2/settings.xml -d
echo Install Java GPG: DONE | tee -a build.log

echo make java: ... | tee.exe -a build.log
make.exe java WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make java: DONE | tee.exe -a build.log
REM make.exe test_java WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
REM echo make test_java: DONE | tee.exe -a build.log

for %%i in (temp_java\ortools-win32-x86-64\target\*.jar*) do copy %%i export\.
for %%i in (temp_java\ortools-java\target\*.jar*) do copy %%i export\.
echo %BRANCH% %SHA1%>build_java.log
exit /B 0

:BUILD_DOTNET
title Build .Net
set HASH=
for /F "tokens=* delims=" %%x in (build_dotnet.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo .Net build seems up to date, skipping
exit /B 0
)

REM Check .Net
which.exe dotnet || exit 1
which.exe dotnet | tee.exe -a build.log

REM Install .Net snk
echo Install .Net snk | tee.exe -a build.log
openssl aes-256-cbc -iter 42 -pass pass:%ORTOOLS_TOKEN% -in tools\release\or-tools.snk.enc -out or-tools.snk -d
set DOTNET_SNK=or-tools.snk

echo make dotnet: ... | tee.exe -a build.log
make.exe dotnet WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make dotnet: DONE | tee.exe -a build.log
REM make.exe test_dotnet WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
REM echo make test_dotnet: DONE | tee.exe -a build.log

for %%i in (packages\*nupkg*) do copy %%i export\.
echo %BRANCH% %SHA1%>build_dotnet.log
exit /B 0

REM Create Archive
:BUILD_ARCHIVE
title Build archives
set HASH=
for /F "tokens=* delims=" %%x in (build_archive.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Archive build seems up to date, skipping
exit /B 0
)

make.exe archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make archive: DONE | tee.exe -a build.log
make.exe test_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make test_archive: DONE | tee.exe -a build.log
make.exe fz_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make fz_archive: DONE | tee.exe -a build.log
make.exe test_fz_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo make test_fz_archive: DONE | tee.exe -a build.log

echo %BRANCH% %SHA1%>build_archive.log
exit /B 0

REM Build Examples Archives
:BUILD_EXAMPLES
title Build examples
set HASH=
for /F "tokens=* delims=" %%x in (build_examples.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Examples build seems up to date, skipping
exit /B 0
)

rm.exe -rf temp *.zip || exit 1
echo Build examples archives... | tee.exe -a build.log
echo   C++ examples archive... | tee.exe -a build.log
make.exe cc_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo   Python examples archive... | tee.exe -a build.log
make.exe python_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo   Java examples archive... | tee.exe -a build.log
make.exe java_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo   .Net examples archive... | tee.exe -a build.log
make.exe dotnet_examples_archive WINDOWS_PATH_TO_PYTHON=c:\python39-64 || exit 1
echo DONE | tee.exe -a build.log

echo %BRANCH% %SHA1%>build_examples.log
exit /B 0

REM PYTHON 3.6,3.7,3.8,3.9
:BUILD_PYTHON
title Build Python
set HASH=
for /F "tokens=* delims=" %%x in (build_python.log) do (set HASH=%%x)
if "%HASH%"=="%BRANCH% %SHA1%" (
echo Python build seems up to date, skipping
exit /B 0
)

for %%v in (6 7 8 9) do (
title Build Python 3.%%v
REM Check Python
which.exe C:\python3%%v-64\python.exe || exit 1
echo C:\python3%%v-64\python.exe: FOUND | tee.exe -a build.log
C:\python3%%v-64\python.exe -m pip install --user absl-py mypy-protobuf

echo Cleaning Python... | tee.exe -a build.log
make.exe clean_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64
echo Cleaning Python...DONE | tee.exe -a build.log

REM make.exe python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
REM echo make python3.%%v: DONE | tee.exe -a build.log
REM make.exe test_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
REM echo make test_python3.%%v: DONE | tee.exe -a build.log
echo Rebuild Python3.%%v pypi archive... | tee.exe -a build.log
make.exe package_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
echo Rebuild Python3.%%v pypi archive...DONE | tee.exe -a build.log
echo Test Python3.%%v pypi archive... | tee.exe -a build.log
make.exe test_package_python WINDOWS_PATH_TO_PYTHON=c:\python3%%v-64 || exit 1
echo Test Python3.%%v pypi archive...DONE | tee.exe -a build.log

set TEMP_DIR=temp_python3%%v
for %%i in (%TEMP_DIR%\ortools\dist\*.whl) do copy %%i export\.
)

echo %BRANCH% %SHA1%>build_python.log
exit /B 0

Fix windows script

release: Fix windows script


..\tools\Build.Tools\Fake\FAKE.exe ..\tools\Build.Tools\YC.SEL.SDK.fsx "user=%1" "password=%2"

Remove parameters from YC.SEL.SDK bat file


call "c:/Program files (x86)/Microsoft Visual Studio 8/VC/vcvarsall.bat"

set JENKINSDIR=%CD%

for /F "delims=/" %%a in (%JOB_NAME%) do set GHBRANCH=%%c

IF "%GHBRANCH:~0,2%"=="PR" ( GOTO PR ) else ( GOTO BUILD )

:PR
	echo Skipping creating installer for pull requests
	GOTO END

:BUILD
set RIDE_BRANCH=master

set CYGWIN_DIR=c:/cygwin
set CYGWIN=nodosfilewarning
%CYGWIN_DIR%/bin/bash.exe --login -c "cd $JENKINSDIR ; packagescripts/windows/make.sh"

:END

set JENKINSDIR=%CD%

for /F "tokens=1,2,3 delims=/" %%a in ("%JOB_NAME%") do set GHBRANCH=%%c

IF "%GHBRANCH:~0,2%"=="PR" ( GOTO PR ) else ( GOTO BUILD )

:PR
	echo Skipping creating installer for pull requests
	GOTO END

:BUILD

call "c:/Program files (x86)/Microsoft Visual Studio 8/VC/vcvarsall.bat"

set RIDE_BRANCH=master

set CYGWIN_DIR=c:/cygwin
set CYGWIN=nodosfilewarning
%CYGWIN_DIR%/bin/bash.exe --login -c "cd $JENKINSDIR ; packagescripts/windows/make.sh"

:END

fix batch to not build installer for a PR


@echo on

:: This configure script is designed for the default Windows world,

:: This configure script expects to be run from the PDAL root directory.

:: Pick your CMake GENERATOR.  (NMake will pick up architecture (x32, x64) from your environment)
set GENERATOR="NMake Makefiles"
REM set GENERATOR="Visual Studio 14 Win64"
rem set GENERATOR="Visual Studio 10"

:: Pick your build type
set BUILD_TYPE=Release
REM set BUILD_TYPE=Debug

if EXIST CMakeCache.txt del CMakeCache.txt

cmake -G %GENERATOR% ^
    -DCMAKE_INSTALL_PREFIX=C:\pdalbin ^
    -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
    -DCMAKE_VERBOSE_MAKEFILE=ON ^
	-DBUILD_SHARED_LIBS=ON ^
    -Dgtest_force_shared_crt=ON ^
    .

add a hobu example invocation for windows