@ECHO off
SETLOCAL EnableExtensions
SETLOCAL EnableDelayedExpansion

:: ### Version History -- X.Y.Z_YYYYMMDD-hhmm Author Description
SET version=1.0.0_20150930-0600 &: Peter Kirschner   downloading,extract,configure and launch eclipse-installer with jre
SET version=%version: =%
SET title=oomphInstaller script %~nx0 - version %version%
TITLE %title%
SET POWERSHELL_TITLE=$Host.UI.RawUI.WindowTitle='%title%'

:: ###########################################################
SET SCRIPTNAME=%~n0
SET SCRIPT_PATH=%~dp0
SET SCRIPT_PATH=%SCRIPT_PATH:~0,-1%

SET OOMPH_NAME=oomphInstaller
SET DOWNLOAD_LOCATION=%SCRIPT_PATH%\download

SET ECLIPSE_INSTALLER_WEB=http://peterkir.github.io/org.eclipse.oomph/peterkir/products
SET ECLIPSE_INSTALLER_ARCHIVE=org.eclipse.oomph.setup.installer.product-win32.win32.x86_64.zip
SET ECLIPSE_INSTALLER=%ECLIPSE_INSTALLER_ARCHIVE:~0,-4%

::SET JAVA_WEB=https://s3-eu-west-1.amazonaws.com/klib.io/www/_archives/java/zipped/1.8
SET JAVA_WEB=http://jazz01.rd.corpintra.net/web/repo/_archives/java/zipped/1.8
SET JAVA_ARCHIVE=win32.x86_64-jre1.8.0_60.zip
SET JAVA=%JAVA_ARCHIVE:~13,-4%

::ECHO.
::ECHO # workaroung for NTLMv2 ProxyAuth - starting IE
::ECHO.
::SET IE_CMD="C:\Program Files (x86)\Internet Explorer\iexplore.exe www.google.de"
::SET IE_DIR="%TEMP%"
::FOR /F "tokens=2 delims=;=" %%a IN (
::	'WMIC process call create %IE_CMD%^, %IE_DIR% ^| find "ProcessId"'
::) DO (
::	SET IE_PID=%%a
::)
::ECHO browser launched with PID %IE_PID%
:: TODO search an kill the IE if not previously open WMIC process %IE_PID% delete

ECHO.
ECHO # downloading and preparing %ECLIPSE_INSTALLER%
ECHO.

:: download of a file with powershell - http://superuser.com/a/423789/344922
MKDIR %SCRIPT_PATH%\download 2>&1 > NUL

ECHO downloading archive %ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%
powershell -nologo -noprofile -command "%POWERSHELL_TITLE%;if ( Test-Path %DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE% ) { Write-Output 'skipping download, cause file exists - %DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE%' } else {(New-Object System.Net.WebClient).DownloadFile('%ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%','%DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE%')}"

ECHO extracting ECLIPSE_INSTALLER archive to %ECLIPSE_INSTALLER%
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path '%SCRIPT_PATH%\%OOMPH_NAME%' -PathType Container )  { Write-Output 'skipping extraction, cause folder exists - %SCRIPT_PATH%\%OOMPH_NAME%' } else {Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('%DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE%', '%SCRIPT_PATH%\%OOMPH_NAME%')}"

ECHO.
ECHO # downloading and configuring %JAVA_ARCHIVE%
ECHO.

ECHO downloading archive %JAVA_WEB%/%JAVA_ARCHIVE%
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path %DOWNLOAD_LOCATION%\%JAVA_ARCHIVE% ) { Write-Output 'skipping download, cause file exists - %DOWNLOAD_LOCATION%\%JAVA_ARCHIVE%' } else {(New-Object System.Net.WebClient).DownloadFile('%JAVA_WEB%/%JAVA_ARCHIVE%','%DOWNLOAD_LOCATION%\%JAVA_ARCHIVE%')}"

ECHO extracting %ECLIPSE_INSTALLER% archive to %ECLIPSE_INSTALLER%/%JAVA%
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path '%SCRIPT_PATH%\%OOMPH_NAME%\jre' -PathType Container )  { Write-Output 'skipping extraction, cause folder exists - %SCRIPT_PATH%\%OOMPH_NAME%\jre' } else {Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('%DOWNLOAD_LOCATION%\%JAVA_ARCHIVE%', '%SCRIPT_PATH%\download');Move-Item %DOWNLOAD_LOCATION%\%JAVA% %SCRIPT_PATH%\%OOMPH_NAME%\jre}"

SET JAVA_HOME=%SCRIPT_PATH%\%OOMPH_NAME%\jre
SET "OOMPH_HOME=%SCRIPT_PATH%\oomph"
SET "P2_HOME=%SCRIPT_PATH%\p2"

MKDIR %OOMPH_HOME% 2>&1 > NUL
SET OOMPH_HOME=%OOMPH_HOME:\=/%
SET OOMPH_INI=%SCRIPT_PATH%\%OOMPH_NAME%\eclipse-inst.ini

ECHO adding vmArgs to ini file

:: custom added parameters
ECHO -Doomph.home=%OOMPH_HOME% >> %OOMPH_INI%
ECHO -Doomph.p2.agent.path=%P2_HOME% >> %OOMPH_INI%

::SET INSTALL_ROOT=%SCRIPT_PATH%\install
::MKDIR %INSTALL_ROOT% 2>&1 > NUL
::SET INSTALL_ROOT=%INSTALL_ROOT:\=/%
::ECHO -Dinstall.root=%INSTALL_ROOT% >> %OOMPH_INI%

::SET WRKSPC_ROOT=%SCRIPT_PATH%\wrkspc
::MKDIR %WRKSPC_ROOT% 2>&1 > NUL
::SET WRKSPC_ROOT=%WRKSPC_ROOT:\=/%
::ECHO -Dworkspace.container.root=%WRKSPC_ROOT% >> %OOMPH_INI%

:: allow installation of unsigned bundles
ECHO -Declipse.p2.unsignedPolicy=allow >> %OOMPH_INI%

:: hidden p2 options (configured to default)
ECHO -Declipse.p2.max.threads=4  >> %OOMPH_INI%
ECHO -Declipse.p2.force.threading=true >> %OOMPH_INI%
ECHO -Declipse.p2.mirrors=true >> %OOMPH_INI%

:: filtering user displayed catalogs/products/versions
ECHO -Doomph.setup.product.catalog.filter=org\\.eclipse\\.applications >> %OOMPH_INI%
ECHO -Doomph.setup.product.filter=none >> %OOMPH_INI%
ECHO -Doomph.setup.product.version.filter=none >> %OOMPH_INI%

ECHO -Doomph.setup.jre.choice=false >> %OOMPH_INI%
ECHO -Doomph.installer.update.url=http://peterkir.github.io/org.eclipse.oomph/peterkir/repo/oomph >> %OOMPH_INI%
ECHO -Doomph.setup.installer.mode=advanced >> %OOMPH_INI%
ECHO -Doomph.redirection.klibProductCatalog=index:/redirectable.products.setup-^>http://peterkir.github.io/idefix/oomph/products/productsCatalog.setup >> %OOMPH_INI%
ECHO -Doomph.redirection.klibProjectCatalog=index:/redirectable.projects.setup-^>http://peterkir.github.io/idefix/oomph/projects/projectsCatalog.setup >> %OOMPH_INI%

ECHO.
ECHO # launching %OOMPH_NAME%
ECHO.
START /B %SCRIPT_PATH%\%OOMPH_NAME%\eclipse-inst.exe

ECHO.
ECHO # clean-up
ECHO.
RMDIR /Q /S %DOWNLOAD_LOCATION%

@ECHO off
SETLOCAL EnableExtensions
SETLOCAL EnableDelayedExpansion

:: ### Version History -- X.Y.Z_YYYYMMDD-hhmm Author Description
SET version=1.0.0_20150930-0600 &: Peter Kirschner   downloading,extract,configure and launch eclipse-installer with jre
SET version=%version: =%
SET title=oomphInstaller script %~nx0 - version %version%
TITLE %title%
SET POWERSHELL_TITLE=$Host.UI.RawUI.WindowTitle='%title%'

:: ###########################################################
SET SCRIPTNAME=%~n0
SET SCRIPT_PATH=%~dp0
SET SCRIPT_PATH=%SCRIPT_PATH:~0,-1%

SET OOMPH_NAME=oomphInstaller
SET DOWNLOAD_LOCATION=%SCRIPT_PATH%\download

SET ECLIPSE_INSTALLER_WEB=http://peterkir.github.io/org.eclipse.oomph/peterkir/products
SET ECLIPSE_INSTALLER_ARCHIVE=org.eclipse.oomph.setup.installer.product-win32.win32.x86_64.zip
SET ECLIPSE_INSTALLER=%ECLIPSE_INSTALLER_ARCHIVE:~0,-4%

::SET JAVA_WEB=https://s3-eu-west-1.amazonaws.com/klib.io/www/_archives/java/zipped/1.8
SET JAVA_WEB=http://jazz01.rd.corpintra.net/web/repo/_archives/java/zipped/1.8
SET JAVA_ARCHIVE=win32.x86_64-jre1.8.0_60.zip
SET JAVA=%JAVA_ARCHIVE:~13,-4%

::ECHO.
::ECHO # workaroung for NTLMv2 ProxyAuth - starting IE
::ECHO.
::SET IE_CMD="C:\Program Files (x86)\Internet Explorer\iexplore.exe www.google.de"
::SET IE_DIR="%TEMP%"
::FOR /F "tokens=2 delims=;=" %%a IN (
::	'WMIC process call create %IE_CMD%^, %IE_DIR% ^| find "ProcessId"'
::) DO (
::	SET IE_PID=%%a
::)
::ECHO browser launched with PID %IE_PID%
:: TODO search an kill the IE if not previously open WMIC process %IE_PID% delete

ECHO.
ECHO # downloading and preparing %ECLIPSE_INSTALLER%
ECHO.

:: download of a file with powershell - http://superuser.com/a/423789/344922
MKDIR %SCRIPT_PATH%\download 2>&1 > NUL

ECHO downloading archive %ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%
powershell -nologo -noprofile -command "%POWERSHELL_TITLE%;if ( Test-Path %DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE% ) { Write-Output 'skipping download, cause file exists - %DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE%' } else {(New-Object System.Net.WebClient).DownloadFile('%ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%','%DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE%')}"

ECHO extracting ECLIPSE_INSTALLER archive to %ECLIPSE_INSTALLER%
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path '%SCRIPT_PATH%\%OOMPH_NAME%' -PathType Container )  { Write-Output 'skipping extraction, cause folder exists - %SCRIPT_PATH%\%OOMPH_NAME%' } else {Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('%DOWNLOAD_LOCATION%\%ECLIPSE_INSTALLER_ARCHIVE%', '%SCRIPT_PATH%\%OOMPH_NAME%')}"

ECHO.
ECHO # downloading and configuring %JAVA_ARCHIVE%
ECHO.

ECHO downloading archive %JAVA_WEB%/%JAVA_ARCHIVE%
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path %DOWNLOAD_LOCATION%\%JAVA_ARCHIVE% ) { Write-Output 'skipping download, cause file exists - %DOWNLOAD_LOCATION%\%JAVA_ARCHIVE%' } else {(New-Object System.Net.WebClient).DownloadFile('%JAVA_WEB%/%JAVA_ARCHIVE%','%DOWNLOAD_LOCATION%\%JAVA_ARCHIVE%')}"

ECHO extracting %ECLIPSE_INSTALLER% archive to %ECLIPSE_INSTALLER%/%JAVA%
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path '%SCRIPT_PATH%\%OOMPH_NAME%\jre' -PathType Container )  { Write-Output 'skipping extraction, cause folder exists - %SCRIPT_PATH%\%OOMPH_NAME%\jre' } else {Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('%DOWNLOAD_LOCATION%\%JAVA_ARCHIVE%', '%SCRIPT_PATH%\download');Move-Item %DOWNLOAD_LOCATION%\%JAVA% %SCRIPT_PATH%\%OOMPH_NAME%\jre}"

SET JAVA_HOME=%SCRIPT_PATH%\%OOMPH_NAME%\jre
SET "OOMPH_HOME=%SCRIPT_PATH%\oomph"
SET "P2_HOME=%SCRIPT_PATH%\p2"

MKDIR %OOMPH_HOME% 2>&1 > NUL
SET OOMPH_HOME=%OOMPH_HOME:\=/%
SET OOMPH_INI=%SCRIPT_PATH%\%OOMPH_NAME%\eclipse-inst.ini

ECHO adding vmArgs to ini file

:: custom added parameters
ECHO -Doomph.home=%OOMPH_HOME% >> %OOMPH_INI%
ECHO -Doomph.p2.agent.path=%P2_HOME% >> %OOMPH_INI%

::SET INSTALL_ROOT=%SCRIPT_PATH%\install
::MKDIR %INSTALL_ROOT% 2>&1 > NUL
::SET INSTALL_ROOT=%INSTALL_ROOT:\=/%
::ECHO -Dinstall.root=%INSTALL_ROOT% >> %OOMPH_INI%

::SET WRKSPC_ROOT=%SCRIPT_PATH%\wrkspc
::MKDIR %WRKSPC_ROOT% 2>&1 > NUL
::SET WRKSPC_ROOT=%WRKSPC_ROOT:\=/%
::ECHO -Dworkspace.container.root=%WRKSPC_ROOT% >> %OOMPH_INI%

:: allow installation of unsigned bundles
ECHO -Declipse.p2.unsignedPolicy=allow >> %OOMPH_INI%

:: hidden p2 options (configured to default)
ECHO -Declipse.p2.max.threads=4  >> %OOMPH_INI%
ECHO -Declipse.p2.force.threading=true >> %OOMPH_INI%
ECHO -Declipse.p2.mirrors=true >> %OOMPH_INI%

:: filtering user displayed catalogs/products/versions
::ECHO -Doomph.setup.product.catalog.filter=org\\.eclipse\\.applications >> %OOMPH_INI%
::ECHO -Doomph.setup.product.filter=none >> %OOMPH_INI%
::ECHO -Doomph.setup.product.version.filter=none >> %OOMPH_INI%

ECHO -Doomph.setup.jre.choice=false >> %OOMPH_INI%
ECHO -Doomph.installer.update.url=http://peterkir.github.io/org.eclipse.oomph/peterkir/repo/oomph >> %OOMPH_INI%
ECHO -Doomph.setup.installer.mode=advanced >> %OOMPH_INI%
ECHO -Doomph.redirection.klibProductCatalog=index:/redirectable.products.setup-^>http://peterkir.github.io/idefix/oomph/products/productsCatalog.setup >> %OOMPH_INI%
ECHO -Doomph.redirection.klibProjectCatalog=index:/redirectable.projects.setup-^>http://peterkir.github.io/idefix/oomph/projects/projectsCatalog.setup >> %OOMPH_INI%

ECHO.
ECHO # launching %OOMPH_NAME%
ECHO.
START /B %SCRIPT_PATH%\%OOMPH_NAME%\eclipse-inst.exe

ECHO.
ECHO # clean-up
ECHO.
RMDIR /Q /S %DOWNLOAD_LOCATION%

restructure products and projects

restructure products and projects


@ECHO OFF

REM This script builds and signs the Windows packages on Gitlab

ECHO "Start Time"
TIME /T

REM List currently used cygwin and target folders for debugging / maintenance purposes

ECHO "Currently used cygwin folders"
DIR C:\ci\cygwin*
ECHO "Currently used target folders"
DIR C:\ci\coq*
ECHO "Root folders"
DIR C:\

if %ARCH% == 32 (
  SET ARCHLONG=i686
  SET SETUP=setup-x86.exe
)

if %ARCH% == 64 (
  SET ARCHLONG=x86_64
  SET SETUP=setup-x86_64.exe
)

SET CYGROOT=C:\ci\cygwin%ARCH%
SET DESTCOQ=C:\ci\coq%ARCH%

CALL :MakeUniqueFolder %CYGROOT% CYGROOT
CALL :MakeUniqueFolder %DESTCOQ% DESTCOQ

powershell -Command "(New-Object Net.WebClient).DownloadFile('http://www.cygwin.com/%SETUP%', '%SETUP%')"
SET CYGCACHE=%CYGROOT%\var\cache\setup
SET CI_PROJECT_DIR_MFMT=%CI_PROJECT_DIR:\=/%
SET CI_PROJECT_DIR_CFMT=%CI_PROJECT_DIR_MFMT:C:/=/cygdrive/c/%
SET COQREGTESTING=Y
SET PATH=%PATH%;C:\Program Files\7-Zip\;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin

if exist %CYGROOT%\build\ rd /s /q %CYGROOT%\build
if exist %DESTCOQ%\ rd /s /q %DESTCOQ%

IF "%WINDOWS_ALL_ADDONS%" == "enabled" (
  SET EXTRA_ADDONS=^
    -addon=mathcomp ^
    -addon=menhir ^
    -addon=menhirlib ^
    -addon=compcert ^
    -addon=extlib ^
    -addon=quickchick ^
    -addon=coquelicot
  REM addons with build issues
  REM -addon=vst ^
  REM -addon=aactactics ^
) ELSE (
  SET "EXTRA_ADDONS= "
)

call %CI_PROJECT_DIR%\dev\build\windows\MakeCoq_MinGW.bat -threads=1 ^
  -arch=%ARCH% -installer=Y -coqver=%CI_PROJECT_DIR_CFMT% ^
  -destcyg=%CYGROOT% -destcoq=%DESTCOQ% -cygcache=%CYGCACHE% ^
  -addon=bignums ^
  -addon=equations ^
  -addon=ltac2 ^
  -addon=mtac2 ^
  %EXTRA_ADDONS% ^
  -make=N ^
  -setup %CI_PROJECT_DIR%\%SETUP% || GOTO ErrorCopyLogFilesAndExit

ECHO "Start Artifact Creation"
TIME /T

mkdir artifacts

CALL :CopyLogFiles

copy "%CYGROOT%\build\coq-local\dev\nsis\*.exe" artifacts || GOTO ErrorExit
REM The open source archive is only required for release builds
IF DEFINED WIN_CERTIFICATE_PATH (
  7z a artifacts\coq-opensource-archive-windows-%ARCHLONG%.zip %CYGROOT%\build\tarballs\* || GOTO ErrorExit
) ELSE (
  REM In non release builds, create a dummy file
  ECHO "This is not a release build - open source archive not created / uploaded" > artifacts\coq-opensource-info.txt
)

REM DO NOT echo the signing command below, as this would leak secrets in the logs
IF DEFINED WIN_CERTIFICATE_PATH (
  IF DEFINED WIN_CERTIFICATE_PASSWORD (
    ECHO Signing package
    @signtool sign /f %WIN_CERTIFICATE_PATH% /p %WIN_CERTIFICATE_PASSWORD% dev\nsis\*.exe
    signtool verify /pa dev\nsis\*.exe
  )
)

ECHO "Finished Artifact Creation"
TIME /T

CALL :CleanupFolders

ECHO "Finished Cleanup"
TIME /T

GOTO :EOF

:CopyLogFiles
  ECHO Copy log files for artifact upload
  MKDIR artifacts\buildlogs
  COPY %CYGROOT%\build\buildlogs\* artifacts\buildlogs
  MKDIR artifacts\filelists
  COPY %CYGROOT%\build\filelists\* artifacts\filelists
  MKDIR artifacts\flagfiles
  COPY %CYGROOT%\build\flagfiles\* artifacts\flagfiles
  GOTO :EOF

:CleanupFolders
  ECHO "Cleaning %CYGROOT%"
  RMDIR /S /Q "%CYGROOT%"
  ECHO "Cleaning %DESTCOQ%"
  RMDIR /S /Q "%DESTCOQ%"
  GOTO :EOF

:MakeUniqueFolder
  REM Create a uniquely named folder
  REM This script is safe because folder creation is atomic - either we create it or fail
  REM %1 = base path or directory (_%RANDOM%_%RANDOM% is appended to this)
  REM %2 = name of the variable which receives the unique folder name
  SET "UNIQUENAME=%1_%RANDOM%_%RANDOM%"
  MKDIR "%UNIQUENAME%"
  IF ERRORLEVEL 1 GOTO :MakeUniqueFolder
  SET "%2=%UNIQUENAME%"
  GOTO :EOF

:ErrorCopyLogFilesAndExit
  CALL :CopyLogFiles
  REM fall through

:ErrorExit
  CALL :CleanupFolders
  ECHO ERROR %0 failed
  EXIT /b 1

@ECHO OFF

REM This script builds and signs the Windows packages on Gitlab

ECHO "Start Time"
TIME /T

REM List currently used cygwin and target folders for debugging / maintenance purposes

ECHO "Currently used cygwin folders"
DIR C:\ci\cygwin*
ECHO "Currently used target folders"
DIR C:\ci\coq*
ECHO "Root folders"
DIR C:\

if %ARCH% == 32 (
  SET ARCHLONG=i686
  SET SETUP=setup-x86.exe
)

if %ARCH% == 64 (
  SET ARCHLONG=x86_64
  SET SETUP=setup-x86_64.exe
)

SET CYGROOT=C:\ci\cygwin%ARCH%
SET DESTCOQ=C:\ci\coq%ARCH%

CALL :MakeUniqueFolder %CYGROOT% CYGROOT
CALL :MakeUniqueFolder %DESTCOQ% DESTCOQ

powershell -Command "(New-Object Net.WebClient).DownloadFile('http://www.cygwin.com/%SETUP%', '%SETUP%')"
SET CYGCACHE=%CYGROOT%\var\cache\setup
SET CI_PROJECT_DIR_MFMT=%CI_PROJECT_DIR:\=/%
SET CI_PROJECT_DIR_CFMT=%CI_PROJECT_DIR_MFMT:C:/=/cygdrive/c/%
SET COQREGTESTING=Y
SET PATH=%PATH%;C:\Program Files\7-Zip\;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin

IF "%WINDOWS_ALL_ADDONS%" == "enabled" (
  SET EXTRA_ADDONS=^
    -addon=mathcomp ^
    -addon=menhir ^
    -addon=menhirlib ^
    -addon=compcert ^
    -addon=extlib ^
    -addon=quickchick ^
    -addon=coquelicot
  REM addons with build issues
  REM -addon=vst ^
  REM -addon=aactactics ^
) ELSE (
  SET "EXTRA_ADDONS= "
)

call %CI_PROJECT_DIR%\dev\build\windows\MakeCoq_MinGW.bat -threads=1 ^
  -arch=%ARCH% -installer=Y -coqver=%CI_PROJECT_DIR_CFMT% ^
  -destcyg=%CYGROOT% -destcoq=%DESTCOQ% -cygcache=%CYGCACHE% ^
  -addon=bignums ^
  -addon=equations ^
  -addon=ltac2 ^
  -addon=mtac2 ^
  %EXTRA_ADDONS% ^
  -make=N ^
  -setup %CI_PROJECT_DIR%\%SETUP% || GOTO ErrorCopyLogFilesAndExit

ECHO "Start Artifact Creation"
TIME /T

mkdir artifacts

CALL :CopyLogFiles

copy "%CYGROOT%\build\coq-local\dev\nsis\*.exe" artifacts || GOTO ErrorExit
REM The open source archive is only required for release builds
IF DEFINED WIN_CERTIFICATE_PATH (
  7z a artifacts\coq-opensource-archive-windows-%ARCHLONG%.zip %CYGROOT%\build\tarballs\* || GOTO ErrorExit
) ELSE (
  REM In non release builds, create a dummy file
  ECHO "This is not a release build - open source archive not created / uploaded" > artifacts\coq-opensource-info.txt
)

REM DO NOT echo the signing command below, as this would leak secrets in the logs
IF DEFINED WIN_CERTIFICATE_PATH (
  IF DEFINED WIN_CERTIFICATE_PASSWORD (
    ECHO Signing package
    @signtool sign /f %WIN_CERTIFICATE_PATH% /p %WIN_CERTIFICATE_PASSWORD% dev\nsis\*.exe
    signtool verify /pa dev\nsis\*.exe
  )
)

ECHO "Finished Artifact Creation"
TIME /T

CALL :CleanupFolders

ECHO "Finished Cleanup"
TIME /T

GOTO :EOF

:CopyLogFiles
  ECHO Copy log files for artifact upload
  MKDIR artifacts\buildlogs
  COPY %CYGROOT%\build\buildlogs\* artifacts\buildlogs
  MKDIR artifacts\filelists
  COPY %CYGROOT%\build\filelists\* artifacts\filelists
  MKDIR artifacts\flagfiles
  COPY %CYGROOT%\build\flagfiles\* artifacts\flagfiles
  GOTO :EOF

:CleanupFolders
  ECHO "Cleaning %CYGROOT%"
  RMDIR /S /Q "%CYGROOT%"
  ECHO "Cleaning %DESTCOQ%"
  RMDIR /S /Q "%DESTCOQ%"
  GOTO :EOF

:MakeUniqueFolder
  REM Create a uniquely named folder
  REM This script is safe because folder creation is atomic - either we create it or fail
  REM %1 = base path or directory (_%RANDOM%_%RANDOM% is appended to this)
  REM %2 = name of the variable which receives the unique folder name
  SET "UNIQUENAME=%1_%RANDOM%_%RANDOM%"
  MKDIR "%UNIQUENAME%"
  IF ERRORLEVEL 1 GOTO :MakeUniqueFolder
  SET "%2=%UNIQUENAME%"
  GOTO :EOF

:ErrorCopyLogFilesAndExit
  CALL :CopyLogFiles
  REM fall through

:ErrorExit
  CALL :CleanupFolders
  ECHO ERROR %0 failed
  EXIT /b 1

Remove old folder delete (can interfere with unique folder creation)


SET BLD_DIR=%CD%
cd /D "%RECIPE_DIR%\.."

"%PYTHON%" setup.py install

REM # X.X.X.dev builds
FOR /F "delims=" %%i IN ('git describe --tags') DO set BLAZE_VERSION=%%i
set _result=%ALPHA:-=_%

echo %_result%>__conda_version__.txt

copy __conda_version__.txt "%BLD_DIR%"

if errorlevel 1 exit 1

SET BLD_DIR=%CD%
cd /D "%RECIPE_DIR%\.."

"%PYTHON%" setup.py install

REM # X.X.X.dev builds
FOR /F "delims=" %%i IN ('git describe --tags') DO set BLAZE_VERSION=%%i
set _result=%BLAZE_VERSION:-=_%

echo %_result%>__conda_version__.txt

copy __conda_version__.txt "%BLD_DIR%"

if errorlevel 1 exit 1

Use correct variable name

Use correct variable name


setLocal EnableDelayedExpansion

set SCRIPT_DIR=%CD%
set SPECIFICATION_CLASSNAME=%1
set CONFIG_DIR=%SCRIPT_DIR%\config
set JAVA_CMD=%JAVA_HOME%\bin\java

REM Copy all jars to one location to keep CLASSPATH small
rmdir C:\temp\donkey
mkdir C:\temp\donkey
copy donkey.jar c:\temp\donkey
FOR /F "usebackq tokens=*" %%i IN (`dir /b /s .\lib\*.jar`) DO copy "%%i" C:\temp\donkey

REM Requires Java 1.6
set CLASSPATH=%CLASSPATH%;C:\TEMP\donkey\*
echo %CLASSPATH%
set JVM_OPTIONS=-Xmx256m
REM set JVM_DEBUG_OPTIONS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5010"
set EXEC="%JAVA_CMD%" %JVM_OPTIONS% -Dlog4j.configuration=file:"%CONFIG_DIR%\log4j\log4j.properties" -classpath %CLASSPATH% org.burroloco.donkey.trebuchet.Main %SPECIFICATION_CLASSNAME%

echo %EXEC%
%EXEC%

setLocal EnableDelayedExpansion

set SCRIPT_DIR=%CD%
set SPECIFICATION_CLASSNAME=%1
set CONFIG_DIR=%SCRIPT_DIR%\config
set JAVA_CMD=%JAVA_HOME%\bin\java

REM Copy all jars to one location to keep CLASSPATH small
rmdir /S /Q C:\temp\donkey_%SPECIFICATION_CLASSNAME%
mkdir C:\temp\donkey_%SPECIFICATION_CLASSNAME%
copy donkey.jar c:\temp\donkey_%SPECIFICATION_CLASSNAME%
FOR /F "usebackq tokens=*" %%i IN (`dir /b /s .\lib\*.jar`) DO copy "%%i" C:\temp\donkey_%SPECIFICATION_CLASSNAME%

REM Requires Java 1.6
set CLASSPATH=%CLASSPATH%;C:\temp\donkey_%SPECIFICATION_CLASSNAME%\*
echo %CLASSPATH%
set JVM_OPTIONS=-Xmx512m
REM set JVM_DEBUG_OPTIONS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5010"
set EXEC="%JAVA_CMD%" %JVM_OPTIONS% -Dlog4j.configuration=file:"%CONFIG_DIR%\log4j\log4j.properties" -classpath %CLASSPATH% org.burroloco.donkey.trebuchet.Main %SPECIFICATION_CLASSNAME%

echo %EXEC%
%EXEC%

REM Cleanup
rmdir /S /Q C:\temp\donkey_%SPECIFICATION_CLASSNAME%

Make donkey.bat behave a little nicer with other donkey.bats running concurrently.
Bump up -Xmx.

git-svn-id: 21608d751df957719be70fb82654cee6a1ac4b9d@352 080cfd25-d5d9-4c59-82ea-70d02a200d8b


IF EXIST bin rmdir bin /S /Q
IF EXIST obj rmdir obj /S /Q
msbuild FalconUDP.sln /p:Configuration=Debug
msbuild FalconUDP.sln /p:Configuration=Release
msbuild FalconUDPMono.msbuild /p:Configuration=Debug
msbuild FalconUDPMono.msbuild /p:Configuration=Release
msbuild FalconUDPMonoLinux.msbuild /p:Configuration=Debug
msbuild FalconUDPMonoLinux.msbuild /p:Configuration=Release

Remove bin and obj dirs when building

Remove bin and obj dirs when building


@ECHO OFF
IF "%1"=="" (SET TARGET_DOTNET=35) ELSE (SET TARGET_DOTNET=%1)

IF NOT EXIST gen MKDIR gen
IF NOT EXIST bin MKDIR bin
DEL /Q gen\*.*
DEL /Q bin\*.*

ECHO Generating resources...

tools\ResGen.exe resources/CommandLine.resx gen\HFMCmd.Resource.CommandLine.resources /str:cs,HFMCmd.Resource,CommandLine,gen\CommandLineResource.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

tools\ResGen.exe resources/Help.resx gen\HFMCmd.Resource.Help.resources /str:cs,HFMCmd.Resource,Help,gen\HelpResource.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

IF %TARGET_DOTNET%==35 GOTO DOTNET35
IF %TARGET_DOTNET%==40 GOTO DOTNET40

ECHO Usage: build.bat *Version*, where *Version* is one of: 35 or 40 (default is 35)
EXIT /B 99

:DOTNET35
ECHO Targeting .NET Framework 3.5...

ECHO Compiling HFMCmd...
C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\3.5\HFMCmd.exe /debug /optimize+ /lib:lib\log4net-1.2.11\bin\net\3.5\release /reference:log4net.dll /lib:lib/hfm-11.1.2.2 /reference:Interop.HFMCONSTANTSLib.dll /reference:Interop.HFMSLICECOMLib.dll /reference:Interop.HFMWAPPLICATIONSLib.dll /reference:Interop.HFMWDOCUMENTSLib.dll /reference:Interop.HFMWSESSIONLib.dll /reference:Interop.HSVCALCULATELib.dll /reference:Interop.HSVCDATALOADLib.dll /reference:Interop.HSVDATALib.dll /reference:Interop.HSVJOURNALLOADACVLib.dll /reference:Interop.HSVJOURNALSLib.dll /reference:Interop.HSVMETADATALib.dll /reference:Interop.HSVMETADATALOADACVLib.dll /reference:Interop.HSVRESOURCEMANAGERLib.dll /reference:Interop.HSVRULESLOADACVLib.dll /reference:Interop.HSVSECURITYACCESSLib.dll /reference:Interop.HSVSECURITYLOADACVLib.dll /reference:Interop.HSVSESSIONLib.dll /reference:Interop.HSVSTARSCHEMAACMLib.dll /reference:Interop.HSVSYSTEMINFOLib.dll /reference:Interop.HSXCLIENTLib.dll /reference:Interop.HSXSERVERLib.dll /resource:gen\HFMCmd.Resource.CommandLine.resources /resource:gen\HFMCmd.Resource.Help.resources src\*.cs src\command\*.cs src\commandline\*.cs src\yaml\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe  /wildcards /lib:C:\WINDOWS\Microsoft.NET\Framework\v3.5 /out:bin\3.5\HFMCmd.exe gen\3.5\HFMCmd.exe lib/hfm-11.1.2.2\*.dll lib\log4net-1.2.11\bin\net\3.5\release\log4net.dll

GOTO END

:DOTNET40
ECHO Targeting .NET Framework 4.0...

ECHO Compiling HFMCmd...
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\4.0\HFMCmd.exe /debug /optimize+ /lib:lib\log4net-1.2.11\bin\net\4.0\release /reference:log4net.dll /lib:lib/hfm-11.1.2.2 /link:Interop.HFMCONSTANTSLib.dll /link:Interop.HFMSLICECOMLib.dll /link:Interop.HFMWAPPLICATIONSLib.dll /link:Interop.HFMWDOCUMENTSLib.dll /link:Interop.HFMWSESSIONLib.dll /link:Interop.HSVCALCULATELib.dll /link:Interop.HSVCDATALOADLib.dll /link:Interop.HSVDATALib.dll /link:Interop.HSVJOURNALLOADACVLib.dll /link:Interop.HSVJOURNALSLib.dll /link:Interop.HSVMETADATALib.dll /link:Interop.HSVMETADATALOADACVLib.dll /link:Interop.HSVRESOURCEMANAGERLib.dll /link:Interop.HSVRULESLOADACVLib.dll /link:Interop.HSVSECURITYACCESSLib.dll /link:Interop.HSVSECURITYLOADACVLib.dll /link:Interop.HSVSESSIONLib.dll /link:Interop.HSVSTARSCHEMAACMLib.dll /link:Interop.HSVSYSTEMINFOLib.dll /link:Interop.HSXCLIENTLib.dll /link:Interop.HSXSERVERLib.dll /resource:gen\HFMCmd.Resource.CommandLine.resources /resource:gen\HFMCmd.Resource.Help.resources src\*.cs src\command\*.cs src\commandline\*.cs src\yaml\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe /targetplatform:v4,C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 /wildcards /lib:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 /out:bin\4.0\HFMCmd.exe gen\4.0\HFMCmd.exe  lib\log4net-1.2.11\bin\net\4.0\release\log4net.dll

GOTO END

:END
ECHO Build complete!

@ECHO OFF
IF "%1"=="" (SET TARGET_DOTNET=35) ELSE (SET TARGET_DOTNET=%1)

IF NOT EXIST gen MKDIR gen
IF NOT EXIST bin MKDIR bin
DEL /Q gen\*.*
DEL /Q bin\*.*

ECHO Generating resources...

tools\ResGen.exe resources/Help.resx gen\HFMCmd.Resource.Help.resources /str:cs,HFMCmd.Resource,Help,gen\HelpResource.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

IF %TARGET_DOTNET%==35 GOTO DOTNET35
IF %TARGET_DOTNET%==40 GOTO DOTNET40

ECHO Usage: build.bat *Version*, where *Version* is one of: 35 or 40 (default is 35)
EXIT /B 99

:DOTNET35
ECHO Targeting .NET Framework 3.5...

ECHO Compiling HFMCmd...
C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\3.5\HFMCmd.exe /debug /optimize+ /lib:lib\log4net-1.2.11\bin\net\3.5\release /reference:log4net.dll /lib:lib/hfm-11.1.2.2 /reference:Interop.HFMCONSTANTSLib.dll /reference:Interop.HFMSLICECOMLib.dll /reference:Interop.HFMWAPPLICATIONSLib.dll /reference:Interop.HFMWDOCUMENTSLib.dll /reference:Interop.HFMWSESSIONLib.dll /reference:Interop.HSVCALCULATELib.dll /reference:Interop.HSVCDATALOADLib.dll /reference:Interop.HSVDATALib.dll /reference:Interop.HSVJOURNALLOADACVLib.dll /reference:Interop.HSVJOURNALSLib.dll /reference:Interop.HSVMETADATALib.dll /reference:Interop.HSVMETADATALOADACVLib.dll /reference:Interop.HSVRESOURCEMANAGERLib.dll /reference:Interop.HSVRULESLOADACVLib.dll /reference:Interop.HSVSECURITYACCESSLib.dll /reference:Interop.HSVSECURITYLOADACVLib.dll /reference:Interop.HSVSESSIONLib.dll /reference:Interop.HSVSTARSCHEMAACMLib.dll /reference:Interop.HSVSYSTEMINFOLib.dll /reference:Interop.HSXCLIENTLib.dll /reference:Interop.HSXSERVERLib.dll /resource:gen\HFMCmd.Resource.CommandLine.resources /resource:gen\HFMCmd.Resource.Help.resources src\*.cs src\command\*.cs src\commandline\*.cs src\yaml\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe  /wildcards /lib:C:\WINDOWS\Microsoft.NET\Framework\v3.5 /out:bin\3.5\HFMCmd.exe gen\3.5\HFMCmd.exe lib/hfm-11.1.2.2\*.dll lib\log4net-1.2.11\bin\net\3.5\release\log4net.dll

GOTO END

:DOTNET40
ECHO Targeting .NET Framework 4.0...

ECHO Compiling HFMCmd...
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe /nologo /target:exe /main:HFMCmd.Launcher /out:gen\4.0\HFMCmd.exe /debug /optimize+ /lib:lib\log4net-1.2.11\bin\net\4.0\release /reference:log4net.dll /lib:lib/hfm-11.1.2.2 /link:Interop.HFMCONSTANTSLib.dll /link:Interop.HFMSLICECOMLib.dll /link:Interop.HFMWAPPLICATIONSLib.dll /link:Interop.HFMWDOCUMENTSLib.dll /link:Interop.HFMWSESSIONLib.dll /link:Interop.HSVCALCULATELib.dll /link:Interop.HSVCDATALOADLib.dll /link:Interop.HSVDATALib.dll /link:Interop.HSVJOURNALLOADACVLib.dll /link:Interop.HSVJOURNALSLib.dll /link:Interop.HSVMETADATALib.dll /link:Interop.HSVMETADATALOADACVLib.dll /link:Interop.HSVRESOURCEMANAGERLib.dll /link:Interop.HSVRULESLOADACVLib.dll /link:Interop.HSVSECURITYACCESSLib.dll /link:Interop.HSVSECURITYLOADACVLib.dll /link:Interop.HSVSESSIONLib.dll /link:Interop.HSVSTARSCHEMAACMLib.dll /link:Interop.HSVSYSTEMINFOLib.dll /link:Interop.HSXCLIENTLib.dll /link:Interop.HSXSERVERLib.dll /resource:gen\HFMCmd.Resource.CommandLine.resources /resource:gen\HFMCmd.Resource.Help.resources src\*.cs src\command\*.cs src\commandline\*.cs src\yaml\*.cs src\hfm\*.cs gen\*.cs properties\*.cs
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%

ECHO Bundling HFMCmd and libraries into HFMCmd.exe...
tools\ILMerge\ILMerge.exe /targetplatform:v4,C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 /wildcards /lib:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 /out:bin\4.0\HFMCmd.exe gen\4.0\HFMCmd.exe  lib\log4net-1.2.11\bin\net\4.0\release\log4net.dll

GOTO END

:END
ECHO Build complete!

Update build.bat for removed resource

Update build.bat for removed resource


@echo off
pushd "%~dp0"

nuget install -ConfigFile Stuff\NuGet.config -OutputDirectory Stuff -ExcludeVersion Stuff\packages.config || goto ERROR
Stuff\stuff install Stuff || goto ERROR
Stuff\uno doctor %* || goto ERROR

popd && exit /b 0

:ERROR
pause
popd && exit /b 1

@echo off
pushd "%~dp0"

nuget install -ConfigFile Stuff\NuGet.config -OutputDirectory Stuff -ExcludeVersion Stuff\packages.config || goto ERROR
Stuff\uno doctor %* || goto ERROR

popd && exit /b 0

:ERROR
pause
popd && exit /b 1

drop 'stuff install'

build.bat: drop 'stuff install'

There are no longer any stuff files to install.


dist\conmon.exe stop
dist\conmon.exe remove
pyinstaller -F --hidden-import=win32timezone conmon.py
copy _config.yml dist\
dist\conmon.exe --startup=auto install
dist\conmon.exe start

dist\conmon.exe stop
dist\conmon.exe remove
pyinstaller -F --hidden-import=win32timezone conmon.py
copy _config.yml dist\
copy config.yml dist\
dist\conmon.exe --startup=auto install
dist\conmon.exe start

copy config

copy config


@echo off

pushd %~dp0

SET PACKAGEPATH=.\packages\
SET NUGET=.\tools\nuget\NuGet.exe
SET NUGETOPTIONS=-ConfigFile .\tools\nuget\NuGet.Config -OutputDirectory %PACKAGEPATH% -ExcludeVersion

IF NOT EXIST %PACKAGEPATH%FAKE\Ver_4.23.0 (
  %NUGET% install FAKE -Version 4.23.0 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE\Ver_4.23.0
)

IF NOT EXIST %PACKAGEPATH%FAKE.BuildLib\Ver_0.1.4 (
  %NUGET% install FAKE.BuildLib -Version 0.1.4 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE.BuildLib\Ver_0.1.4
)

set encoding=utf-8
"%PACKAGEPATH%FAKE\tools\FAKE.exe" build.fsx %*

popd

@echo off

pushd %~dp0

SET PACKAGEPATH=.\packages\
SET NUGET=.\tools\nuget\NuGet.exe
SET NUGETOPTIONS=-ConfigFile .\tools\nuget\NuGet.Config -OutputDirectory %PACKAGEPATH% -ExcludeVersion

IF NOT EXIST %PACKAGEPATH%FAKE\Ver_4.23.0 (
  %NUGET% install FAKE -Version 4.23.0 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE\Ver_4.23.0
)

IF NOT EXIST %PACKAGEPATH%FAKE.BuildLib\Ver_0.1.5 (
  %NUGET% install FAKE.BuildLib -Version 0.1.5 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE.BuildLib\Ver_0.1.5
)

set encoding=utf-8
"%PACKAGEPATH%FAKE\tools\FAKE.exe" build.fsx %*

popd

Use FAKE.BuildLib 0.1.5

Use FAKE.BuildLib 0.1.5


@echo off
SETLOCAL

cls

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

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

SET FAKE_PATH=packages\build\FAKE\tools\Fake.exe

IF [%1]==[] (
    "%FAKE_PATH%" "build.fsx" "Default"
) ELSE (
    "%FAKE_PATH%" "build.fsx" %*
)

@echo off
SETLOCAL

cls

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

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

SET FAKE_PATH=packages\build\FAKE\tools\Fake.exe
SET Platform=

IF [%1]==[] (
    "%FAKE_PATH%" "build.fsx" "Default"
) ELSE (
    "%FAKE_PATH%" "build.fsx" %*
)

Allow to build FAKE on HP computers

Allow to build FAKE on HP computers

See #1312.


echo Extend drive C to maximum
echo select volume 2 >%TEMP%\extendC.txt
echo extend >>%TEMP%\extendC.txt
diskpart.exe /s %TEMP%\extendC.txt
set WORKDRIVE=C:

echo Ensuring .NET 4.0 is installed
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.github.com/StefanScherer/arduino-ide/install/InstallNet4.ps1'))"
echo Installing Chocolatey
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

if "%ChocolateyInstall%x"=="x" set ChocolateyInstall=%SystemDrive%\Chocolatey
where cinst
if ERRORLEVEL 1 goto set_chocolatey
goto inst
:set_chocolatey
set PATH=%PATH%;%ChocolateyInstall%\bin
:inst

call cinst vagrant
set PATH=%PATH%;%SystemDrive%\hashicorp\vagrant\bin
cd /D %USERPROFILE%\Documents

call cinst wget
call cinst 7zip
set PATH=%PATH%;C:\Program Files\7-Zip
call cinst vim
where gvim.exe
if ERRORLEVEL 1 call :addVimToUserPath
goto VIM_DONE
:addVimToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\Program Fiels (x86)\vim\vim74" /f
set PATH=%PATH%;C:\Program Files (x86)\vim\vim74
exit /b
:VIM_DONE

call cinst msysgit
set PATH=%PATH%;C:\Program Files (x86)\Git\cmd

rem install firefox and all plugins needed to access vCloud via browser
call cinst firefox
call cinst flashplayerplugin
if not exist "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" (
call wget -O "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" http://roecloudsrv001/vmware/clientintegrationplugin/VMware-ClientIntegrationPlugin-5.5.0.exe
)
"%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" /s /v/qn
del "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe"

rem Install packer 0.5.2
if not exist %WORKDRIVE%\Packer\cache mkdir %WORKDRIVE%\Packer\cache
setx PACKER_CACHE_DIR %WORKDRIVE%\Packer\cache
set PACKER_CACHE_DIR=%WORKDRIVE%\Packer\cache
if not exist %WORKDRIVE%\Packer\temp mkdir %WORKDRIVE%\Packer\temp
setx PACKER_TEMP_DIR %WORKDRIVE%\Packer\temp
set PACKER_TEMP_DIR=%WORKDRIVE%\Packer\temp

call cinst packer
where packer
if ERRORLEVEL 1 call :addPackerToUserPath
goto PACKER_DONE
:addPackerToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\hashicorp\packer" /f
set PATH=%PATH%;C:\hashicorp\packer
exit /b
:PACKER_DONE

echo Skipping VirtualBox installation
goto VIRTUALBOX_DONE

rem Install VirtualBox 4.3.6
if not exist "%USERPROFILE%\.VirtualBox\VirtualBox.xml" (
  mkdir "%USERPROFILE%\.VirtualBox"
  call wget --no-check-certificate https://github.com/StefanScherer/basebox-slave/raw/master/VirtualBox.xml -O "%USERPROFILE%\.VirtualBox\VirtualBox.xml"
)
call cinst virtualbox
if not exist %WORKDRIVE%\VirtualBox mkdir %WORKDRIVE%\VirtualBox
rem if exist "C:\program files\oracle\virtualbox\vboxmanage.exe" goto VIRTUALBOX_INSTALLED
rem wget http://download.virtualbox.org/virtualbox/4.3.6/VirtualBox-4.3.6-91406-Win.exe -O %TEMP%\VirtualBox-4.3.6-91406-Win.exe
rem %TEMP%\VirtualBox-4.3.6-91406-Win.exe -s
:VIRTUALBOX_INSTALLED
where vboxmanage
if ERRORLEVEL 1 call :addVirtualBoxToUserPath
goto VIRTUALBOX_DONE
:addVirtualBoxToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\program files\oracle\virtualbox" /f
set PATH=%PATH%;C:\program files\oracle\virtualbox
exit /b
:VIRTUALBOX_DONE

rem Install Jenkins
rem wget http://mirrors.jenkins-ci.org/windows/latest -O %TEMP%\jenkins.zip
rem cd /D %TEMP%
rem unzip jenkins.zip
rem setup.exe -s

if not exist %WORKDRIVE%\GitHub mkdir %WORKDRIVE%\GitHub
cd /D %WORKDRIVE%\GitHub
if not exist basebox-packer (
  git clone https://github.com/StefanScherer/basebox-packer.git
) else (
  cd basebox-packer
  git pull
  cd ..
)

if not exist packer-windows (
  git clone -b san https://github.com/StefanScherer/packer-windows.git
) else (
  cd packer-windows
  git pull
  cd ..
)

if not exist basebox-slave (
  git clone https://github.com/StefanScherer/basebox-slave.git
) else (
  cd basebox-slave
  git pull
  cd ..
)

echo Install VMware PowerCLI...
if not exist "c:\Program Files (x86)\VMware\VMware VIX" (
  if not exist "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe" (
    call wget -O "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe" http://roecloudsrv001/vmware/powercli/VMware-PowerCLI-5.5.0-1671586.exe
  )
  powershell -Command "Import-Module ServerManager; Add-WindowsFeature NET-Framework-Features"
  "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe" /s /v/qn /vADDLOCAL=ALL
  del "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe"
)

echo Install VMware Workstation...
rem Install VMware Workstation
if not exist "%USERPROFILE%\AppData\Roaming\VMWare\preferences.ini" (
  if not exist "%USERPROFILE%\AppData\Roaming\VMWare" mkdir "%USERPROFILE%\AppData\Roaming\VMWare"
  call wget --no-check-certificate -O "%USERPROFILE%\AppData\Roaming\VMWare\preferences.ini" https://raw.github.com/StefanScherer/basebox-slave/master/preferences.ini
)
if not exist "c:\Program Files (x86)\VMware\VMware Workstation" (
  if not exist "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" (
    call wget -O "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" http://roecloudsrv001/vmware/workstation10/VMware-workstation-full-10.0.0-1295980.exe
  )
  rem "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1 SERIALNUMBER="xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"
  "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1
  del "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe"
)

rem put ovftool into path
where ovftool
if ERRORLEVEL 1 call :addOvftoolToUserPath
goto OVFTOOL_DONE
:addOvftoolToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool" /f
set PATH=%PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool
exit /b
:OVFTOOL_DONE

rem install addtime to measure time
call cinst strawberryperl
set PATH=%PATH%;c:\strawberry\perl\bin
call wget --no-check-certificate -O c:\chocolatey\bin\addtime.bat https://github.com/StefanScherer/dotfiles-windows/raw/master/bin/addtime.bat

call cinst javaruntime
if not exist %WORKDRIVE%\jenkins mkdir %WORKDRIVE%\jenkins
if not exist %WORKDRIVE%\swarmclient mkdir %WORKDRIVE%\swarmclient
cd /D %WORKDRIVE%\swarmclient
call wget -O swarm-client.jar http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/1.8/swarm-client-1.8-jar-with-dependencies.jar

set jenkinshost=10.115.4.8
net user swarmclient K8934jASD,x9  /ADD
net localgroup Administrators swarmclient /add
rem Due to problems with UDP broadcast, use the -master switch at the moment
rem Schedule start of swarm client at start of the machine (after next reboot)
schtasks /CREATE /SC ONSTART /RU swarmclient /RP K8934jASD,x9 /TN JenkinsSwarmClient /TR "java.exe -jar %WORKDRIVE%\swarmclient\swarm-client.jar -master http://%jenkinshost% -labels packer -fsroot %WORKDRIVE%\jenkins"

cd %WORKDRIVE%\GitHub\packer-windows
vagrant --version
packer --version
vboxmanage --version
ovftool -version

echo Extend drive C to maximum
echo select volume 2 >%TEMP%\extendC.txt
echo extend >>%TEMP%\extendC.txt
diskpart.exe /s %TEMP%\extendC.txt
set WORKDRIVE=C:

echo Ensuring .NET 4.0 is installed
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.github.com/StefanScherer/arduino-ide/install/InstallNet4.ps1'))"
echo Installing Chocolatey
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

if "%ChocolateyInstall%x"=="x" set ChocolateyInstall=%SystemDrive%\Chocolatey
where cinst
if ERRORLEVEL 1 goto set_chocolatey
goto inst
:set_chocolatey
set PATH=%PATH%;%ChocolateyInstall%\bin
:inst

call cinst vagrant
set PATH=%PATH%;%SystemDrive%\hashicorp\vagrant\bin
cd /D %USERPROFILE%\Documents

call cinst wget
call cinst 7zip
set PATH=%PATH%;C:\Program Files\7-Zip
call cinst vim
where gvim.exe
if ERRORLEVEL 1 call :addVimToUserPath
goto VIM_DONE
:addVimToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\Program Fiels (x86)\vim\vim74" /f
set PATH=%PATH%;C:\Program Files (x86)\vim\vim74
exit /b
:VIM_DONE

call cinst msysgit
set PATH=%PATH%;C:\Program Files (x86)\Git\cmd

rem install firefox and all plugins needed to access vCloud via browser
call cinst firefox
call cinst flashplayerplugin
if not exist "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" (
call wget -O "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" http://roecloudsrv001.sealsystems.local/vmware/clientintegrationplugin/VMware-ClientIntegrationPlugin-5.5.0.exe
)
"%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" /s /v/qn
del "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe"

rem Install packer 0.5.2
if not exist %WORKDRIVE%\Packer\cache mkdir %WORKDRIVE%\Packer\cache
setx PACKER_CACHE_DIR %WORKDRIVE%\Packer\cache
set PACKER_CACHE_DIR=%WORKDRIVE%\Packer\cache
if not exist %WORKDRIVE%\Packer\temp mkdir %WORKDRIVE%\Packer\temp
setx PACKER_TEMP_DIR %WORKDRIVE%\Packer\temp
set PACKER_TEMP_DIR=%WORKDRIVE%\Packer\temp

call cinst packer
where packer
if ERRORLEVEL 1 call :addPackerToUserPath
goto PACKER_DONE
:addPackerToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\hashicorp\packer" /f
set PATH=%PATH%;C:\hashicorp\packer
exit /b
:PACKER_DONE

echo Skipping VirtualBox installation
goto VIRTUALBOX_DONE

rem Install VirtualBox 4.3.6
if not exist "%USERPROFILE%\.VirtualBox\VirtualBox.xml" (
  mkdir "%USERPROFILE%\.VirtualBox"
  call wget --no-check-certificate https://github.com/StefanScherer/basebox-slave/raw/master/VirtualBox.xml -O "%USERPROFILE%\.VirtualBox\VirtualBox.xml"
)
call cinst virtualbox
if not exist %WORKDRIVE%\VirtualBox mkdir %WORKDRIVE%\VirtualBox
rem if exist "C:\program files\oracle\virtualbox\vboxmanage.exe" goto VIRTUALBOX_INSTALLED
rem wget http://download.virtualbox.org/virtualbox/4.3.6/VirtualBox-4.3.6-91406-Win.exe -O %TEMP%\VirtualBox-4.3.6-91406-Win.exe
rem %TEMP%\VirtualBox-4.3.6-91406-Win.exe -s
:VIRTUALBOX_INSTALLED
where vboxmanage
if ERRORLEVEL 1 call :addVirtualBoxToUserPath
goto VIRTUALBOX_DONE
:addVirtualBoxToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\program files\oracle\virtualbox" /f
set PATH=%PATH%;C:\program files\oracle\virtualbox
exit /b
:VIRTUALBOX_DONE

rem Install Jenkins
rem wget http://mirrors.jenkins-ci.org/windows/latest -O %TEMP%\jenkins.zip
rem cd /D %TEMP%
rem unzip jenkins.zip
rem setup.exe -s

if not exist %WORKDRIVE%\GitHub mkdir %WORKDRIVE%\GitHub
cd /D %WORKDRIVE%\GitHub
if not exist basebox-packer (
  git clone https://github.com/StefanScherer/basebox-packer.git
) else (
  cd basebox-packer
  git pull
  cd ..
)

if not exist packer-windows (
  git clone -b san https://github.com/StefanScherer/packer-windows.git
) else (
  cd packer-windows
  git pull
  cd ..
)

if not exist basebox-slave (
  git clone https://github.com/StefanScherer/basebox-slave.git
) else (
  cd basebox-slave
  git pull
  cd ..
)

echo Install VMware PowerCLI...
if not exist "c:\Program Files (x86)\VMware\VMware VIX" (
  if not exist "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe" (
    call wget -O "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe" http://roecloudsrv001.sealsystems.local/vmware/powercli/VMware-PowerCLI-5.5.0-1671586.exe
  )
  powershell -Command "Import-Module ServerManager; Add-WindowsFeature NET-Framework-Features"
  "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe" /s /v/qn /vADDLOCAL=ALL
  del "%TEMP%\VMware-PowerCLI-5.5.0-1671586.exe"
)

echo Install VMware Workstation...
rem Install VMware Workstation
if not exist "%USERPROFILE%\AppData\Roaming\VMWare\preferences.ini" (
  if not exist "%USERPROFILE%\AppData\Roaming\VMWare" mkdir "%USERPROFILE%\AppData\Roaming\VMWare"
  call wget --no-check-certificate -O "%USERPROFILE%\AppData\Roaming\VMWare\preferences.ini" https://raw.github.com/StefanScherer/basebox-slave/master/preferences.ini
)
if not exist "c:\Program Files (x86)\VMware\VMware Workstation" (
  if not exist "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" (
    call wget -O "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" http://roecloudsrv001.sealsystems.local/vmware/workstation10/VMware-workstation-full-10.0.0-1295980.exe
  )
  rem "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1 SERIALNUMBER="xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"
  "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1
  del "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe"
)

rem put ovftool into path
where ovftool
if ERRORLEVEL 1 call :addOvftoolToUserPath
goto OVFTOOL_DONE
:addOvftoolToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool" /f
set PATH=%PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool
exit /b
:OVFTOOL_DONE

rem install addtime to measure time
call cinst strawberryperl
set PATH=%PATH%;c:\strawberry\perl\bin
call wget --no-check-certificate -O c:\chocolatey\bin\addtime.bat https://github.com/StefanScherer/dotfiles-windows/raw/master/bin/addtime.bat

call cinst javaruntime
if not exist %WORKDRIVE%\jenkins mkdir %WORKDRIVE%\jenkins
if not exist %WORKDRIVE%\swarmclient mkdir %WORKDRIVE%\swarmclient
cd /D %WORKDRIVE%\swarmclient
call wget -O swarm-client.jar http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/1.8/swarm-client-1.8-jar-with-dependencies.jar

set jenkinshost=10.115.4.8
net user swarmclient K8934jASD,x9  /ADD
net localgroup Administrators swarmclient /add
rem Due to problems with UDP broadcast, use the -master switch at the moment
rem Schedule start of swarm client at start of the machine (after next reboot)
schtasks /CREATE /SC ONSTART /RU swarmclient /RP K8934jASD,x9 /TN JenkinsSwarmClient /TR "java.exe -jar %WORKDRIVE%\swarmclient\swarm-client.jar -master http://%jenkinshost% -labels packer -fsroot %WORKDRIVE%\jenkins"

cd %WORKDRIVE%\GitHub\packer-windows
vagrant --version
packer --version
vboxmanage --version
ovftool -version

use FQDN for internal links

use FQDN for internal links


git clone https://github.com/CodingLizards/serpentes.git .
call npm install
call npm install -g nodemon
start http://localhost:1337/
node install.js PORT=1337
call start.bat

git init .
git remote add -f -t master -m master origin https://github.com/CodingLizards/serpentes.git
git checkout master
call npm install
call npm install -g nodemon
start http://localhost:1337/
node install.js PORT=1337
call start.bat

install script didn't work with clone

install script didn't work with clone

so we imitated clone and now it works just fine :)


echo ON

if "%PY3K%" == "1" (
  2to3 --output-dir=src/py3 -W -n src/py
  rmdir src/py /s /q
  move src/py3 src/py
  2to3 --output-dir=test3 -W -n test
  rmdir test /s /q
  move test3 test
)

python setup.py install

echo ON

if "%PY3K%" == "1" (
  2to3 --output-dir=src/py3 -W -n src/py
  rmdir src/py /s /q
  move src\py3 src\py
  2to3 --output-dir=test3 -W -n test
  rmdir test /s /q
  move test3 test
)

python setup.py install

Update bld.bat

Update bld.bat


REM install_programs_manager_schema_and_objects.bat

REM install the schema
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\create_programs_manager_schema.sql  1> install_programs_manager_schema_and_objects.log 2>&1

REM -- insert the actions for the programs_manager service that require authorization.
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_system_actions_for_prgrm_mngr.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

REM install the objects
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\program_folders.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_programs_history.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_organizations_history.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_continua.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_change_program_user_visibility.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_list_user_visible_organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_list_user_visible_programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_change_organization_user_visibility.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\utility_functions\trig_log_user_allowed_programs_history.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\utility_functions\insert_master_user_report_manager_actions.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\utility_functions\run_insert_master_user_prgrm_mngr_actions.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

REM install_programs_manager_schema_and_objects.bat

REM install the schema
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\create_programs_manager_schema.sql  1> install_programs_manager_schema_and_objects.log 2>&1

REM -- insert the actions for the programs_manager service that require authorization.
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_system_actions_for_prgrm_mngr.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

REM install the objects
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\program_folders.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_programs_history.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\system_user_allowed_organizations_history.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_continua.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_change_program_user_visibility.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_list_user_visible_organizations.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_list_user_visible_programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\action_functions\action_change_organization_user_visibility.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\utility_functions\trig_log_user_allowed_programs_history.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

REM add master user
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\utility_functions\insert_master_user_report_manager_actions.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\utility_functions\run_insert_master_user_prgrm_mngr_actions.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

REM add organizations, folders,and programs
"C:\Program Files\PostgreSQL\9.4\bin\psql.exe" -h localhost -U postgres -d report_manager_database  -p 5432 -f C:\funda_components\programs_manager\programs_manager_database\table_definitions\insert_organizations_program_folders_and_programs.sql  1>> install_programs_manager_schema_and_objects.log 2>>&1

insert STEPS organizations and programs

insert STEPS organizations and programs


@echo off
setlocal

call fb-init.bat

taskkill /im tgitcache.exe 1>NUL 2>NUL
if not exist cs-init call cs-init.bat || goto :ko
robocopy cs-init cs-do /MIR

pushd cs-do
%FULLBUILD% clone * || goto :ko
%FULLBUILD% index * || goto :ko
%FULLBUILD% convert * || goto :ko
%FULLBUILD% view all * || goto :ko
%FULLBUILD% view csc cassandra-sharp-contrib/* || goto :ko
%FULLBUILD% list view || goto :ko
%FULLBUILD% describe view all || goto :ko
%FULLBUILD% graph all || goto :ko
%FULLBUILD% build all || goto :ko
%FULLBUILD% drop view csc || goto :ko
%FULLBUILD% outdated package || goto :ko
%FULLBUILD% update package || goto :ko
%FULLBUILD% push 42 || goto :ko

:ok
echo *** SUCCESSFUL
exit /b 0

:ko
echo *** FAILURE
exit /b 0

@echo off
setlocal

call fb-init.bat

taskkill /im tgitcache.exe 1>NUL 2>NUL
if not exist cs-init call cs-init.bat || goto :ko
robocopy cs-init cs-do /MIR

pushd cs-do
%FULLBUILD% clone * || goto :ko
%FULLBUILD% index * || goto :ko
%FULLBUILD% convert * || goto :ko
%FULLBUILD% view all * || goto :ko
%FULLBUILD% view csc cassandra-sharp-contrib/* || goto :ko
%FULLBUILD% list view || goto :ko
%FULLBUILD% describe view all || goto :ko
%FULLBUILD% graph all || goto :ko
%FULLBUILD% build all || goto :ko
%FULLBUILD% history || goto :ko
%FULLBUILD% drop view csc || goto :ko
%FULLBUILD% outdated package || goto :ko
%FULLBUILD% update package || goto :ko
%FULLBUILD% push 42 || goto :ko

:ok
echo *** SUCCESSFUL
exit /b 0

:ko
echo *** FAILURE
exit /b 0

add history to integration test

add history to integration test


@echo off
set /p file="Please enter the shader file:"
LoveShaderConverter.exe %file%
pause

@echo off
echo Welcome to Love Shader Converter,
echo this file needs to be executed from the same directory as the EXE.
echo
set /p file="Please enter the shader file:"
LoveShaderConverter.exe %file%
pause

Update LoveShaderConverter.bat

Update LoveShaderConverter.bat


setlocal

set nocache=0

if not exist thirdparty.cached set nocache=1
if not exist %BOOST_ROOT% set nocache=1

if %nocache% == 1 (
	pushd C:\Libraries
	curl -fsSO http://iweb.dl.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.7z
	7z x boost_1_60_0.7z | find "ing archive"
	cd boost_1_60_0
	call .\bootstrap.bat
	call .\b2.exe --prefix=%BOOST_ROOT% toolset=msvc-14.0 variant=release link=static threading=multi runtime-link=static --with-date_time --with-filesystem --with-system --with-regex --with-signals --with-thread --with-locale -q -d0 install
	xcopy /e /i /y /q %BOOST_ROOT%\include\boost-1_60\boost %BOOST_ROOT%\boost
	popd
	if %ERRORLEVEL% NEQ 0 goto ERROR

	call .\build.bat thirdparty
	if %ERRORLEVEL% NEQ 0 goto ERROR

	date /t > thirdparty.cached & time /t >> thirdparty.cached
	echo.
	echo Thirdparty libraries installed.
	echo.
	goto EXIT
) else (
	echo.
	echo Last build date of cache is
	type thirdparty.cached
	echo.
	goto EXIT
)

:ERROR
set EXITCODE=%ERRORLEVEL%

:EXIT
exit /b %EXITCODE%

setlocal

set nocache=0

if not exist thirdparty.cached set nocache=1
if not exist %BOOST_ROOT% set nocache=1

if %nocache% == 1 (
	pushd C:\Libraries
	curl -fsSO http://superb-sea2.dl.sourceforge.net/project/boost/boost/1.61.0/boost_1_61_0.7z
	7z x boost_1_61_0.7z | find "ing archive"
	cd boost_1_61_0
	call .\bootstrap.bat
	call .\b2.exe --prefix=%BOOST_ROOT% toolset=msvc-14.0 variant=release link=static threading=multi runtime-link=static --with-date_time --with-filesystem --with-system --with-regex --with-signals --with-thread --with-locale -q -d0 install
	xcopy /e /i /y /q %BOOST_ROOT%\include\boost-1_61\boost %BOOST_ROOT%\boost
	popd
	if %ERRORLEVEL% NEQ 0 goto ERROR

	call .\build.bat thirdparty
	if %ERRORLEVEL% NEQ 0 goto ERROR

	date /t > thirdparty.cached & time /t >> thirdparty.cached
	echo.
	echo Thirdparty libraries installed.
	echo.
	goto EXIT
) else (
	echo.
	echo Last build date of cache is
	type thirdparty.cached
	echo.
	goto EXIT
)

:ERROR
set EXITCODE=%ERRORLEVEL%

:EXIT
exit /b %EXITCODE%

Upgrade libboost to 1.61.0.

Upgrade libboost to 1.61.0.


:: First, make sure you have sed, gawk, cat, and cp

cd src

:: Create Makefile for Windows.
nmake -f Makefile.in prep-windows
if errorlevel 1 exit 1

:: Build the sources
nmake [NODEBUG=1]
if errorlevel 1 exit 1

:: Copy headers, libs, executables.
nmake install [NODEBUG=1]
if errorlevel 1 exit 1

:: First, make sure you have sed, gawk, cat, and cp

cd src

:: Create Makefile for Windows.
nmake -f Makefile.in prep-windows
if errorlevel 1 exit 1

:: Build the sources
nmake NODEBUG=1
if errorlevel 1 exit 1

:: Copy headers, libs, executables.
nmake install NODEBUG=1
if errorlevel 1 exit 1

Fix copy-and-pasta

Fix copy-and-pasta


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

:: FIXME (carbokuo) This script is migrated from bin/buck and bin/buck_common and still very incomplete.

@echo off
set ORIGINAL_WORKING_DIRECTORY=%cd%
set PROJECT_ROOT=%cd%
set BUCK_BIN_DIRECTORY=%~dp0
cd %BUCK_BIN_DIRECTORY%\..
set BUCK_DIRECTORY=%cd%
cd %ORIGINAL_WORKING_DIRECTORY%

set BUCKD_DIR=%PROJECT_ROOT%\.buckd
set BUCKD_LOG_FILE=%PROJECT_ROOT%\buckd.log
set BUCKD_PID_FILE=%PROJECT_ROOT%\buckd.pid
set BUCKD_PORT_FILE=%PROJECT_ROOT%\buckd.port
set BUCKD_RUNNING=0

if exist %PROJECT_ROOT%\.buckversion (
  if not exist %PROJECT_ROOT%\.nobuckcheck (
    set /p BUCK_REQUIRED_VERSION=<%PROJECT_ROOT%\.buckversion
    rem TODO checkout the required version
  )
)

set BUCK_REPOSITORY_DIRTY=0
set BUCK_CURRENT_VERSION=N/A
set BUCK_VERSION_TIMESTAMP=-1
set BUCK_GIT_DIRECTORY=%BUCK_DIRECTORY%\.git

:: The following commands are to retrieve output from external commands.
:: Because the second following command contains % (percent sign), it could not be executed in a for /f statement.
:: The workaround is to write the output of the command into a temp file and read it.
:: The name of the temp file contains a random number in order to avoid race condition.
set BUCK_VERSION_TIMESTAMP_TEMPFILE=%TEMP%\BUCK_VERSION_TIMESTAMP_%RANDOM%.tmp
if exist %BUCK_GIT_DIRECTORY% (
  for /f %%i in ('git --git-dir %BUCK_GIT_DIRECTORY% rev-parse HEAD') do set BUCK_CURRENT_VERSION=%%i
  git --git-dir %BUCK_GIT_DIRECTORY% log --pretty=format:%%ct -1 HEAD >%BUCK_VERSION_TIMESTAMP_TEMPFILE%
  set /p BUCK_VERSION_TIMESTAMP=<%BUCK_VERSION_TIMESTAMP_TEMPFILE%
)

set BUCK_VERSION_UID=N/A
:: TODO (carbokuo) Retrieve BUCK_VERSION_UID

:: Find python.exe defined in %PATH%. If not found, jython will be used instead.
if not defined PYTHON_INTERP (
  set PYTHON_INTERP=
  for %%e in (%PATHEXT%) do (
    for %%X in (python%%e) do (
      if not defined PYTHON_INTERP (
        set PYTHON_INTERP=%%~$PATH:X
      )
    )
  )
  if not defined PYTHON_INTERP (
    set PYTHON_INTERP=%BUCK_BIN_DIRECTORY%\jython.cmd
  )
)

:: Path to Python interpreter will be tried to find. If not found, Jython will be used.
set PYTHON_INTERP_FALLBACK=%BUCK_BIN_DIRECTORY%\jython.cmd

set RELATIVE_PATH_TO_BUCK_PY=src/com/facebook/buck/parser/buck.py
set PATH_TO_BUCK_PY=%BUCK_DIRECTORY%\%RELATIVE_PATH_TO_BUCK_PY%

set BUCK_JAVA_ARGS=^
-XX:MaxPermSize=256m ^
-Xmx1000m ^
-Djava.awt.headless=true ^
-Dbuck.testrunner_classes=%BUCK_DIRECTORY%\build\testrunner\classes ^
-Dbuck.abi_processor_classes=%BUCK_DIRECTORY%\build\abi_processor\classes ^
-Dbuck.path_to_emma_jar=%BUCK_DIRECTORY%\third-party\java\emma-2.0.5312\out\emma-2.0.5312.jar ^
-Dbuck.test_util_no_tests_dir=true ^
-Dbuck.path_to_python_interp=%PYTHON_INTERP_FALLBACK% ^
-Dbuck.path_to_buck_py=%PATH_TO_BUCK_PY% ^
-Dbuck.path_to_intellij_py=%BUCK_DIRECTORY%\src\com\facebook\buck\command\intellij.py ^
-Dbuck.git_commit=%BUCK_CURRENT_VERSION% ^
-Dbuck.git_commit_timestamp=%BUCK_VERSION_TIMESTAMP% ^
-Dbuck.git_dirty=%BUCK_REPOSITORY_DIRTY% ^
-Dbuck.version_uid=%BUCK_VERSION_UID% ^
-Dbuck.buckd_dir=%BUCKD_DIR% ^
-Dlog4j.configuration=file:%BUCK_DIRECTORY%\config\log4j.properties

set BUCK_JAVA_CLASSPATH=^
%BUCK_DIRECTORY%\src;^
%BUCK_DIRECTORY%\build\classes;^
%BUCK_DIRECTORY%\lib\args4j.jar;^
%BUCK_DIRECTORY%\lib\guava-14.0.1.jar;^
%BUCK_DIRECTORY%\lib\ini4j-0.5.2.jar;^
%BUCK_DIRECTORY%\lib\jackson-annotations-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-core-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-databind-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jsr305.jar;^
%BUCK_DIRECTORY%\lib\sdklib.jar;^
%BUCK_DIRECTORY%\lib\ddmlib-r21.jar;^
%BUCK_DIRECTORY%\lib\sdklib.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-cassandra-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-core-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-thrift-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-thrift-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-cli-1.1.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-codec-1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-lang-2.6.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\high-scale-lib-1.1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\joda-time-2.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\libthrift-0.7.0.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\log4j-1.2.16.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-api-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-log4j12-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\xz-java-1.3\xz-1.3.jar

java ^
  -classpath %BUCK_JAVA_CLASSPATH% ^
  %BUCK_JAVA_ARGS% ^
  -Dbuck.daemon=false ^
  com.facebook.buck.cli.Main ^
  %*

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

:: FIXME (carbokuo) This script is migrated from bin/buck and bin/buck_common and still very incomplete.

@echo off

:: Check %JAVA_HOME%
if "%JAVA_HOME%"=="" (
  echo Please have JDK 1.7 or higher installed and set environment variable %%JAVA_HOME%%.
  exit /b
)
:: Check java
set JAVA=%JAVA_HOME%\bin\java.exe
if not exist "%JAVA%" (
  echo java.exe not found under "%JAVA_HOME%\bin". Please check your environment variable %%JAVA_HOME%%.
  exit /b
)

set ORIGINAL_WORKING_DIRECTORY=%cd%
set PROJECT_ROOT=%cd%
set BUCK_BIN_DIRECTORY=%~dp0
cd %BUCK_BIN_DIRECTORY%\..
set BUCK_DIRECTORY=%cd%
cd %ORIGINAL_WORKING_DIRECTORY%

set BUCKD_DIR=%PROJECT_ROOT%\.buckd
set BUCKD_LOG_FILE=%PROJECT_ROOT%\buckd.log
set BUCKD_PID_FILE=%PROJECT_ROOT%\buckd.pid
set BUCKD_PORT_FILE=%PROJECT_ROOT%\buckd.port
set BUCKD_RUNNING=0

if exist "%PROJECT_ROOT%\.buckversion" (
  if not exist "%PROJECT_ROOT%\.nobuckcheck" (
    set /p BUCK_REQUIRED_VERSION=<%PROJECT_ROOT%\.buckversion
    rem TODO checkout the required version
  )
)

set BUCK_REPOSITORY_DIRTY=0
set BUCK_CURRENT_VERSION=N/A
set BUCK_VERSION_TIMESTAMP=-1
set BUCK_GIT_DIRECTORY=%BUCK_DIRECTORY%\.git

:: The following commands are to retrieve output from external commands.
:: Because the second following command contains % (percent sign), it could not be executed in a for /f statement.
:: The workaround is to write the output of the command into a temp file and read it.
:: The name of the temp file contains a random number in order to avoid race condition.
set BUCK_VERSION_TIMESTAMP_TEMPFILE=%TEMP%\BUCK_VERSION_TIMESTAMP_%RANDOM%.tmp
if exist "%BUCK_GIT_DIRECTORY%" (
  for /f %%i in ('git --git-dir %BUCK_GIT_DIRECTORY% rev-parse HEAD') do set BUCK_CURRENT_VERSION=%%i
  git --git-dir %BUCK_GIT_DIRECTORY% log --pretty=format:%%ct -1 HEAD >%BUCK_VERSION_TIMESTAMP_TEMPFILE%
  set /p BUCK_VERSION_TIMESTAMP=<%BUCK_VERSION_TIMESTAMP_TEMPFILE%
)

set BUCK_VERSION_UID=N/A
:: TODO (carbokuo) Retrieve BUCK_VERSION_UID

:: Find python.exe defined in %PATH%. If not found, jython will be used instead.
if not defined PYTHON_INTERP (
  set PYTHON_INTERP=
  for %%e in (%PATHEXT%) do (
    for %%X in (python%%e) do (
      if not defined PYTHON_INTERP (
        set PYTHON_INTERP=%%~$PATH:X
      )
    )
  )
  if not defined PYTHON_INTERP (
    set PYTHON_INTERP=%BUCK_BIN_DIRECTORY%\jython.cmd
  )
)

:: Path to Python interpreter will be tried to find. If not found, Jython will be used.
set PYTHON_INTERP_FALLBACK=%BUCK_BIN_DIRECTORY%\jython.cmd

set RELATIVE_PATH_TO_BUCK_PY=src/com/facebook/buck/parser/buck.py
set PATH_TO_BUCK_PY=%BUCK_DIRECTORY%\%RELATIVE_PATH_TO_BUCK_PY%

set BUCK_JAVA_ARGS=^
-XX:MaxPermSize=256m ^
-Xmx1000m ^
-Djava.awt.headless=true ^
-Dbuck.testrunner_classes=%BUCK_DIRECTORY%\build\testrunner\classes ^
-Dbuck.abi_processor_classes=%BUCK_DIRECTORY%\build\abi_processor\classes ^
-Dbuck.path_to_emma_jar=%BUCK_DIRECTORY%\third-party\java\emma-2.0.5312\out\emma-2.0.5312.jar ^
-Dbuck.test_util_no_tests_dir=true ^
-Dbuck.path_to_python_interp=%PYTHON_INTERP_FALLBACK% ^
-Dbuck.path_to_buck_py=%PATH_TO_BUCK_PY% ^
-Dbuck.path_to_intellij_py=%BUCK_DIRECTORY%\src\com\facebook\buck\command\intellij.py ^
-Dbuck.git_commit=%BUCK_CURRENT_VERSION% ^
-Dbuck.git_commit_timestamp=%BUCK_VERSION_TIMESTAMP% ^
-Dbuck.git_dirty=%BUCK_REPOSITORY_DIRTY% ^
-Dbuck.version_uid=%BUCK_VERSION_UID% ^
-Dbuck.buckd_dir=%BUCKD_DIR% ^
-Dlog4j.configuration=file:%BUCK_DIRECTORY%\config\log4j.properties

set BUCK_JAVA_CLASSPATH=^
%BUCK_DIRECTORY%\src;^
%BUCK_DIRECTORY%\build\classes;^
%BUCK_DIRECTORY%\lib\args4j.jar;^
%BUCK_DIRECTORY%\lib\guava-14.0.1.jar;^
%BUCK_DIRECTORY%\lib\ini4j-0.5.2.jar;^
%BUCK_DIRECTORY%\lib\jackson-annotations-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-core-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-databind-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jsr305.jar;^
%BUCK_DIRECTORY%\lib\sdklib.jar;^
%BUCK_DIRECTORY%\lib\ddmlib-r21.jar;^
%BUCK_DIRECTORY%\lib\sdklib.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-cassandra-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-core-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-thrift-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-thrift-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-cli-1.1.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-codec-1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-lang-2.6.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\high-scale-lib-1.1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\joda-time-2.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\libthrift-0.7.0.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\log4j-1.2.16.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-api-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-log4j12-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\xz-java-1.3\xz-1.3.jar

"%JAVA%" ^
  -classpath %BUCK_JAVA_CLASSPATH% ^
  %BUCK_JAVA_ARGS% ^
  -Dbuck.daemon=false ^
  com.facebook.buck.cli.Main ^
  %*

Check JDK existence in buck.cmd and find java.exe.

Summary:
By default, `java` points to `C:\Windows\System32\java.exe` which is not from JDK.
Buck needs `java.exe` from JDK to run (rather than JRE) because it invokes Java compiler.

Test Plan: Run `buck build targetname` on Windows.


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

:: FIXME (carbokuo) This script is migrated from bin/buck and bin/buck_common and still very incomplete.

@echo off

:: Check %JAVA_HOME%
if "%JAVA_HOME%"=="" (
  echo Please have JDK 1.7 or higher installed and set environment variable %%JAVA_HOME%%.
  exit /b
)
:: Check java
set JAVA=%JAVA_HOME%\bin\java.exe
if not exist "%JAVA%" (
  echo java.exe not found under "%JAVA_HOME%\bin". Please check your environment variable %%JAVA_HOME%%.
  exit /b
)

set ORIGINAL_WORKING_DIRECTORY=%cd%
set PROJECT_ROOT=%cd%
set BUCK_BIN_DIRECTORY=%~dp0
cd %BUCK_BIN_DIRECTORY%\..
set BUCK_DIRECTORY=%cd%
cd %ORIGINAL_WORKING_DIRECTORY%

set BUCKD_DIR=%PROJECT_ROOT%\.buckd
set BUCKD_LOG_FILE=%PROJECT_ROOT%\buckd.log
set BUCKD_PID_FILE=%PROJECT_ROOT%\buckd.pid
set BUCKD_PORT_FILE=%PROJECT_ROOT%\buckd.port
set BUCKD_RUNNING=0

if exist "%PROJECT_ROOT%\.buckversion" (
  if not exist "%PROJECT_ROOT%\.nobuckcheck" (
    set /p BUCK_REQUIRED_VERSION=<%PROJECT_ROOT%\.buckversion
    rem TODO checkout the required version
  )
)

set BUCK_REPOSITORY_DIRTY=0
set BUCK_CURRENT_VERSION=N/A
set BUCK_VERSION_TIMESTAMP=-1
set BUCK_GIT_DIRECTORY=%BUCK_DIRECTORY%\.git

:: The following commands are to retrieve output from external commands.
:: Because the second following command contains % (percent sign), it could not be executed in a for /f statement.
:: The workaround is to write the output of the command into a temp file and read it.
:: The name of the temp file contains a random number in order to avoid race condition.
set BUCK_VERSION_TIMESTAMP_TEMPFILE=%TEMP%\BUCK_VERSION_TIMESTAMP_%RANDOM%.tmp
if exist "%BUCK_GIT_DIRECTORY%" (
  for /f %%i in ('git --git-dir %BUCK_GIT_DIRECTORY% rev-parse HEAD') do set BUCK_CURRENT_VERSION=%%i
  git --git-dir %BUCK_GIT_DIRECTORY% log --pretty=format:%%ct -1 HEAD >%BUCK_VERSION_TIMESTAMP_TEMPFILE%
  set /p BUCK_VERSION_TIMESTAMP=<%BUCK_VERSION_TIMESTAMP_TEMPFILE%
)

set BUCK_VERSION_UID=N/A
:: TODO (carbokuo) Retrieve BUCK_VERSION_UID

:: Path to Python interpreter will be tried to find. If not found, Jython will be used.
set PYTHON_INTERP_FALLBACK=%BUCK_BIN_DIRECTORY%\jython.cmd

set RELATIVE_PATH_TO_BUCK_PY=src/com/facebook/buck/parser/buck.py
set PATH_TO_BUCK_PY=%BUCK_DIRECTORY%\%RELATIVE_PATH_TO_BUCK_PY%

set BUCK_JAVA_ARGS=^
-XX:MaxPermSize=256m ^
-Xmx1000m ^
-Djava.awt.headless=true ^
-Dbuck.testrunner_classes=%BUCK_DIRECTORY%\build\testrunner\classes ^
-Dbuck.abi_processor_classes=%BUCK_DIRECTORY%\build\abi_processor\classes ^
-Dbuck.path_to_emma_jar=%BUCK_DIRECTORY%\third-party\java\emma-2.0.5312\out\emma-2.0.5312.jar ^
-Dbuck.test_util_no_tests_dir=true ^
-Dbuck.path_to_python_interp=%PYTHON_INTERP_FALLBACK% ^
-Dbuck.path_to_buck_py=%PATH_TO_BUCK_PY% ^
-Dbuck.path_to_intellij_py=%BUCK_DIRECTORY%\src\com\facebook\buck\command\intellij.py ^
-Dbuck.git_commit=%BUCK_CURRENT_VERSION% ^
-Dbuck.git_commit_timestamp=%BUCK_VERSION_TIMESTAMP% ^
-Dbuck.git_dirty=%BUCK_REPOSITORY_DIRTY% ^
-Dbuck.version_uid=%BUCK_VERSION_UID% ^
-Dbuck.buckd_dir=%BUCKD_DIR% ^
-Dlog4j.configuration=file:%BUCK_DIRECTORY%\config\log4j.properties

set BUCK_JAVA_CLASSPATH=^
%BUCK_DIRECTORY%\src;^
%BUCK_DIRECTORY%\build\classes;^
%BUCK_DIRECTORY%\lib\args4j-2.0.26.jar;^
%BUCK_DIRECTORY%\lib\guava-15.0.jar;^
%BUCK_DIRECTORY%\lib\ini4j-0.5.2.jar;^
%BUCK_DIRECTORY%\lib\jackson-annotations-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-core-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-databind-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jsr305.jar;^
%BUCK_DIRECTORY%\lib\sdklib.jar;^
%BUCK_DIRECTORY%\lib\ddmlib-r21.jar;^
%BUCK_DIRECTORY%\lib\sdklib.jar;^
%BUCK_DIRECTORY%\third-party\java\asm\asm-debug-all-4.1.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-cassandra-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-core-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-thrift-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-thrift-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-cli-1.1.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-codec-1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-lang-2.6.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\high-scale-lib-1.1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\joda-time-2.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\libthrift-0.7.0.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\log4j-1.2.16.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-api-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-log4j12-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\jetty\jetty-all-9.0.4.v20130625.jar;^
%BUCK_DIRECTORY%\third-party\java\jetty\servlet-api.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\geronimo-jta_1.1_spec-1.1.1.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\lucene-core-3.6.2.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\neo4j-kernel-2.0.0-M05.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\neo4j-lucene-index-2.0.0-M05.jar;^
%BUCK_DIRECTORY%\third-party\java\xz-java-1.3\xz-1.3.jar

"%JAVA%" ^
  -classpath %BUCK_JAVA_CLASSPATH% ^
  %BUCK_JAVA_ARGS% ^
  -Dbuck.daemon=false ^
  com.facebook.buck.cli.Main ^
  %*

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

:: FIXME (carbokuo) This script is migrated from bin/buck and bin/buck_common and still very incomplete.

@echo off

:: Check %JAVA_HOME%
if "%JAVA_HOME%"=="" (
  echo Please have JDK 1.7 or higher installed and set environment variable %%JAVA_HOME%%.
  exit /b
)
:: Check java
set JAVA=%JAVA_HOME%\bin\java.exe
if not exist "%JAVA%" (
  echo java.exe not found under "%JAVA_HOME%\bin". Please check your environment variable %%JAVA_HOME%%.
  exit /b
)

set ORIGINAL_WORKING_DIRECTORY=%cd%
set PROJECT_ROOT=%cd%
set BUCK_BIN_DIRECTORY=%~dp0
cd %BUCK_BIN_DIRECTORY%\..
set BUCK_DIRECTORY=%cd%
cd %ORIGINAL_WORKING_DIRECTORY%

set BUCKD_DIR=%PROJECT_ROOT%\.buckd
set BUCKD_LOG_FILE=%PROJECT_ROOT%\buckd.log
set BUCKD_PID_FILE=%PROJECT_ROOT%\buckd.pid
set BUCKD_PORT_FILE=%PROJECT_ROOT%\buckd.port
set BUCKD_RUNNING=0

if exist "%PROJECT_ROOT%\.buckversion" (
  if not exist "%PROJECT_ROOT%\.nobuckcheck" (
    set /p BUCK_REQUIRED_VERSION=<%PROJECT_ROOT%\.buckversion
    rem TODO checkout the required version
  )
)

set BUCK_REPOSITORY_DIRTY=0
set BUCK_CURRENT_VERSION=N/A
set BUCK_VERSION_TIMESTAMP=-1
set BUCK_GIT_DIRECTORY=%BUCK_DIRECTORY%\.git

:: The following commands are to retrieve output from external commands.
:: Because the second following command contains % (percent sign), it could not be executed in a for /f statement.
:: The workaround is to write the output of the command into a temp file and read it.
:: The name of the temp file contains a random number in order to avoid race condition.
set BUCK_VERSION_TIMESTAMP_TEMPFILE=%TEMP%\BUCK_VERSION_TIMESTAMP_%RANDOM%.tmp
if exist "%BUCK_GIT_DIRECTORY%" (
  for /f %%i in ('git --git-dir %BUCK_GIT_DIRECTORY% rev-parse HEAD') do set BUCK_CURRENT_VERSION=%%i
  git --git-dir %BUCK_GIT_DIRECTORY% log --pretty=format:%%ct -1 HEAD >%BUCK_VERSION_TIMESTAMP_TEMPFILE%
  set /p BUCK_VERSION_TIMESTAMP=<%BUCK_VERSION_TIMESTAMP_TEMPFILE%
)

set BUCK_VERSION_UID=N/A
:: TODO (carbokuo) Retrieve BUCK_VERSION_UID

:: Path to Python interpreter will be tried to find. If not found, Jython will be used.
set PYTHON_INTERP_FALLBACK=%BUCK_BIN_DIRECTORY%\jython.cmd

set RELATIVE_PATH_TO_BUCK_PY=src/com/facebook/buck/parser/buck.py
set PATH_TO_BUCK_PY=%BUCK_DIRECTORY%\%RELATIVE_PATH_TO_BUCK_PY%

set BUCK_JAVA_ARGS=^
-XX:MaxPermSize=256m ^
-Xmx1000m ^
-Djava.awt.headless=true ^
-Dbuck.testrunner_classes=%BUCK_DIRECTORY%\build\testrunner\classes ^
-Dbuck.abi_processor_classes=%BUCK_DIRECTORY%\build\abi_processor\classes ^
-Dbuck.path_to_emma_jar=%BUCK_DIRECTORY%\third-party\java\emma-2.0.5312\out\emma-2.0.5312.jar ^
-Dbuck.test_util_no_tests_dir=true ^
-Dbuck.path_to_python_interp=%PYTHON_INTERP_FALLBACK% ^
-Dbuck.path_to_buck_py=%PATH_TO_BUCK_PY% ^
-Dbuck.path_to_intellij_py=%BUCK_DIRECTORY%\src\com\facebook\buck\command\intellij.py ^
-Dbuck.git_commit=%BUCK_CURRENT_VERSION% ^
-Dbuck.git_commit_timestamp=%BUCK_VERSION_TIMESTAMP% ^
-Dbuck.git_dirty=%BUCK_REPOSITORY_DIRTY% ^
-Dbuck.quickstart_origin_dir=%BUCK_DIRECTORY%\src\com\facebook\buck\cli\quickstart\android ^
-Dbuck.version_uid=%BUCK_VERSION_UID% ^
-Dbuck.buckd_dir=%BUCKD_DIR% ^
-Dlog4j.configuration=file:%BUCK_DIRECTORY%\config\log4j.properties

set BUCK_JAVA_CLASSPATH=^
%BUCK_DIRECTORY%\src;^
%BUCK_DIRECTORY%\build\classes;^
%BUCK_DIRECTORY%\lib\args4j-2.0.26.jar;^
%BUCK_DIRECTORY%\lib\ddmlib-r21.jar;^
%BUCK_DIRECTORY%\lib\guava-15.0.jar;^
%BUCK_DIRECTORY%\lib\ini4j-0.5.2.jar;^
%BUCK_DIRECTORY%\lib\jackson-annotations-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-core-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jackson-databind-2.0.5.jar;^
%BUCK_DIRECTORY%\lib\jsr305.jar;^
%BUCK_DIRECTORY%\lib\nailgun-server-0.9.2-SNAPSHOT.jar;^
%BUCK_DIRECTORY%\lib\sdklib.jar;^
%BUCK_DIRECTORY%\third-party\java\asm\asm-debug-all-4.1.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-cassandra-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-core-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\astyanax-thrift-1.56.38.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\cassandra-thrift-1.2.3.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-cli-1.1.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-codec-1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\commons-lang-2.6.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\high-scale-lib-1.1.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\joda-time-2.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\libthrift-0.7.0.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\log4j-1.2.16.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-api-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\astyanax\slf4j-log4j12-1.7.2.jar;^
%BUCK_DIRECTORY%\third-party\java\gson\gson-2.2.4.jar;^
%BUCK_DIRECTORY%\third-party\java\jetty\jetty-all-9.0.4.v20130625.jar;^
%BUCK_DIRECTORY%\third-party\java\jetty\servlet-api.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\geronimo-jta_1.1_spec-1.1.1.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\lucene-core-3.6.2.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\neo4j-kernel-2.0.0-M05.jar;^
%BUCK_DIRECTORY%\third-party\java\neo4j\neo4j-lucene-index-2.0.0-M05.jar;^
%BUCK_DIRECTORY%\third-party\java\xz-java-1.3\xz-1.3.jar

"%JAVA%" ^
  -classpath %BUCK_JAVA_CLASSPATH% ^
  %BUCK_JAVA_ARGS% ^
  -Dbuck.daemon=false ^
  com.facebook.buck.cli.Main ^
  %*

Update bin/buck.cmd which has fallen behind bin/buck_common.

Test Plan: Ran Buck on Windows 7.


@REM
@REM Copyright (c) 2012 - 2016 YCSB contributors. All rights reserved.
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License"); you
@REM may not use this file except in compliance with the License. You
@REM may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
@REM implied. See the License for the specific language governing
@REM permissions and limitations under the License. See accompanying
@REM LICENSE file.
@REM
@REM -----------------------------------------------------------------------
@REM Control Script for YCSB
@REM
@REM Environment Variable Prerequisites
@REM
@REM   Do not set the variables in this script. Instead put them into a script
@REM   setenv.sh in YCSB_HOME/bin to keep your customizations separate.
@REM
@REM   YCSB_HOME       (Optional) YCSB installation directory.  If not set
@REM                   this script will use the parent directory of where this
@REM                   script is run from.
@REM
@REM   JAVA_HOME       (Required) Must point at your Java Development Kit
@REM                   or Java Runtime Environment installation.
@REM
@REM   JAVA_OPTS       (Optional) Java runtime options used when any command
@REM                   is executed.
@REM
@REM   WARNING!!! YCSB home must be located in a directory path that doesn't
@REM   contain spaces.
@REM

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

@REM Only set YCSB_HOME if not already set
PUSHD %~dp0..
IF NOT DEFINED YCSB_HOME SET YCSB_HOME=%CD%
POPD

@REM Ensure that any extra CLASSPATH variables are set via setenv.bat
SET CLASSPATH=

@REM Pull in customization options
if exist "%YCSB_HOME%\bin\setenv.bat" call "%YCSB_HOME%\bin\setenv.bat"

@REM Check if we have a usable JDK
IF "%JAVA_HOME%." == "." GOTO noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
GOTO okJava
:noJavaHome
ECHO The JAVA_HOME environment variable is not defined correctly.
GOTO exit
:okJava

@REM Determine YCSB command argument
IF NOT "load" == "%1" GOTO noload
SET YCSB_COMMAND=-load
SET YCSB_CLASS=com.yahoo.ycsb.Client
GOTO gotCommand
:noload
IF NOT "run" == "%1" GOTO noRun
SET YCSB_COMMAND=-t
SET YCSB_CLASS=com.yahoo.ycsb.Client
GOTO gotCommand
:noRun
IF NOT "shell" == "%1" GOTO noShell
SET YCSB_COMMAND=
SET YCSB_CLASS=com.yahoo.ycsb.CommandLine
GOTO gotCommand
:noShell
ECHO [ERROR] Found unknown command '%1'
ECHO [ERROR] Expected one of 'load', 'run', or 'shell'. Exiting.
GOTO exit
:gotCommand

@REM Find binding information
FOR /F "delims=" %%G in (
  'FINDSTR /B "%2:" %YCSB_HOME%\bin\bindings.properties'
) DO SET "BINDING_LINE=%%G"

IF NOT "%BINDING_LINE%." == "." GOTO gotBindingLine
ECHO [ERROR] The specified binding '%2' was not found.  Exiting.
GOTO exit
:gotBindingLine

@REM Pull out binding name and class
FOR /F "tokens=1-2 delims=:" %%G IN ("%BINDING_LINE%") DO (
  SET BINDING_NAME=%%G
  SET BINDING_CLASS=%%H
)

@REM Some bindings have multiple versions that are managed in the same
@REM directory.
@REM   They are noted with a '-' after the binding name.
@REM   (e.g. cassandra-7 & cassandra-8)
FOR /F "tokens=1 delims=-" %%G IN ("%BINDING_NAME%") DO (
  SET BINDING_DIR=%%G
)

@REM The 'basic' binding is core functionality
IF NOT "%BINDING_NAME%" == "basic" GOTO noBasic
SET BINDING_DIR=core
:noBasic

@REM Add Top level conf to classpath
IF "%CLASSPATH%." == "." GOTO emptyClasspath
SET CLASSPATH=%CLASSPATH%;%YCSB_HOME%\conf
GOTO confAdded
:emptyClasspath
SET CLASSPATH=%YCSB_HOME%\conf
:confAdded

@REM Build classpath according to source checkout or release distribution
IF EXIST "%YCSB_HOME%\pom.xml" GOTO gotRelease

@REM Core libraries
FOR %%F IN (%YCSB_HOME%\lib\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database conf dir
IF NOT EXIST "%YCSB_HOME%\%BINDING_DIR%-binding\conf" GOTO noBindingConf
set CLASSPATH=%CLASSPATH%;%YCSB_HOME%\%BINDING_DIR%-binding\conf
:noBindingConf

@REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%-binding\lib\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)
GOTO classpathComplete

:gotRelease
@REM Core libraries
FOR %%F IN (%YCSB_HOME%\core\target\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database conf (need to find because location is not consistent)
FOR /D /R %YCSB_HOME%\%BINDING_DIR% %%F IN (*) DO (
  IF "%%~nxF" == "conf" SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database dependency libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\dependency\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

:classpathComplete

@REM Cassandra deprecation message
IF NOT "%BINDING_DIR%" == "cassandra" GOTO notOldCassandra
echo [WARN] The 'cassandra-7', 'cassandra-8', 'cassandra-10', and cassandra-cql' clients are deprecated. If you are using Cassandra 2.X try using the 'cassandra2-cql' client instead.
:notOldCassandra

@REM Get the rest of the arguments, skipping the first 2
FOR /F "tokens=2*" %%G IN ("%*") DO (
  SET YCSB_ARGS=%%H
)

@REM Run YCSB
@ECHO ON
"%JAVA_HOME%\bin\java.exe" %JAVA_OPTS% -classpath "%CLASSPATH%" %YCSB_CLASS% %YCSB_COMMAND% -db %BINDING_CLASS% %YCSB_ARGS%
@ECHO OFF

GOTO end

:exit
EXIT /B 1;

:end

@REM
@REM Copyright (c) 2012 - 2016 YCSB contributors. All rights reserved.
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License"); you
@REM may not use this file except in compliance with the License. You
@REM may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
@REM implied. See the License for the specific language governing
@REM permissions and limitations under the License. See accompanying
@REM LICENSE file.
@REM
@REM -----------------------------------------------------------------------
@REM Control Script for YCSB
@REM
@REM Environment Variable Prerequisites
@REM
@REM   Do not set the variables in this script. Instead put them into a script
@REM   setenv.sh in YCSB_HOME/bin to keep your customizations separate.
@REM
@REM   YCSB_HOME       (Optional) YCSB installation directory.  If not set
@REM                   this script will use the parent directory of where this
@REM                   script is run from.
@REM
@REM   JAVA_HOME       (Required) Must point at your Java Development Kit
@REM                   or Java Runtime Environment installation.
@REM
@REM   JAVA_OPTS       (Optional) Java runtime options used when any command
@REM                   is executed.
@REM
@REM   WARNING!!! YCSB home must be located in a directory path that doesn't
@REM   contain spaces.
@REM

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

@REM Only set YCSB_HOME if not already set
PUSHD %~dp0..
IF NOT DEFINED YCSB_HOME SET YCSB_HOME=%CD%
POPD

@REM Ensure that any extra CLASSPATH variables are set via setenv.bat
SET CLASSPATH=

@REM Pull in customization options
if exist "%YCSB_HOME%\bin\setenv.bat" call "%YCSB_HOME%\bin\setenv.bat"

@REM Check if we have a usable JDK
IF "%JAVA_HOME%." == "." GOTO noJavaHome
IF NOT EXIST "%JAVA_HOME%\bin\java.exe" GOTO noJavaHome
GOTO okJava
:noJavaHome
ECHO The JAVA_HOME environment variable is not defined correctly.
GOTO exit
:okJava

@REM Determine YCSB command argument
IF NOT "load" == "%1" GOTO noload
SET YCSB_COMMAND=-load
SET YCSB_CLASS=com.yahoo.ycsb.Client
GOTO gotCommand
:noload
IF NOT "run" == "%1" GOTO noRun
SET YCSB_COMMAND=-t
SET YCSB_CLASS=com.yahoo.ycsb.Client
GOTO gotCommand
:noRun
IF NOT "shell" == "%1" GOTO noShell
SET YCSB_COMMAND=
SET YCSB_CLASS=com.yahoo.ycsb.CommandLine
GOTO gotCommand
:noShell
ECHO [ERROR] Found unknown command '%1'
ECHO [ERROR] Expected one of 'load', 'run', or 'shell'. Exiting.
GOTO exit
:gotCommand

@REM Find binding information
FOR /F "delims=" %%G in (
  'FINDSTR /B "%2:" %YCSB_HOME%\bin\bindings.properties'
) DO SET "BINDING_LINE=%%G"

IF NOT "%BINDING_LINE%." == "." GOTO gotBindingLine
ECHO [ERROR] The specified binding '%2' was not found.  Exiting.
GOTO exit
:gotBindingLine

@REM Pull out binding name and class
FOR /F "tokens=1-2 delims=:" %%G IN ("%BINDING_LINE%") DO (
  SET BINDING_NAME=%%G
  SET BINDING_CLASS=%%H
)

@REM Some bindings have multiple versions that are managed in the same
@REM directory.
@REM   They are noted with a '-' after the binding name.
@REM   (e.g. cassandra-7 & cassandra-8)
FOR /F "tokens=1 delims=-" %%G IN ("%BINDING_NAME%") DO (
  SET BINDING_DIR=%%G
)

@REM The 'basic' binding is core functionality
IF NOT "%BINDING_NAME%" == "basic" GOTO noBasic
SET BINDING_DIR=core
:noBasic

@REM Add Top level conf to classpath
IF "%CLASSPATH%." == "." GOTO emptyClasspath
SET CLASSPATH=%CLASSPATH%;%YCSB_HOME%\conf
GOTO confAdded
:emptyClasspath
SET CLASSPATH=%YCSB_HOME%\conf
:confAdded

@REM Build classpath according to source checkout or release distribution
IF EXIST "%YCSB_HOME%\pom.xml" GOTO gotSource

@REM Core libraries
FOR %%F IN (%YCSB_HOME%\lib\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database conf dir
IF NOT EXIST "%YCSB_HOME%\%BINDING_DIR%-binding\conf" GOTO noBindingConf
set CLASSPATH=%CLASSPATH%;%YCSB_HOME%\%BINDING_DIR%-binding\conf
:noBindingConf

@REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%-binding\lib\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)
GOTO classpathComplete

:gotSource
@REM Check for some basic libraries to see if the source has been built.
IF EXIST "%YCSB_HOME%\%BINDING_DIR%\target\*.jar" GOTO gotJars

@REM Call mvn to build source checkout.
IF "%BINDING_NAME%" == "basic" GOTO buildCore
SET MVN_PROJECT=%BINDING_DIR%-binding
goto gotMvnProject
:buildCore
SET MVN_PROJECT=core
:gotMvnProject

ECHO [WARN] YCSB libraries not found.  Attempting to build...
CALL mvn -pl com.yahoo.ycsb:%MVN_PROJECT% -am package -DskipTests
IF %ERRORLEVEL% NEQ 0 (
  ECHO [ERROR] Error trying to build project. Exiting.
  GOTO exit
)

:gotJars
@REM Core libraries
FOR %%F IN (%YCSB_HOME%\core\target\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database conf (need to find because location is not consistent)
FOR /D /R %YCSB_HOME%\%BINDING_DIR% %%F IN (*) DO (
  IF "%%~nxF" == "conf" SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

@REM Database dependency libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\dependency\*.jar) DO (
  SET CLASSPATH=!CLASSPATH!;%%F%
)

:classpathComplete

@REM Cassandra deprecation message
IF NOT "%BINDING_DIR%" == "cassandra" GOTO notOldCassandra
echo [WARN] The 'cassandra-7', 'cassandra-8', 'cassandra-10', and cassandra-cql' clients are deprecated. If you are using Cassandra 2.X try using the 'cassandra2-cql' client instead.
:notOldCassandra

@REM Get the rest of the arguments, skipping the first 2
FOR /F "tokens=2*" %%G IN ("%*") DO (
  SET YCSB_ARGS=%%H
)

@REM Run YCSB
@ECHO ON
"%JAVA_HOME%\bin\java.exe" %JAVA_OPTS% -classpath "%CLASSPATH%" %YCSB_CLASS% %YCSB_COMMAND% -db %BINDING_CLASS% %YCSB_ARGS%
@ECHO OFF

GOTO end

:exit
EXIT /B 1;

:end

[scripts] Add mvn build if necessary for source checkout on windows.  Plus a couple other fixups to make consistent with the linux script.