::
:: Build the installer for RBTools for Windows.
::
:: This will fetch Python and build a WiX package for RBTools.
::
:: This requires that curl for Windows (and its ca-bundle) are properly
:: installed and working in order to download files.
::
@echo off
setlocal

::-------------------------------------------------------------------------
:: Build paths
::-------------------------------------------------------------------------

:: Store out the absolute path to the tree root.
pushd ..\..\..
set TREE_ROOT=%CD%
popd

set BUILD_DEST=%TREE_ROOT%\dist
set BUILD_BASE=%TREE_ROOT%\build\windows-pkg
set BUILD_ROOT=%BUILD_BASE%\build
set BUILD_ROOT_X86=%BUILD_BASE%\build\x86
set BUILD_ROOT_X64=%BUILD_BASE%\build\x64
set BUILD_STAGE=%BUILD_BASE%\stage
set DEPS_DIR=%BUILD_BASE%\deps

::-------------------------------------------------------------------------
:: Dependencies
::-------------------------------------------------------------------------
set PYTHON_VERSION=3.8.10

set PYTHON_X86_FILENAME=python-%PYTHON_VERSION%.exe
set PYTHON_X86_URL=https://www.python.org/ftp/python/%PYTHON_VERSION%/%PYTHON_X86_FILENAME%
set PYTHON_X86_MD5=b355cfc84b681ace8908ae50908e8761
set PYTHON_X86_DEP=%DEPS_DIR%\python-%PYTHON_VERSION%-x86

set PYTHON_X64_FILENAME=python-%PYTHON_VERSION%-amd64.exe
set PYTHON_X64_URL=https://www.python.org/ftp/python/%PYTHON_VERSION%/%PYTHON_X64_FILENAME%
set PYTHON_X64_MD5=62cf1a12a5276b0259e8761d4cf4fe42
set PYTHON_X64_DEP=%DEPS_DIR%\python-%PYTHON_VERSION%-x64

::-------------------------------------------------------------------------
:: Binaries
::-------------------------------------------------------------------------
set BUNDLED_PYTHON_X86_DIR=%BUILD_ROOT_X86%\Python
set BUNDLED_PYTHON_X86=%BUNDLED_PYTHON_X86_DIR%\python.exe

set BUNDLED_PYTHON_X64_DIR=%BUILD_ROOT_X64%\Python
set BUNDLED_PYTHON_X64=%BUNDLED_PYTHON_X64_DIR%\python.exe

call :SetMSBuildPath || goto :Abort

::-------------------------------------------------------------------------
:: Signing certificate
::-------------------------------------------------------------------------
set CERT_THUMBPRINT=deee311acc700a6f797018a6cf4075131b6f7198

::-------------------------------------------------------------------------
:: Begin the installation process
::-------------------------------------------------------------------------
if not exist "%DEPS_DIR%" mkdir "%DEPS_DIR%"
if not exist "%BUILD_STAGE%" mkdir "%BUILD_STAGE%"

call :InstallPython ^
    x86 %PYTHON_X86_DEP% %PYTHON_X86_FILENAME% ^
    %PYTHON_X86_URL% %PYTHON_X86_MD5% ^
    || goto :Abort

call :InstallPython ^
    x64 %PYTHON_X64_DEP% %PYTHON_X64_FILENAME% ^
    %PYTHON_X64_URL% %PYTHON_X64_MD5% ^
    || goto :Abort

call :CreateBuildDirectory || goto :Abort
call :InstallPackages || goto :Abort
call :InstallRBTools || goto :Abort
call :RemoveUnwantedFiles || goto :Abort
call :BuildInstaller || goto :Abort

echo Done.

goto :EOF

::-------------------------------------------------------------------------
:: Installs Python
::-------------------------------------------------------------------------
:InstallPython arch dep_path python_filename url md5
setlocal

set _arch=%~1
set _dep_path=%~2
set _python_filename=%~3
set _url=%~4
set _md5=%~5

echo.
echo == Installing Python [%_arch%] ==

set _PYTHON_INSTALLER=%TEMP%\%_python_filename%

if not exist "%_dep_path%" (
    if not exist "%_PYTHON_INSTALLER%" (
        echo Preparing to download Python v%PYTHON_VERSION% [%_arch%]...
        call :DownloadAndVerify %_url% "%_PYTHON_INSTALLER%" %_md5% ^
            || exit /B 1

        echo Downloaded to %_PYTHON_INSTALLER%
    )

    echo Running the installer [%_arch%]...
    "%_PYTHON_INSTALLER%" /quiet ^
        AssociateFiles=0 Include_doc=0 Include_debug=0 Include_launcher=0 ^
        Include_tcltk=0 Include_test=0 InstallAllUsers=0 ^
        InstallLauncherAllUsers=0 Shortcuts=0 SimpleInstall=1 ^
		SimpleInstallDescription="Python for RBTools for Windows" ^
		TargetDir="%_dep_path%-temp"
    xcopy /EYI "%_dep_path%-temp" "%_dep_path%"

    :: Remove the old install from the temp directory, and clean up the
    :: registry files so future installs aren't impacted.
    "%_PYTHON_INSTALLER%" /quiet /uninstall
)

goto :EOF

::-------------------------------------------------------------------------
:: Populates the build directory from dependencies
::-------------------------------------------------------------------------
:CreateBuildDirectory
setlocal

:: Create a copy of the Python directory. This is where we'll be installing
:: RBTools and dependencies, and what we'll actually be distributing.
echo.
echo == Creating build directory ==

call :DeleteIfExists "%BUILD_ROOT%"
xcopy /EYI "%PYTHON_X86_DEP%" "%BUNDLED_PYTHON_X86_DIR%" >NUL
xcopy /EYI "%PYTHON_X64_DEP%" "%BUNDLED_PYTHON_X64_DIR%" >NUL

goto :EOF

::-------------------------------------------------------------------------
:: Install package tools
::-------------------------------------------------------------------------
:InstallPackages
setlocal

echo.
echo == Installing pip and setuptools ==
echo.
echo --------------------------- [Install log] ---------------------------

pushd %TREE_ROOT%

:: Install packages for 32-bit packages.
"%BUNDLED_PYTHON_X86%" -m ensurepip --upgrade

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

"%BUNDLED_PYTHON_X86%" -m pip install -U pip setuptools

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

:: Install packages for 64-bit packages.
"%BUNDLED_PYTHON_X64%" -m ensurepip --upgrade

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

"%BUNDLED_PYTHON_X64%" -m pip install -U pip setuptools

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

popd

echo ---------------------------------------------------------------------

goto :EOF

::-------------------------------------------------------------------------
:: Install RBTools and all dependencies
::-------------------------------------------------------------------------
:InstallRBTools
setlocal

echo.
echo == Installing RBTools and dependencies ==
echo.
echo --------------------------- [Install log] ---------------------------

pushd %TREE_ROOT%

:: Build for 32-bit Python.
"%BUNDLED_PYTHON_X86%" setup.py release install >NUL

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

:: Build for 64-bit Python.
"%BUNDLED_PYTHON_X64%" setup.py release install >NUL

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

popd

echo ---------------------------------------------------------------------

goto :EOF

::-------------------------------------------------------------------------
:: Remove unwanted files from the build directory.
::-------------------------------------------------------------------------
:RemoveUnwantedFiles
setlocal

echo.
echo == Removing unwanted files ==

call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\Doc"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\tcl"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\Tools"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\%PYTHON_X86_FILENAME%"

call :DeleteIfExists "%BUNDLED_PYTHON_X64_DIR%\Doc"
call :DeleteIfExists "%BUNDLED_PYTHON_X64_DIR%\tcl"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\Tools"
call :DeleteIfExists "%BUNDLED_PYTHON_X64_DIR%\%PYTHON_X64_FILENAME%"

echo == Files removed ==

goto :EOF

::-------------------------------------------------------------------------
:: Build the installer
::-------------------------------------------------------------------------
:BuildInstaller
setlocal

call :GetRBToolsVersion
set _rbtools_version=%_return1%

set _wix_path=%CD%\wix
set _sln_file=%_wix_path%\rbtools.sln
set _timestamp_url=http://timestamp.comodoca.com/authenticode

echo.
echo == Building the RBTools installer [x86] ==

%MSBUILD% ^
    /p:Version="%_rbtools_version%" ^
    /p:Platform=x86 ^
    /p:ExeSuffix=-32bit ^
    /p:Root="%BUILD_ROOT_X86%" ^
    /p:OutputPath="%BUILD_STAGE%\\" ^
    /p:SourcePath="%_wix_path%" ^
    /p:CertificateThumbprint=%CERT_THUMBPRINT% ^
    /p:TimestampUrl=%_timestamp_url% ^
    "%_sln_file%"

if ERRORLEVEL 1 exit /B 1

echo.
echo == Building the RBTools installer [x64] ==

%MSBUILD% ^
    /p:Version="%_rbtools_version%" ^
    /p:Platform=x64 ^
    /p:ExeSuffix=-64bit ^
    /p:Root="%BUILD_ROOT_X64%" ^
    /p:OutputPath="%BUILD_STAGE%\\" ^
    /p:SourcePath="%_wix_path%" ^
    /p:CertificateThumbprint=%CERT_THUMBPRINT% ^
    /p:TimestampUrl=%_timestamp_url% ^
    "%_sln_file%"

if ERRORLEVEL 1 exit /B 1

mkdir "%BUILD_DEST%" 2>&1
dir "%BUILD_STAGE%" /S
copy "%BUILD_STAGE%\RBTools-%_rbtools_version%*.exe" "%BUILD_DEST%" >NUL

echo Installers published to %BUILD_DEST%

goto :EOF

::-------------------------------------------------------------------------
:: Returns the Python version for RBTools.
::
:: This must be run after installing RBTools in %BUILD_ROOT%.
::-------------------------------------------------------------------------
:GetRBToolsVersion
setlocal

set _version_file=%BUILD_STAGE%\VERSION

"%BUNDLED_PYTHON_X64%" scripts/get-version.py > "%_version_file%"
set /P _version= < "%_version_file%"
del "%_version_file%"

endlocal & set _return1=%_version%
goto :EOF

::-------------------------------------------------------------------------
:: Determines the path to MSBuild.exe
::-------------------------------------------------------------------------
:SetMSBuildPath
setlocal

set _reg_key=HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
set _reg_query_cmd=reg.exe query "%_reg_key%" /V MSBuildToolsPath

%_reg_query_cmd% >NUL 2>&1

if ERRORLEVEL 1 (
    echo Cannot obtain the MSBuild tools path from the registry.
    exit /B 1
)

for /f "skip=2 tokens=2,*" %%A in ('%_reg_query_cmd%') do (
    SET MSBUILDDIR=%%B
)

if not exist %MSBUILDDIR%nul (
    echo The MSBuild tools path from the registry does not exist.
    echo
    echo The missing path is: %MSBUILDDIR%
    exit /B 1
)

if not exist %MSBUILDDIR%msbuild.exe (
    echo MSBuild.exe is missing from %MSBUILDDIR%.
    exit /B 1
)

endlocal & set MSBUILD=%MSBUILDDIR%msbuild.exe
goto :EOF

::-------------------------------------------------------------------------
:: Downloads and verifies a file from a URL.
::-------------------------------------------------------------------------
:DownloadAndVerify url dest expected_hash
setlocal

set _url=%~1
set _dest=%~2
set _expected_hash=%~3

if not exist "%_dest%" (
    call :DownloadFile %_url% "%_dest%" || exit /B 1
)

call :VerifyMD5 "%_dest%" %_expected_hash% || exit /B 1

goto :EOF

::-------------------------------------------------------------------------
:: Downloads a file from a URL to a given destination.
::-------------------------------------------------------------------------
:DownloadFile url dest
setlocal

set _url=%~1
set _dest=%~2

echo Downloading %_url% to %_dest%...

curl "%_url%" -o "%_dest%" || exit /B 1

echo Downloaded %_url%

goto :EOF

::-------------------------------------------------------------------------
:: Verifies the MD5 checksum of a file.
::-------------------------------------------------------------------------
:VerifyMD5 filename expected_hash
setlocal

set _filename=%~1
set _expected_hash=%~2

echo Verifying that %_filename% has MD5 hash %_expected_hash%...

PowerShell -Command ^
 "$md5 = New-Object Security.Cryptography.MD5CryptoServiceProvider;"^
 "$file = [System.IO.File]::ReadAllBytes('%_filename%');"^
 "$hash = [System.BitConverter]::ToString($md5.ComputeHash($file));"^
 "$hash = $hash.toLower().Replace('-', '');"^
 "if ($hash -eq '%_expected_hash%') {"^
 "    Write-Host '%_filename% has a valid hash.';"^
 "    exit 0;"^
 "} else {"^
 "    Write-Host 'Invalid hash for %_filename%.';"^
 "    exit 1;"^
 "}" || exit /B 1

echo Hash verified.

goto :EOF

::-------------------------------------------------------------------------
:: Deletes a file or directory if it exists.
::-------------------------------------------------------------------------
:DeleteIfExists path
setlocal

set _path=%~1

if exist "%_path%" (
    del /F /Q "%_path%" 2>NUL
    rmdir /S /Q "%_path%" 2>NUL
)

goto :EOF

::-------------------------------------------------------------------------
:: Aborts the creation of the installer.
::-------------------------------------------------------------------------
:Abort

echo Installation aborted.
exit /B 1

::
:: Build the installer for RBTools for Windows.
::
:: This will fetch Python and build a WiX package for RBTools.
::
:: This requires that curl for Windows (and its ca-bundle) are properly
:: installed and working in order to download files.
::
@echo off
setlocal

::-------------------------------------------------------------------------
:: Build paths
::-------------------------------------------------------------------------

:: Store out the absolute path to the tree root.
pushd ..\..\..
set TREE_ROOT=%CD%
popd

set BUILD_DEST=%TREE_ROOT%\dist
set BUILD_BASE=%TREE_ROOT%\build\windows-pkg
set BUILD_ROOT=%BUILD_BASE%\build
set BUILD_ROOT_X86=%BUILD_BASE%\build\x86
set BUILD_ROOT_X64=%BUILD_BASE%\build\x64
set BUILD_STAGE=%BUILD_BASE%\stage
set DEPS_DIR=%BUILD_BASE%\deps

::-------------------------------------------------------------------------
:: Dependencies
::-------------------------------------------------------------------------
set PYTHON_VERSION=3.8.13

set PYTHON_URL_BASE=https://s3.amazonaws.com/downloads.beanbaginc.com/python
:: set PYTHON_URL_BASE=https://www.python.org/ftp/python

set PYTHON_X86_FILENAME=python-%PYTHON_VERSION%.exe
set PYTHON_X86_URL=%PYTHON_URL_BASE%/%PYTHON_VERSION%/%PYTHON_X86_FILENAME%
set PYTHON_X86_MD5=5e8edbf3fe95034850768b4e6680bc9f
set PYTHON_X86_DEP=%DEPS_DIR%\python-%PYTHON_VERSION%-x86

set PYTHON_X64_FILENAME=python-%PYTHON_VERSION%-amd64.exe
set PYTHON_X64_URL=%PYTHON_URL_BASE%/%PYTHON_VERSION%/%PYTHON_X64_FILENAME%
set PYTHON_X64_MD5=8cd844e55135bd5f9e1d8d2d70a2b6ae
set PYTHON_X64_DEP=%DEPS_DIR%\python-%PYTHON_VERSION%-x64

::-------------------------------------------------------------------------
:: Binaries
::-------------------------------------------------------------------------
set BUNDLED_PYTHON_X86_DIR=%BUILD_ROOT_X86%\Python
set BUNDLED_PYTHON_X86=%BUNDLED_PYTHON_X86_DIR%\python.exe

set BUNDLED_PYTHON_X64_DIR=%BUILD_ROOT_X64%\Python
set BUNDLED_PYTHON_X64=%BUNDLED_PYTHON_X64_DIR%\python.exe

call :SetMSBuildPath || goto :Abort

::-------------------------------------------------------------------------
:: Signing certificate
::-------------------------------------------------------------------------
set CERT_THUMBPRINT=deee311acc700a6f797018a6cf4075131b6f7198

::-------------------------------------------------------------------------
:: Begin the installation process
::-------------------------------------------------------------------------
if not exist "%DEPS_DIR%" mkdir "%DEPS_DIR%"
if not exist "%BUILD_STAGE%" mkdir "%BUILD_STAGE%"

call :InstallPython ^
    x86 %PYTHON_X86_DEP% %PYTHON_X86_FILENAME% ^
    %PYTHON_X86_URL% %PYTHON_X86_MD5% ^
    || goto :Abort

call :InstallPython ^
    x64 %PYTHON_X64_DEP% %PYTHON_X64_FILENAME% ^
    %PYTHON_X64_URL% %PYTHON_X64_MD5% ^
    || goto :Abort

call :CreateBuildDirectory || goto :Abort
call :InstallPackages || goto :Abort
call :InstallRBTools || goto :Abort
call :RemoveUnwantedFiles || goto :Abort
call :BuildInstaller || goto :Abort

echo Done.

goto :EOF

::-------------------------------------------------------------------------
:: Installs Python
::-------------------------------------------------------------------------
:InstallPython arch dep_path python_filename url md5
setlocal

set _arch=%~1
set _dep_path=%~2
set _python_filename=%~3
set _url=%~4
set _md5=%~5

echo.
echo == Installing Python [%_arch%] ==

set _PYTHON_INSTALLER=%TEMP%\%_python_filename%

if not exist "%_dep_path%" (
    echo Checking for %_PYTHON_INSTALLER%...
    if not exist "%_PYTHON_INSTALLER%" (
        echo Preparing to download Python v%PYTHON_VERSION% [%_arch%]...

        call :DownloadAndVerify %_url% "%_PYTHON_INSTALLER%" %_md5%
        if %errorlevel% neq 0 exit /b 1

        echo Downloaded to %_PYTHON_INSTALLER%
    )

    echo Running the installer [%_arch%]...
    "%_PYTHON_INSTALLER%" /quiet ^
        AssociateFiles=0 Include_doc=0 Include_debug=0 Include_launcher=0 ^
        Include_tcltk=0 Include_test=0 InstallAllUsers=0 ^
        InstallLauncherAllUsers=0 Shortcuts=0 SimpleInstall=1 ^
        SimpleInstallDescription="Python for RBTools for Windows" ^
        TargetDir="%_dep_path%-temp"
    if %errorlevel% neq 0 exit /b 1

    xcopy /EYI "%_dep_path%-temp" "%_dep_path%"
    if %errorlevel% neq 0 exit /b 1

    :: Remove the old install from the temp directory, and clean up the
    :: registry files so future installs aren't impacted.
    "%_PYTHON_INSTALLER%" /quiet /uninstall
    if %errorlevel% neq 0 exit /b 1
)

goto :EOF

::-------------------------------------------------------------------------
:: Populates the build directory from dependencies
::-------------------------------------------------------------------------
:CreateBuildDirectory
setlocal

:: Create a copy of the Python directory. This is where we'll be installing
:: RBTools and dependencies, and what we'll actually be distributing.
echo.
echo == Creating build directory ==

call :DeleteIfExists "%BUILD_ROOT%"
xcopy /EYI "%PYTHON_X86_DEP%" "%BUNDLED_PYTHON_X86_DIR%" >NUL
xcopy /EYI "%PYTHON_X64_DEP%" "%BUNDLED_PYTHON_X64_DIR%" >NUL

goto :EOF

::-------------------------------------------------------------------------
:: Install package tools
::-------------------------------------------------------------------------
:InstallPackages
setlocal

echo.
echo == Installing pip and setuptools ==
echo.
echo --------------------------- [Install log] ---------------------------

pushd %TREE_ROOT%

:: Install packages for 32-bit packages.
"%BUNDLED_PYTHON_X86%" -m ensurepip --upgrade

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

"%BUNDLED_PYTHON_X86%" -m pip install -U pip setuptools

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

:: Install packages for 64-bit packages.
"%BUNDLED_PYTHON_X64%" -m ensurepip --upgrade

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

"%BUNDLED_PYTHON_X64%" -m pip install -U pip setuptools

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

popd

echo ---------------------------------------------------------------------

goto :EOF

::-------------------------------------------------------------------------
:: Install RBTools and all dependencies
::-------------------------------------------------------------------------
:InstallRBTools
setlocal

echo.
echo == Installing RBTools and dependencies ==
echo.
echo --------------------------- [Install log] ---------------------------

pushd %TREE_ROOT%

:: Build for 32-bit Python.
"%BUNDLED_PYTHON_X86%" setup.py release install >NUL

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

:: Build for 64-bit Python.
"%BUNDLED_PYTHON_X64%" setup.py release install >NUL

if ERRORLEVEL 1 (
    popd
    exit /B 1
)

popd

echo ---------------------------------------------------------------------

goto :EOF

::-------------------------------------------------------------------------
:: Remove unwanted files from the build directory.
::-------------------------------------------------------------------------
:RemoveUnwantedFiles
setlocal

echo.
echo == Removing unwanted files ==

call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\Doc"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\tcl"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\Tools"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\%PYTHON_X86_FILENAME%"

call :DeleteIfExists "%BUNDLED_PYTHON_X64_DIR%\Doc"
call :DeleteIfExists "%BUNDLED_PYTHON_X64_DIR%\tcl"
call :DeleteIfExists "%BUNDLED_PYTHON_X86_DIR%\Tools"
call :DeleteIfExists "%BUNDLED_PYTHON_X64_DIR%\%PYTHON_X64_FILENAME%"

echo == Files removed ==

goto :EOF

::-------------------------------------------------------------------------
:: Build the installer
::-------------------------------------------------------------------------
:BuildInstaller
setlocal

call :GetRBToolsVersion
set _rbtools_version=%_return1%

set _wix_path=%CD%\wix
set _sln_file=%_wix_path%\rbtools.sln
set _timestamp_url=http://timestamp.comodoca.com/authenticode

echo.
echo == Building the RBTools installer [x86] ==

%MSBUILD% ^
    /p:Version="%_rbtools_version%" ^
    /p:Platform=x86 ^
    /p:ExeSuffix=-32bit ^
    /p:Root="%BUILD_ROOT_X86%" ^
    /p:OutputPath="%BUILD_STAGE%\\" ^
    /p:SourcePath="%_wix_path%" ^
    /p:CertificateThumbprint=%CERT_THUMBPRINT% ^
    /p:TimestampUrl=%_timestamp_url% ^
    "%_sln_file%"

if ERRORLEVEL 1 exit /B 1

echo.
echo == Building the RBTools installer [x64] ==

%MSBUILD% ^
    /p:Version="%_rbtools_version%" ^
    /p:Platform=x64 ^
    /p:ExeSuffix=-64bit ^
    /p:Root="%BUILD_ROOT_X64%" ^
    /p:OutputPath="%BUILD_STAGE%\\" ^
    /p:SourcePath="%_wix_path%" ^
    /p:CertificateThumbprint=%CERT_THUMBPRINT% ^
    /p:TimestampUrl=%_timestamp_url% ^
    "%_sln_file%"

if ERRORLEVEL 1 exit /B 1

mkdir "%BUILD_DEST%" 2>&1
dir "%BUILD_STAGE%" /S
copy "%BUILD_STAGE%\RBTools-%_rbtools_version%*.exe" "%BUILD_DEST%" >NUL

echo Installers published to %BUILD_DEST%

goto :EOF

::-------------------------------------------------------------------------
:: Returns the Python version for RBTools.
::
:: This must be run after installing RBTools in %BUILD_ROOT%.
::-------------------------------------------------------------------------
:GetRBToolsVersion
setlocal

set _version_file=%BUILD_STAGE%\VERSION

"%BUNDLED_PYTHON_X64%" scripts/get-version.py > "%_version_file%"
set /P _version= < "%_version_file%"
del "%_version_file%"

endlocal & set _return1=%_version%
goto :EOF

::-------------------------------------------------------------------------
:: Determines the path to MSBuild.exe
::-------------------------------------------------------------------------
:SetMSBuildPath
setlocal

set _reg_key=HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
set _reg_query_cmd=reg.exe query "%_reg_key%" /V MSBuildToolsPath

%_reg_query_cmd% >NUL 2>&1

if ERRORLEVEL 1 (
    echo Cannot obtain the MSBuild tools path from the registry.
    exit /B 1
)

for /f "skip=2 tokens=2,*" %%A in ('%_reg_query_cmd%') do (
    SET MSBUILDDIR=%%B
)

if not exist %MSBUILDDIR%nul (
    echo The MSBuild tools path from the registry does not exist.
    echo
    echo The missing path is: %MSBUILDDIR%
    exit /B 1
)

if not exist %MSBUILDDIR%msbuild.exe (
    echo MSBuild.exe is missing from %MSBUILDDIR%.
    exit /B 1
)

endlocal & set MSBUILD=%MSBUILDDIR%msbuild.exe
goto :EOF

::-------------------------------------------------------------------------
:: Downloads and verifies a file from a URL.
::-------------------------------------------------------------------------
:DownloadAndVerify url dest expected_hash
setlocal

set _url=%~1
set _dest=%~2
set _expected_hash=%~3

if not exist "%_dest%" (
    call :DownloadFile %_url% "%_dest%" || exit /B 1
)

call :VerifyMD5 "%_dest%" %_expected_hash% || exit /B 1

goto :EOF

::-------------------------------------------------------------------------
:: Downloads a file from a URL to a given destination.
::-------------------------------------------------------------------------
:DownloadFile url dest
setlocal

set _url=%~1
set _dest=%~2

echo Downloading %_url% to %_dest%...

curl "%_url%" -o "%_dest%" || exit /B 1

echo Downloaded %_url%

goto :EOF

::-------------------------------------------------------------------------
:: Verifies the MD5 checksum of a file.
::-------------------------------------------------------------------------
:VerifyMD5 filename expected_hash
setlocal

set _filename=%~1
set _expected_hash=%~2

echo Verifying that %_filename% has MD5 hash %_expected_hash%...

PowerShell -NoProfile -Command ^
 "$md5 = New-Object Security.Cryptography.MD5CryptoServiceProvider;"^
 "$file = [System.IO.File]::ReadAllBytes('%_filename%');"^
 "$hash = [System.BitConverter]::ToString($md5.ComputeHash($file));"^
 "$hash = $hash.toLower().Replace('-', '');"^
 "if ($hash -eq '%_expected_hash%') {"^
 "    Write-Host '%_filename% has a valid hash.';"^
 "    exit 0;"^
 "} else {"^
 "    Write-Host 'Invalid hash for %_filename%.';"^
 "    exit 1;"^
 "}" < nul || exit /B 1

echo Hash verified.

goto :EOF

::-------------------------------------------------------------------------
:: Deletes a file or directory if it exists.
::-------------------------------------------------------------------------
:DeleteIfExists path
setlocal

set _path=%~1

if exist "%_path%" (
    del /F /Q "%_path%" 2>NUL
    rmdir /S /Q "%_path%" 2>NUL
)

goto :EOF

::-------------------------------------------------------------------------
:: Aborts the creation of the installer.
::-------------------------------------------------------------------------
:Abort

echo Installation aborted.
exit /B 1

Update the Windows installer to ship Python 3.8.13.

Previously, the Windows installer was shipping Python 3.8.10, which was
the newest release in the 3.8 series at the time. We're now shipping
3.8.13.

This was chosen over Python 3.9 or 3.10 due to still being compatible
with Windows 7 systems. While we may want to drop Windows 7 soon, we
want to make sure we communicate that correctly before we do it.

There are no official Python 3.8.13 builds, so we've built our own
signed installer using their official process, hosted on S3. This has
been tested and verified to work. When we move to a newer release, we
can go back to consuming official installers.

There are some other fixes in here as well. We no longer block on MD5
verification, which could happen sometimes due to PowerShell looking for
more scripts on stdin. We also have better error handling for the
installation stage, and we output the path to the installer in case we
need to debug things.

Testing Done:
Successfully built the installers. Verified they worked on a Windows
install without Python.

Reviewed at https://reviews.reviewboard.org/r/12203/


C:\Python27\Scripts\pip.exe install -r requirements.txt --allow-external pypubsub
C:\Python27\python.exe setup.py bdist_msi
move dist\* prerequisites
"C:\Program Files (x86)\NSIS\makensis.exe" "iridaUploader_installer.nsi"
PAUSE

C:\Python27\Scripts\pip.exe install -r requirements.txt --allow-external pypubsub
C:\Python27\Scripts\pip.exe install -r requirements-building.txt --allow-external pypubsub
cd iridaUploader/docs
C:\Python27\Scripts\sphinx-build -b html -d _build/doctrees   . _build/html
echo. 2>_build/__init__.py
echo. 2>_build/html/__init__.py
echo. 2>_build/html/_images/__init__.py
echo. 2>_build/html/_sources/__init__.py
echo. 2>_build/html/_static/__init__.py
cd ../..
C:\Python27\python.exe setup.py bdist_msi
move dist\* prerequisites
"C:\Program Files (x86)\NSIS\makensis.exe" "iridaUploader_installer.nsi"
PAUSE

build docs
subfolders in _build/ need __init__.py to be recognized as package and have it's data moved in to application directory

Former-commit-id: dafe7c0563746b3b4fd08098f2793a17798d9117


mkdir build
cd build

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

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

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

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

Create bld.bat

Create bld.bat


@echo off

setlocal
set OUTDIR=%1
set JSENG=%2
set CYGWIN_ROOT=%~dp0..\..\..\third_party\cygwin\
set GNU_ROOT=%~dp0..\..\..\third_party\gnu\files

set PATH=%CYGWIN_ROOT%bin;%GNU_ROOT%;%SystemRoot%;%SystemRoot%\system32

:: Ensure that the cygwin mount points are defined
CALL %CYGWIN_ROOT%setup_mount.bat > NUL

bash -x create-config.sh %OUTDIR% %JSENG%

@echo off

setlocal
set OUTDIR=%1
set JSENG=%2
set CYGWIN_ROOT=%~dp0..\..\..\third_party\cygwin\
set GNU_ROOT=%~dp0..\..\..\third_party\gnu\files

:: Fix cp.exe on vista: without this flag, the files that it creates are not accessible.
set CYGWIN=nontsec

set PATH=%CYGWIN_ROOT%bin;%GNU_ROOT%;%SystemRoot%;%SystemRoot%\system32

:: Ensure that the cygwin mount points are defined
CALL %CYGWIN_ROOT%setup_mount.bat > NUL

bash -x create-config.sh %OUTDIR% %JSENG%

Fix a build issue with Vista. Stop cp.exe from trying to emulate POSIX security
on top of NTFS.

BUG=1157117

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@40 0039d316-1c4b-4281-b951-d872f2087c98


echo off
IF EXIST dist del /Q dist\*.*

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

:default_value:
IF NOT EXIST c:\Python34 GOTO checkinstall64:

:checkinstall:
IF EXIST c:\Python34vir GOTO nexta:
mkdir c:\Python34vir

:nexta:
IF EXIST c:\Python34vir\install GOTO fullsetupa:
c:\Python34\Scripts\virtualenv c:\Python34vir\install --system-site-packages
if %errorlevel% neq 0 exit /b %errorlevel%

:fullsetupa:
echo #######################################################
c:\Python34vir\install\Scripts\python -u setup.py install
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:checkinstall64:
IF EXIST c:\Python34_64vir GOTO nextb:
mkdir c:\Python34_64vir

:nextb:
IF EXIST c:\Python34_64vir\install GOTO fullsetupb:
c:\Python34_x64\Scripts\virtualenv c:\Python34_64vir\install --system-site-packages
if %errorlevel% neq 0 exit /b %errorlevel%

:fullsetupb:
echo #######################################################
c:\Python34_64vir\install\Scripts\python -u setup.py install
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup33:
IF NOT EXIST c:\Python33 GOTO setup33_64:
set pythonexe="c:\Python33\python"
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py bdist_wininst
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup33_64:
IF NOT EXIST c:\Python33_x64 GOTO setup34:
set pythonexe="c:\Python33_x64\python"
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py sdist --formats=gztar,zip --verbose
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py build bdist_wininst --plat-name=win-amd64
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup34:
IF NOT EXIST c:\Python34 GOTO setup34_x64_msi_wheel:
set pythonexe="c:\Python34\python"
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py build bdist_wininst --plat-name=win-amd64
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:utpy34_64:
set pythonexe="c:\Python34_x64\python"
%pythonexe% -u setup.py clean_space
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% -u setup.py unittests
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup34_x64_msi_wheel:
set pythonexe="c:\Python34_x64\python"
:custom_python:
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py sdist --formats=gztar,zip --verbose
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_wininst --plat-name=win-amd64
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_msi
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_wheel
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:documentation:
%pythonexe% -u setup.py build_sphinx
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:copyfiles:
if not exist dist\html mkdir dist\html
xcopy /E /C /I /Y _doc\sphinxdoc\build\html dist\html
if %errorlevel% neq 0 exit /b %errorlevel%

echo off
IF EXIST dist del /Q dist\*.*

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

:default_value:
IF NOT EXIST c:\Python34 GOTO checkinstall64:

:checkinstall:
IF EXIST c:\Python34vir GOTO nexta:
mkdir c:\Python34vir

:nexta:
IF EXIST c:\Python34vir\install GOTO fullsetupa:
c:\Python34\Scripts\virtualenv c:\Python34vir\install --system-site-packages
if %errorlevel% neq 0 exit /b %errorlevel%

:fullsetupa:
echo #######################################################
c:\Python34vir\install\Scripts\python -u setup.py install
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:checkinstall64:
IF EXIST c:\Python34_64vir GOTO nextb:
mkdir c:\Python34_64vir

:nextb:
IF EXIST c:\Python34_64vir\install GOTO fullsetupb:
c:\Python34_x64\Scripts\virtualenv c:\Python34_64vir\install --system-site-packages
if %errorlevel% neq 0 exit /b %errorlevel%

:fullsetupb:
echo #######################################################
c:\Python34_64vir\install\Scripts\python -u setup.py install
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup33:
IF NOT EXIST c:\Python33 GOTO setup33_64:
set pythonexe="c:\Python33\python"
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py bdist_wininst
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup33_64:
IF NOT EXIST c:\Python33_x64 GOTO setup34:
set pythonexe="c:\Python33_x64\python"
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py sdist --formats=gztar,zip --verbose
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py build bdist_wininst --plat-name=win-amd64
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup34:
IF NOT EXIST c:\Python34 GOTO utpy34_64:
set pythonexe="c:\Python34\python"
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py build bdist_wininst --plat-name=win-amd64
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:utpy34_64:
set pythonexe="c:\Python34_x64\python"
%pythonexe% -u setup.py clean_space
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% -u setup.py unittests
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:setup34_x64_msi_wheel:
set pythonexe="c:\Python34_x64\python"
:custom_python:
%pythonexe% setup.py clean_pyd
%pythonexe% setup.py sdist --formats=gztar,zip --verbose
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_wininst --plat-name=win-amd64
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_msi
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_wheel
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:documentation:
%pythonexe% -u setup.py build_sphinx
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

:copyfiles:
if not exist dist\html mkdir dist\html
xcopy /E /C /I /Y _doc\sphinxdoc\build\html dist\html
if %errorlevel% neq 0 exit /b %errorlevel%

fix setup batch

fix setup batch


@echo off
md \php-gtk-dist
cd \php-gtk-dist
md php4
md winnt
md winnt\system32
md samples
copy \php4\php.exe php4
copy \php4\php_win.exe php4
copy \php4\php4ts.dll php4
copy \php4\php4isapi.dll php4
copy \php4\php_gtk.dll php4
copy \php\php4\php.ini-dist winnt\php.ini
copy %SystemRoot%\system32\gtk-1.3.dll winnt\system32
copy %SystemRoot%\system32\gdk-1.3.dll winnt\system32
copy %SystemRoot%\system32\gmodule-1.3.dll winnt\system32
copy %SystemRoot%\system32\glib-1.3.dll winnt\system32
copy %SystemRoot%\system32\iconv-1.3.dll winnt\system32
copy %SystemRoot%\system32\gnu-intl.dll winnt\system32
copy %SystemRoot%\system32\libglade-0.14.dll winnt\system32
copy %SystemRoot%\system32\libxml.dll winnt\system32
copy \php\php-gtk\test\fileselection.php samples
copy \php\php-gtk\test\gtk.php samples
copy \php\php-gtk\test\hello.php samples
copy \php\php-gtk\test\list.php samples
copy \php\php-gtk\test\scribble.php samples
copy \php\php-gtk\test\testgtkrc samples
copy \php\php-gtk\test\testgtkrc2 samples
copy \php\php-gtk\win32\README.txt
"c:\Program Files\WinZip\WZZip" -ampr php-gtk-0.1.1a-win32.zip
cd \php\php-gtk\win32

@echo off
md \php-gtk-dist
cd \php-gtk-dist
md php4
md winnt
md winnt\system32
md test
copy \php4\php.exe php4
copy \php4\php_win.exe php4
copy \php4\php4ts.dll php4
copy \php4\php4isapi.dll php4
copy \php4\php_gtk.dll php4
copy \php\php4\php.ini-dist winnt\php.ini
copy %SystemRoot%\system32\gtk-1.3.dll winnt\system32
copy %SystemRoot%\system32\gdk-1.3.dll winnt\system32
copy %SystemRoot%\system32\gmodule-1.3.dll winnt\system32
copy %SystemRoot%\system32\glib-1.3.dll winnt\system32
copy %SystemRoot%\system32\iconv-1.3.dll winnt\system32
copy %SystemRoot%\system32\gnu-intl.dll winnt\system32
copy %SystemRoot%\system32\libglade-0.14.dll winnt\system32
copy %SystemRoot%\system32\libxml.dll winnt\system32
copy \php\php-gtk\test\fileselection.php test
copy \php\php-gtk\test\gtk.php test
copy \php\php-gtk\test\hello.php test
copy \php\php-gtk\test\list.php test
copy \php\php-gtk\test\scribble.php test
copy \php\php-gtk\test\testgtkrc test
copy \php\php-gtk\test\testgtkrc2 test
copy \php\php-gtk\win32\README.txt
"c:\Program Files\WinZip\WZZip" -ampr php-gtk-0.1.1a-win32.zip
cd \php\php-gtk\win32

Rename samples to test according to the docs.


@echo off
rem ----------------------------------------------------------------------------
rem
rem This variable should be set to the directory where is installed ProActive
rem

IF NOT DEFINED PA_SCHEDULER set PA_SCHEDULER=%CD%\..\..

rem ----------------------------------------------------------------------------

if NOT DEFINED JAVA_HOME goto javahome
if "%JAVA_HOME%" == "" goto javahome

rem ----
rem Set up the classpath using classes dir or jar files
rem

IF DEFINED CLASSPATHEXT (
	SET CLASSPATH=%CLASSPATHEXT%
) ELSE (
	SET CLASSPATH=.
)

IF EXIST "%PA_SCHEDULER%\classes" (
	SET CLASSPATH=%CLASSPATH%;%PA_SCHEDULER%\classes\resource-manager;%PA_SCHEDULER%\classes\scheduler
	SET JARS=%PA_SCHEDULER%\lib\
	FOR %%j IN ("%PA_SCHEDULER%\lib\*.jar") DO SET JARS=!JARS!;%%j
	FOR %%j IN ("%PA_SCHEDULER%\lib\ProActive\*.jar") DO SET JARS=!JARS!;%%j
	FOR %%j IN ("%PA_SCHEDULER%\lib\common\*.jar") DO SET JARS=!JARS!;%%j
) ELSE (
	FOR %%j IN ("%PA_SCHEDULER%\dist\lib\*.jar") DO SET JARS=!JARS!;%%j
	SET CLASSPATH=%CLASSPATH%;%PA_SCHEDULER%\dist\lib\.jar
)

SET CLASSPATH=%CLASSPATH%;%JARS%

set JAVA_CMD="%JAVA_HOME%\bin\java.exe" -Dproactive.home="%PA_SCHEDULER%" -Djava.security.manager -Djava.security.policy="%PA_SCHEDULER%\bin\proactive.java.policy"

rem Adding java tools to the path
SET OK=1
FOR /F "delims=;" %%i IN ("%PATH%") DO (
IF /I "%%i" == "%JAVA_HOME%\bin" SET OK=0
)
IF /I %OK%==1 SET PATH=%JAVA_HOME%\bin;%PATH%

goto end

:javahome
echo.
echo The enviroment variable JAVA_HOME must be set the current jdk distribution
echo installed on your computer.
echo Use
echo    set JAVA_HOME=<the directory where is the JDK>
goto end

:end

@echo off
rem ----------------------------------------------------------------------------
rem
rem This variable should be set to the directory where is installed ProActive
rem

IF NOT DEFINED PA_SCHEDULER set PA_SCHEDULER=%CD%\..\..

rem ----------------------------------------------------------------------------

if NOT DEFINED JAVA_HOME goto javahome
if "%JAVA_HOME%" == "" goto javahome

rem ----
rem Set up the classpath using classes dir or jar files
rem

IF DEFINED CLASSPATHEXT (
	SET CLASSPATH=%CLASSPATHEXT%
) ELSE (
	SET CLASSPATH=.
)

IF EXIST "%PA_SCHEDULER%\classes" (
	SET CLASSPATH=%CLASSPATH%;%PA_SCHEDULER%\classes\resource-manager;%PA_SCHEDULER%\classes\scheduler
	SET JARS=%PA_SCHEDULER%\lib\
	FOR %%j IN ("%PA_SCHEDULER%\lib\*.jar") DO SET JARS=!JARS!;%%j
	FOR %%j IN ("%PA_SCHEDULER%\lib\ProActive\*.jar") DO SET JARS=!JARS!;%%j
	FOR %%j IN ("%PA_SCHEDULER%\lib\common\*.jar") DO SET JARS=!JARS!;%%j
) ELSE (
	FOR %%j IN ("%PA_SCHEDULER%\dist\lib\*.jar") DO SET JARS=!JARS!;%%j
	SET CLASSPATH=%CLASSPATH%;%PA_SCHEDULER%\dist\lib\.jar
)

SET CLASSPATH=%CLASSPATH%;%JARS%

set JAVA_CMD="%JAVA_HOME%\bin\java.exe" -Dproactive.home="%PA_SCHEDULER%" -Dscheduler.home="%PA_SCHEDULER%" -Djava.security.manager -Djava.security.policy="%PA_SCHEDULER%\bin\proactive.java.policy"

rem Adding java tools to the path
SET OK=1
FOR /F "delims=;" %%i IN ("%PATH%") DO (
IF /I "%%i" == "%JAVA_HOME%\bin" SET OK=0
)
IF /I %OK%==1 SET PATH=%JAVA_HOME%\bin;%PATH%

goto end

:javahome
echo.
echo The enviroment variable JAVA_HOME must be set the current jdk distribution
echo installed on your computer.
echo Use
echo    set JAVA_HOME=<the directory where is the JDK>
goto end

:end

Add scheduler.home java properties in init.bat

git-svn-id: 27916816d6cfa57849e9a885196bf7392b80e1ac@9621 28e8926c-6b08-0410-baaa-805c5e19b8d6


@echo off

if not defined PHP_SDK_RUN_FROM_ROOT (
	echo This script should not be run directly.
	echo Use starter scripts looking like phpsdk-^<crt^>-^<arch^>.bat in the PHP SDK root instead.
	goto out_error
)

if "%1"=="" goto :help
if "%1"=="/?" goto :help
if "%1"=="-h" goto :help
if "%1"=="--help" goto :help
if "%2"=="" goto :help

cmd /c "exit /b 0"

set PHP_SDK_VS=%1
if /i not "%PHP_SDK_VS:~0,2%"=="vc" (
	if /i not "%PHP_SDK_VS:~0,2%"=="vs" (
:malformed_vc_string
		echo Malformed CRT string "%1"
		set PHP_SDK_VS=
		goto out_error
	)
)
if ""=="%PHP_SDK_VS:~2%" (
	goto malformed_vc_string
)
set /a TMP_CHK=%PHP_SDK_VS:~2%
if 14 gtr %TMP_CHK% (
	if "0"=="%TMP_CHK%" (
		if not "0"=="%PHP_SDK_VS:~2%" (
			set TMP_CHK=
			goto malformed_vc_string
		)
	)

	echo At least vc14 is required
	set PHP_SDK_VS=
	set TMP_CHK=
	goto out_error
)
set PHP_SDK_VS_NUM=%TMP_CHK%
set TMP_CHK=

if /i not "%2"=="x64" (
	if /i not "%2"=="x86" (
		echo Unsupported arch "%2"
		goto out_error
	)
)

set PHP_SDK_ARCH=%2

rem check OS arch
set TMPKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
reg query "%TMPKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul
if not errorlevel 1 (
	set PHP_SDK_OS_ARCH=x64
) else (
	if /i "%PHP_SDK_ARCH%"=="x64" (
		echo 32-bit OS detected, native 64-bit toolchain is unavailable.
		goto out_error
	)
	set PHP_SDK_OS_ARCH=x86
)
set TMPKEY=

rem get vc base dir
if 15 gtr %PHP_SDK_VS_NUM% (
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC
	) else (
		set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC
	)
	reg query !TMPKEY! /v ProductDir >nul 2>&1
	if errorlevel 1 (
		echo Couldn't determine VC%PHP_SDK_VS:~2% directory
		goto out_error;
	)
	for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VS_DIR=%%b
) else (
	rem vc15 support only for now, could parse out and pass on later
	for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VS_NUM% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
		set PHP_SDK_VS_DIR=%%b\VC
		goto break0
	)
:break0
	if not exist "!PHP_SDK_VS_DIR!" (
		for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VS_NUM% -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
			set PHP_SDK_VS_DIR=%%b\VC
			goto break1
		)
:break1
		if not exist "!PHP_SDK_VS_DIR!" (
			rem check for a preview release
			for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VS_NUM% -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
				set PHP_SDK_VS_DIR=%%b\VC
				goto break3
			)
:break3
			if not exist "!PHP_SDK_VS_DIR!" (
				echo Could not determine '%PHP_SDK_VS%' directory
				goto out_error;
			)
		)
	)
	set VSCMD_ARG_no_logo=nologo
)
set TMPKEY=

if 15 gtr %PHP_SDK_VS_NUM% (
	rem get sdk dir
	rem if 10.0 is available, it's ok
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0
	) else (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0
	)
	for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
		for /f "tokens=2*" %%c in ('reg query "!TMPKEY!" /v ProductVersion') do (
			if exist "%%bInclude\%%d.0\um\Windows.h" (
				goto got_sdk
			)
		)
	)

	rem Otherwise 8.1 should be available anyway
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
	) else (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
	)
	for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
		if exist "%%b\Include\um\Windows.h" (
			goto got_sdk
		)
	)

	echo Windows SDK not found.
	goto out_error;
:got_sdk
	set TMPKEY=
)

if /i "%PHP_SDK_ARCH%"=="x64" (
	if 15 gtr %PHP_SDK_VS_NUM% (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VS_DIR!\vcvarsall.bat" amd64
	) else (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VS_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
	)
) else (
	if 15 gtr %PHP_SDK_VS_NUM% (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VS_DIR!\vcvarsall.bat" x86
	) else (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VS_DIR!\Auxiliary\Build\vcvarsall.bat" x86
	)
)

rem echo Visual Studio path %PHP_SDK_VS_DIR%
rem echo Windows SDK path %PHP_SDK_WIN_SDK_DIR%

goto out

:help
	echo "Start Visual Studio command line for PHP SDK"
	echo "Usage: %0 vc arch"
	echo nul

:out_error
	exit /b 3

:out
rem	echo Shell configuration complete
	exit /b 0

goto :eof

@echo off

if not defined PHP_SDK_RUN_FROM_ROOT (
	echo This script should not be run directly.
	echo Use starter scripts looking like phpsdk-^<crt^>-^<arch^>.bat in the PHP SDK root instead.
	goto out_error
)

if "%1"=="" goto :help
if "%1"=="/?" goto :help
if "%1"=="-h" goto :help
if "%1"=="--help" goto :help
if "%2"=="" goto :help

cmd /c "exit /b 0"

set PHP_SDK_VS=%1
if /i not "%PHP_SDK_VS:~0,2%"=="vc" (
	if /i not "%PHP_SDK_VS:~0,2%"=="vs" (
:malformed_vc_string
		echo Malformed CRT string "%1"
		set PHP_SDK_VS=
		goto out_error
	)
)
if ""=="%PHP_SDK_VS:~2%" (
	goto malformed_vc_string
)
set /a TMP_CHK=%PHP_SDK_VS:~2%
if 14 gtr %TMP_CHK% (
	if "0"=="%TMP_CHK%" (
		if not "0"=="%PHP_SDK_VS:~2%" (
			set TMP_CHK=
			goto malformed_vc_string
		)
	)

	echo At least vc14 is required
	set PHP_SDK_VS=
	set TMP_CHK=
	goto out_error
)
set PHP_SDK_VS_NUM=%TMP_CHK%
set TMP_CHK=

if /i not "%2"=="x64" (
	if /i not "%2"=="x86" (
		echo Unsupported arch "%2"
		goto out_error
	)
)

set PHP_SDK_ARCH=%2

rem check OS arch
set TMPKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
reg query "%TMPKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul
if not errorlevel 1 (
	set PHP_SDK_OS_ARCH=x64
) else (
	if /i "%PHP_SDK_ARCH%"=="x64" (
		echo 32-bit OS detected, native 64-bit toolchain is unavailable.
		goto out_error
	)
	set PHP_SDK_OS_ARCH=x86
)
set TMPKEY=

rem get vc base dir
if 15 gtr %PHP_SDK_VS_NUM% (
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC
	) else (
		set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC
	)
	reg query !TMPKEY! /v ProductDir >nul 2>&1
	if errorlevel 1 (
		echo Couldn't determine VC%PHP_SDK_VS:~2% directory
		goto out_error;
	)
	for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
) else (
	rem the first one found seems the correct one
	for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VS_NUM% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
		set PHP_SDK_VC_DIR=%%b\VC
		goto break0
	)
:break0
	if not exist "!PHP_SDK_VC_DIR!" (
		for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VS_NUM% -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
			set PHP_SDK_VC_DIR=%%b\VC
			goto break1
		)
:break1
		if not exist "!PHP_SDK_VC_DIR!" (
			rem check for a preview release
			for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VS_NUM% -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
				set PHP_SDK_VC_DIR=%%b\VC
				goto break3
			)
:break3
			if not exist "!PHP_SDK_VC_DIR!" (
				echo Could not determine '%PHP_SDK_VS%' directory
				goto out_error;
			)
		)
	)
	set VSCMD_ARG_no_logo=nologo
)
set TMPKEY=

if 15 gtr %PHP_SDK_VS_NUM% (
	rem get sdk dir
	rem if 10.0 is available, it's ok
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0
	) else (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0
	)
	for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
		for /f "tokens=2*" %%c in ('reg query "!TMPKEY!" /v ProductVersion') do (
			if exist "%%bInclude\%%d.0\um\Windows.h" (
				goto got_sdk
			)
		)
	)

	rem Otherwise 8.1 should be available anyway
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
	) else (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
	)
	for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
		if exist "%%b\Include\um\Windows.h" (
			goto got_sdk
		)
	)

	echo Windows SDK not found.
	goto out_error;
:got_sdk
	set TMPKEY=
)

if /i "%PHP_SDK_ARCH%"=="x64" (
	if 15 gtr %PHP_SDK_VS_NUM% (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
	) else (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
	)
) else (
	if 15 gtr %PHP_SDK_VS_NUM% (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
	) else (
		set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86
	)
)

rem echo Visual Studio VC path %PHP_SDK_VC_DIR%
rem echo Windows SDK path %PHP_SDK_WIN_SDK_DIR%

goto out

:help
	echo "Start Visual Studio command line for PHP SDK"
	echo "Usage: %0 vc arch"
	echo nul

:out_error
	exit /b 3

:out
rem	echo Shell configuration complete
	exit /b 0

goto :eof

Fix var name

Fix var name


if exist classes rmdir classes /s /q
mkdir classes
xcopy /E /y src classes\
"%JAVA_HOME%\bin\java" -cp ../../3rdpartypublic/classext/clojure.jar;../MMCoreJ_wrap/MMCoreJ.jar;../../3rdpartypublic/classext/ij.jar;../mmstudio/MMJ_.jar;../../3rdpartypublic/classext/bsh-2.0b4.jar;./src -Dclojure.compile.path=classes clojure.lang.Compile org.micromanager.acq-engine
"%JAVA_HOME%\bin\jar" cf MMAcqEngine.jar -C classes\ .
copy /Y MMAcqEngine.jar ..\bin_Win32\
copy /Y MMAcqEngine.jar ..\bin_x64\
copy /Y MMAcqEngine.jar ..\Install_Win32\micro-manager\plugins\Micro-Manager"
copy /Y MMAcqEngine.jar ..\Install_x64\micro-manager\plugins\Micro-Manager"

if exist classes rmdir classes /s /q
mkdir classes
xcopy /E /y src classes\
"%JAVA_HOME%\bin\java" -cp ../../3rdpartypublic/classext/clojure.jar;../MMCoreJ_wrap/MMCoreJ.jar;../../3rdpartypublic/classext/ij.jar;../mmstudio/MMJ_.jar;../../3rdpartypublic/classext/bsh-2.0b4.jar;./src -Dclojure.compile.path=classes clojure.lang.Compile org.micromanager.acq-engine
xcopy /E /y src build\
copy classes\org\micromanager\AcquisitionEngine2010.class build\org\micromanager
"%JAVA_HOME%\bin\jar" cf MMAcqEngine.jar -C build\ .
copy /Y MMAcqEngine.jar ..\bin_Win32\
copy /Y MMAcqEngine.jar ..\bin_x64\
copy /Y MMAcqEngine.jar ..\Install_Win32\micro-manager\plugins\Micro-Manager"
copy /Y MMAcqEngine.jar ..\Install_x64\micro-manager\plugins\Micro-Manager"

Use mostly JIT compiling for acq eng.

Use mostly JIT compiling for acq eng.

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


"%sdkverpath%" -q -version:"%sdkver%"
call setenv /x64

rem install python packages
pip install --cache-dir "%whell_cache%" numexpr
pip install --cache-dir "%Env:whell_cache%" -r dev_requirements.txt

rem install simphony-common
python setup.py develop
if %errorlevel% neq 0 exit /b %errorlevel%
cd examples/plugin
python setup.py develop
if %errorlevel% neq 0 exit /b %errorlevel%
cd ..

"%sdkverpath%" -q -version:"%sdkver%"
call setenv /x64

rem install python packages
pip install --cache-dir "%wheel_cache%" numexpr
pip install --cache-dir "%wheel_cache%" -r dev_requirements.txt

rem install simphony-common
python setup.py develop
if %errorlevel% neq 0 exit /b %errorlevel%
cd examples/plugin
python setup.py develop
if %errorlevel% neq 0 exit /b %errorlevel%
cd ..

fix the variable name for the cache directory


set DEPOT="%CD%"

IF NOT EXIST multimedia.pro GOTO NOSOURCE
IF EXIST %QTDIR%\.qmake.cache set CETESTCOMMAND=cetest -cache %QTDIR%\.qmake.cache -libpath \Windows
IF NOT EXIST %QTDIR%\.qmake.cache set CETESTCOMMAND=cetest -libpath \Windows

IF NOT EXIST %DEPOT%\..\..\qa-dungeon\mainline\tests\wince\deploy\ GOTO SKIPDEPLOY
cd %DEPOT%\..\..\qa-dungeon\mainline\tests\wince\deploy\
call %CETESTCOMMAND%

:SKIPDEPLOY
cd %DEPOT%\tests\auto\qaudiocapturesource
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qcamera
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qgraphicsvideoitem
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediacontent
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaimageviewer
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaobject
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaplayer
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaplaylist
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaplaylistnavigator
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediapluginloader
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediarecorder
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaresource
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaservice
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qmediaserviceprovider
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qradiotuner
call %CETESTCOMMAND%
cd %DEPOT%\tests\auto\qvideowidget
call %CETESTCOMMAND%
GOTO EOF

:NOSOURCE
echo "Unable to find multimedia.pro check current directory is multimedia source"
GOTO EOF

:EOF
cd %DEPOT%

Convert line endings.

Convert line endings.


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

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

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

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

Update bld.bat

Update bld.bat


:: To build extensions for 64 bit Python 3, we need to configure environment
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
::
:: To build extensions for 64 bit Python 2, we need to configure environment
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
::
:: 32 bit builds do not require specific environment configurations.
::
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
:: cmd interpreter, at least for (SDK v7.0)
::
:: More details at:
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
:: http://stackoverflow.com/a/13751649/163740
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
@ECHO OFF

SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows

IF "%PYTHON_ARCH%"=="64" (
    ECHO SDK: %WINDOWS_SDK_VERSION% ARCH: %PYTHON_ARCH%
    SET DISTUTILS_USE_SDK=1
    SET MSSdk=1
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
) ELSE (
    ECHO SDK: %WINDOWS_SDK_VERSION% ARCH: %PYTHON_ARCH%
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
)

:: To build extensions for 64 bit Python 3, we need to configure environment
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
::
:: To build extensions for 64 bit Python 2, we need to configure environment
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
::
:: 32 bit builds do not require specific environment configurations.
::
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
:: cmd interpreter, at least for (SDK v7.0)
::
:: More details at:
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
:: http://stackoverflow.com/a/13751649/163740
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
@ECHO OFF

SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows

SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
IF %MAJOR_PYTHON_VERSION% == "2" (
    SET WINDOWS_SDK_VERSION="v7.0"
) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
    SET WINDOWS_SDK_VERSION="v7.1"
) ELSE (
    ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
    EXIT 1
)

IF "%PYTHON_ARCH%"=="64" (
    ECHO SDK: %WINDOWS_SDK_VERSION% ARCH: %PYTHON_ARCH%
    SET DISTUTILS_USE_SDK=1
    SET MSSdk=1
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
    "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
) ELSE (
    ECHO SDK: %WINDOWS_SDK_VERSION% ARCH: %PYTHON_ARCH%
    ECHO Executing: %COMMAND_TO_RUN%
    call %COMMAND_TO_RUN% || EXIT 1
)

Update appveyor-with-compiler.cmd

Update appveyor-with-compiler.cmd


@echo on

call ./ci/tools/threads.bat

set "VSCMD_START_DIR=%CD%"
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"

cd tests

rem set build_root=build_windows_x86_msvc
call :compile "build_windows_x86_msvc_nointr"   "-DMIPP_NO_INTRINSICS"
call :compile "build_windows_x86_msvc_sse2"     "/arch:SSE2   -D__SSE__ -D__SSE2__"
call :compile "build_windows_x86_msvc_sse3"     "/arch:SSE3   -D__SSE__ -D__SSE2__ -D__SSE3__"
call :compile "build_windows_x86_msvc_ssse3"    "/arch:SSSE3  -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__"
call :compile "build_windows_x86_msvc_sse4_1"   "/arch:SSE4.1 -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__"
call :compile "build_windows_x86_msvc_sse4_2"   "/arch:SSE4.2 -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__"
call :compile "build_windows_x86_msvc_avx"      "/arch:AVX    -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__AVX__"
call :compile "build_windows_x86_msvc_avx2_fma" "/arch:AVX2   -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__AVX__ -D__AVX2__ -D__FMA__"
rem call :compile "build_windows_x86_msvc_avx512f"  "/arch:AVX512"

exit /B %ERRORLEVEL%

:compile
set build=%~1%
set params=%~2%
mkdir %build%
cd %build%
cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_CXX_FLAGS="-D_CRT_SECURE_NO_DEPRECATE /EHsc /MP%THREADS% %params%"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
devenv /build Release MIPP_tests.sln
rem msbuild MIPP_tests.sln /t:Build /p:Configuration=Release
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
move bin\Release\* bin\
rmdir bin\Release\
cd ..
exit /B 0

@echo on

call ./ci/tools/threads.bat

set "VSCMD_START_DIR=%CD%"
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat"

cd tests

rem set build_root=build_windows_x86_msvc
call :compile "build_windows_x86_msvc_nointr"   "-DMIPP_NO_INTRINSICS"
call :compile "build_windows_x86_msvc_sse2"     "/arch:SSE2   -D__SSE__ -D__SSE2__"
call :compile "build_windows_x86_msvc_sse3"     "/arch:SSE3   -D__SSE__ -D__SSE2__ -D__SSE3__"
call :compile "build_windows_x86_msvc_ssse3"    "/arch:SSSE3  -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__"
call :compile "build_windows_x86_msvc_sse4_1"   "/arch:SSE4.1 -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__"
call :compile "build_windows_x86_msvc_sse4_2"   "/arch:SSE4.2 -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__"
call :compile "build_windows_x86_msvc_avx"      "/arch:AVX    -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__AVX__"
call :compile "build_windows_x86_msvc_avx2_fma" "/arch:AVX2   -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__AVX__ -D__AVX2__ -D__FMA__"
rem call :compile "build_windows_x86_msvc_avx512f"  "/arch:AVX512"

exit /B %ERRORLEVEL%

:compile
set build=%~1%
set params=%~2%
mkdir %build%
cd %build%
cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_CXX_FLAGS="-D_CRT_SECURE_NO_DEPRECATE /EHsc /MP%THREADS% %params%"
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
rem devenv /build Release MIPP_tests.sln
msbuild MIPP_tests.sln /t:Build /p:Configuration=Release
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
move bin\Release\* bin\
rmdir bin\Release\
cd ..
exit /B 0

use `msbuild` instead of `devenv`.

CI: use `msbuild` instead of `devenv`.


cd ..
del/q scintilla.zip
zip scintilla.zip scintilla\*.* scintilla\*\*.* -x *.o -x *.obj -x *.dll -x *.lib
cd scintilla

cd ..
del/q scintilla.zip
zip scintilla.zip scintilla\*.* scintilla\*\*.* -x *.o -x *.obj -x *.dll -x *.lib -x *.res
cd scintilla

Remove *.res from files zipped.

Remove *.res from files zipped.


@ECHO OFF

SET BASEDIR=%~dp0..
SET USERINI=%BASEDIR%\user.ini
FOR /F "tokens=1,2 delims=:" %%a in ("%STEELTOE_PCF_CREDENTIALS%") do (
   set CF_USER=%%a
   set CF_PASS=%%b
)

SET PYTHON_HOME=C:\Python36
SET DOTNET_HOME=C:\Program Files\dotnet
SET MAVEN_HOME=C:\opt\apache-maven-3.3.9

ECHO [behave.userdata] > %USERINI%
ECHO cf_apiurl = api.run.pcfbeta.io >> %USERINI%
ECHO cf_org = STEELTOE >> %USERINI%
ECHO cf_username = %CF_USER% >> %USERINI%
ECHO cf_password = %CF_PASS% >> %USERINI%

SET PATH=%PYTHON_HOME%\Scripts;%DOTNET_HOME%;%MAVEN_HOME%\bin;%PATH%

CALL %BASEDIR%\test-setup
CALL %BASEDIR%\test-run %*

@ECHO OFF

SET BASEDIR=%~dp0..
SET USERINI=%BASEDIR%\user.ini
FOR /F "tokens=1,2 delims=:" %%a in ("%STEELTOE_PCF_CREDENTIALS%") do (
   set CF_USER=%%a
   set CF_PASS=%%b
)

SET PYTHON_HOME=C:\Python36
SET DOTNET_HOME=C:\Program Files\dotnet
SET JAVA_HOME=C:\opt\oracle-jdk-8
SET MAVEN_HOME=C:\opt\apache-maven-3.3.9

ECHO [behave.userdata] > %USERINI%
ECHO cf_apiurl = api.run.pcfbeta.io >> %USERINI%
ECHO cf_org = STEELTOE >> %USERINI%
ECHO cf_username = %CF_USER% >> %USERINI%
ECHO cf_password = %CF_PASS% >> %USERINI%

SET PATH=%PYTHON_HOME%\Scripts;%DOTNET_HOME%;%JAVA_HOME%\bin;%MAVEN_HOME%\bin;%PATH%

CALL %BASEDIR%\test-setup
CALL %BASEDIR%\test-run %*

Update path to Java 8

Update path to Java 8


@echo off

REM Licensed to the Apache Software Foundation (ASF) under one or more
REM contributor license agreements.  See the NOTICE file distributed with
REM this work for additional information regarding copyright ownership.
REM The ASF licenses this file to You under the Apache License, Version 2.0
REM (the "License"); you may not use this file except in compliance with
REM the License.  You 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 implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.

setlocal enableextensions enabledelayedexpansion

set bin=%~dp0

:loop
if "%~1"=="" goto cont
if /I "%~1"=="-h" goto usage
if /I "%~1"=="-d" (
    set INTERPRETER_DIR=%~2
    set INTERPRETER_ID=%~n2
)
if /I "%~1"=="-p" set PORT=%~2
if /I "%~1"=="-l" set LOCAL_INTERPRETER_REPO=%~2
shift
goto loop
:cont

if "%PORT%"=="" goto usage
if "%INTERPRETER_DIR%"=="" goto usage

call "%bin%\common.cmd"

if exist "%ZEPPELIN_HOME%\zeppelin-interpreter\target\classes" (
    set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%ZEPPELIN_HOME%\zeppelin-interpreter\target\classes"
)

REM add test classes for unittest
if exist "%ZEPPELIN_HOME%\zeppelin-interpreter\target\test-classes" (
    set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%ZEPPELIN_HOME%\zeppelin-interpreter\target\test-classes"
)
if exist "%ZEPPELIN_HOME%\zeppelin-zengine\target\test-classes" (
    set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%ZEPPELIN_HOME%\zeppelin-zengine\target\test-classes"
)

call "%bin%\functions.cmd" ADDJARINDIR "%ZEPPELIN_HOME%\zeppelin-interpreter\target\lib"
call "%bin%\functions.cmd" ADDJARINDIR "%ZEPPELIN_HOME%\lib\interpreter"
call "%bin%\functions.cmd" ADDJARINDIR "%INTERPRETER_DIR%"

set HOSTNAME=%COMPUTERNAME%
set ZEPPELIN_SERVER=org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer

set ZEPPELIN_LOGFILE=%ZEPPELIN_LOG_DIR%\zeppelin-interpreter-%INTERPRETER_ID%-%ZEPPELIN_IDENT_STRING%-%HOSTNAME%.log

if not exist "%ZEPPELIN_LOG_DIR%" (
    echo Log dir doesn't exist, create %ZEPPELIN_LOG_DIR%
    mkdir "%ZEPPELIN_LOG_DIR%"
)

if /I "%INTERPRETER_ID%"=="spark" (
    if defined SPARK_HOME (
        set SPARK_SUBMIT=%SPARK_HOME%\bin\spark-submit.cmd
        for %%d in ("%ZEPPELIN_HOME%\interpreter\spark\zeppelin-spark*.jar") do (
            set SPARK_APP_JAR=%%d
        )
        set ZEPPELIN_CLASSPATH="!SPARK_APP_JAR!"

        for %%d in ("%SPARK_HOME%\python\lib\py4j-*-src.zip") do (
            set py4j=%%d
        )

        if not defined PYTHONPATH (
            set PYTHONPATH=!py4j!;%SPARK_HOME%\python
        ) else (
            set PYTHONPATH=!py4j!;%SPARK_HOME%\python;%PYTHONPATH%
        )
    ) else (
        if defined HADOOP_HOME if exist "%HADOOP_HOME%\bin\hadoop.cmd" (
            for /f "tokens=*" %%d in ('"%HADOOP_HOME%\bin\hadoop.cmd" classpath') do (
                set LOCAL_HADOOP_CLASSPATH=%%d
            )
            set ZEPPELIN_CLASSPATH=!LOCAL_HADOOP_CLASSPATH!;%ZEPPELIN_CLASSPATH%
        )

        call "%bin%\functions.cmd" ADDJARINDIR "%INTERPRETER_DIR%\dep"

        for %%d in ("%ZEPPELIN_HOME%\interpreter\spark\pyspark\py4j-*-src.zip") do (
            set py4j=%%d
        )

        set PYSPARKPATH=%ZEPPELIN_HOME%\interpreter\spark\pyspark\pyspark.zip;!py4j!

        if not defined PYTHONPATH (
            set PYTHONPATH=!PYSPARKPATH!
        ) else (
            set PYTHONPATH=%PYTHONPATH%;!PYSPARKPATH!
        )

        set PYSPARKPATH=

        if defined HADOOP_HOME if not defined HADOOP_CONF_DIR (
            if exist "%HADOOP_HOME%\etc\hadoop" (
                set HADOOP_CONF_DIR=%HADOOP_HOME%\etc\hadoop
            )
        )

        if exist "%HADOOP_CONF_DIR%" (
            set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%HADOOP_CONF_DIR%"
        )
    )
)

call "%bin%\functions.cmd" ADDJARINDIR "%LOCAL_INTERPRETER_REPO%"

if not defined ZEPPELIN_CLASSPATH_OVERRIDES (
    set CLASSPATH=%ZEPPELIN_CLASSPATH%
) else (
    set CLASSPATH=%ZEPPELIN_CLASSPATH_OVERRIDES%;%ZEPPELIN_CLASSPATH%
)

if defined SPARK_SUBMIT (
    set JAVA_INTP_OPTS=%JAVA_INTP_OPTS% -Dzeppelin.log.file='%ZEPPELIN_LOGFILE%'

    "%SPARK_SUBMIT%" --class %ZEPPELIN_SERVER% --jars %CLASSPATH% --driver-java-options "!JAVA_INTP_OPTS!" %SPARK_SUBMIT_OPTIONS% "%SPARK_APP_JAR%" %PORT%
) else (
    set JAVA_INTP_OPTS=%JAVA_INTP_OPTS% -Dzeppelin.log.file="%ZEPPELIN_LOGFILE%"

    "%ZEPPELIN_RUNNER%" !JAVA_INTP_OPTS! %ZEPPELIN_INTP_MEM% -cp %ZEPPELIN_CLASSPATH_OVERRIDES%;%CLASSPATH% %ZEPPELIN_SERVER% %PORT%
)

exit /b

:usage
echo Usage: %~n0 -p ^<port^> -d ^<interpreter dir to load^> -l ^<local interpreter repo dir to load^>

@echo off

REM Licensed to the Apache Software Foundation (ASF) under one or more
REM contributor license agreements.  See the NOTICE file distributed with
REM this work for additional information regarding copyright ownership.
REM The ASF licenses this file to You under the Apache License, Version 2.0
REM (the "License"); you may not use this file except in compliance with
REM the License.  You 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 implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.

setlocal enableextensions enabledelayedexpansion

set bin=%~dp0

:loop
if "%~1"=="" goto cont
if /I "%~1"=="-h" goto usage
if /I "%~1"=="-d" (
    set INTERPRETER_DIR=%~2
    set INTERPRETER_ID=%~n2
)
if /I "%~1"=="-p" set PORT=%~2
if /I "%~1"=="-c" set CALLBACK_HOST=%~2
if /I "%~1"=="-l" set LOCAL_INTERPRETER_REPO=%~2
shift
goto loop
:cont

if "%PORT%"=="" goto usage
if "%INTERPRETER_DIR%"=="" goto usage

call "%bin%\common.cmd"

if exist "%ZEPPELIN_HOME%\zeppelin-interpreter\target\classes" (
    set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%ZEPPELIN_HOME%\zeppelin-interpreter\target\classes"
)

REM add test classes for unittest
if exist "%ZEPPELIN_HOME%\zeppelin-interpreter\target\test-classes" (
    set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%ZEPPELIN_HOME%\zeppelin-interpreter\target\test-classes"
)
if exist "%ZEPPELIN_HOME%\zeppelin-zengine\target\test-classes" (
    set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%ZEPPELIN_HOME%\zeppelin-zengine\target\test-classes"
)

call "%bin%\functions.cmd" ADDJARINDIR "%ZEPPELIN_HOME%\zeppelin-interpreter\target\lib"
call "%bin%\functions.cmd" ADDJARINDIR "%ZEPPELIN_HOME%\lib\interpreter"
call "%bin%\functions.cmd" ADDJARINDIR "%INTERPRETER_DIR%"

set HOSTNAME=%COMPUTERNAME%
set ZEPPELIN_SERVER=org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer

set ZEPPELIN_LOGFILE=%ZEPPELIN_LOG_DIR%\zeppelin-interpreter-%INTERPRETER_ID%-%ZEPPELIN_IDENT_STRING%-%HOSTNAME%.log

if not exist "%ZEPPELIN_LOG_DIR%" (
    echo Log dir doesn't exist, create %ZEPPELIN_LOG_DIR%
    mkdir "%ZEPPELIN_LOG_DIR%"
)

if /I "%INTERPRETER_ID%"=="spark" (
    if defined SPARK_HOME (
        set SPARK_SUBMIT=%SPARK_HOME%\bin\spark-submit.cmd
        for %%d in ("%ZEPPELIN_HOME%\interpreter\spark\zeppelin-spark*.jar") do (
            set SPARK_APP_JAR=%%d
        )
        set ZEPPELIN_CLASSPATH="!SPARK_APP_JAR!"

        for %%d in ("%SPARK_HOME%\python\lib\py4j-*-src.zip") do (
            set py4j=%%d
        )

        if not defined PYTHONPATH (
            set PYTHONPATH=!py4j!;%SPARK_HOME%\python
        ) else (
            set PYTHONPATH=!py4j!;%SPARK_HOME%\python;%PYTHONPATH%
        )
    ) else (
        if defined HADOOP_HOME if exist "%HADOOP_HOME%\bin\hadoop.cmd" (
            for /f "tokens=*" %%d in ('"%HADOOP_HOME%\bin\hadoop.cmd" classpath') do (
                set LOCAL_HADOOP_CLASSPATH=%%d
            )
            set ZEPPELIN_CLASSPATH=!LOCAL_HADOOP_CLASSPATH!;%ZEPPELIN_CLASSPATH%
        )

        call "%bin%\functions.cmd" ADDJARINDIR "%INTERPRETER_DIR%\dep"

        for %%d in ("%ZEPPELIN_HOME%\interpreter\spark\pyspark\py4j-*-src.zip") do (
            set py4j=%%d
        )

        set PYSPARKPATH=%ZEPPELIN_HOME%\interpreter\spark\pyspark\pyspark.zip;!py4j!

        if not defined PYTHONPATH (
            set PYTHONPATH=!PYSPARKPATH!
        ) else (
            set PYTHONPATH=%PYTHONPATH%;!PYSPARKPATH!
        )

        set PYSPARKPATH=

        if defined HADOOP_HOME if not defined HADOOP_CONF_DIR (
            if exist "%HADOOP_HOME%\etc\hadoop" (
                set HADOOP_CONF_DIR=%HADOOP_HOME%\etc\hadoop
            )
        )

        if exist "%HADOOP_CONF_DIR%" (
            set ZEPPELIN_CLASSPATH=%ZEPPELIN_CLASSPATH%;"%HADOOP_CONF_DIR%"
        )
    )
)

call "%bin%\functions.cmd" ADDJARINDIR "%LOCAL_INTERPRETER_REPO%"

if not defined ZEPPELIN_CLASSPATH_OVERRIDES (
    set CLASSPATH=%ZEPPELIN_CLASSPATH%
) else (
    set CLASSPATH=%ZEPPELIN_CLASSPATH_OVERRIDES%;%ZEPPELIN_CLASSPATH%
)

if defined SPARK_SUBMIT (
    set JAVA_INTP_OPTS=%JAVA_INTP_OPTS% -Dzeppelin.log.file='%ZEPPELIN_LOGFILE%'

    "%SPARK_SUBMIT%" --class %ZEPPELIN_SERVER% --jars %CLASSPATH% --driver-java-options "!JAVA_INTP_OPTS!" %SPARK_SUBMIT_OPTIONS% "%SPARK_APP_JAR%" "%CALLBACK_HOST%" %PORT%
) else (
    set JAVA_INTP_OPTS=%JAVA_INTP_OPTS% -Dzeppelin.log.file="%ZEPPELIN_LOGFILE%"

    "%ZEPPELIN_RUNNER%" !JAVA_INTP_OPTS! %ZEPPELIN_INTP_MEM% -cp %ZEPPELIN_CLASSPATH_OVERRIDES%;%CLASSPATH% %ZEPPELIN_SERVER% "%CALLBACK_HOST%" %PORT%
)

exit /b

:usage
echo Usage: %~n0 -p ^<port^> -d ^<interpreter dir to load^> -l ^<local interpreter repo dir to load^>

fix interpreter.cmd script

[HOTFIX] fix interpreter.cmd script

### What is this PR for?
interpreter.cmd works incorrect after https://github.com/apache/zeppelin/pull/2562

### What type of PR is it?
Bug Fix

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: tinkoff-dwh <tinkoff.dwh@gmail.com>

Closes #2607 from tinkoff-dwh/master and squashes the following commits:

1932202 [tinkoff-dwh] Merge remote-tracking branch 'upstream/master'
c7f5124 [tinkoff-dwh] Merge remote-tracking branch 'upstream/master'
8baa87b [tinkoff-dwh] [HOTFIX] fix interpreter.cmd script


@echo off
setlocal

set SourceDir=%~dp0.

set BuildDir=%~dp0../build/win_msvc_x86-64_debug
if not exist "%BuildDir%" mkdir "%BuildDir%"

pushd "%BuildDir%"
  set CFlags=/nologo /MTd /Zi /DEBUG
  set LFlags=/INCREMENTAL:NO
  set Libs=User32.lib Gdi32.lib
  cl %CFlags% "%SourceDir%/win32_main.cpp" /Fe"main.exe" /link %LFlags% %Libs%
popd

@echo off
setlocal

set SourceDir=%~dp0.

set BuildDir=%~dp0../build/win_msvc_x86-64_debug
if not exist "%BuildDir%" mkdir "%BuildDir%"

pushd "%BuildDir%"
  set CFlags=/nologo /MTd /Zi /DEBUG
  set LFlags=/INCREMENTAL:NO
  set Libs=User32.lib Gdi32.lib
  cl %CFlags% "%SourceDir%/win32_main.cpp" /Fe"couscous.exe" /link %LFlags% %Libs%
popd

Change output to couscous.exe

Change output to couscous.exe


@echo Off
rem Trigger build process for NFluent
rem usage build [Target] [Configuration]. Configuration is Release by default
Rem target is either 'nightly' (default) for nightly build, 'RC' for release candidate, 'release' for release package
Rem those targets build a tested packaged and pushed it on nuget (assuming a publishing key has been setup)
Rem other targets (e.G. CI) build 'alpha package'
cls
set target=%1
if "%target%"=="" (
	set target=%NFLUENT_STREAM%
)
if "%target%"=="" (
	set target=CI
)
set config=%2
if "%config%" == "" (
   set config=Release
)

set extraOpt=""
if defined APPVEYOR (
    set extraOpt="/logger:""C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"""
)

msbuild .\.build\Build.proj /t:%target% /p:Configuration="%config%" /fl /v:m /flp:LogFile=msbuild.log;Verbosity=Diagnostic /nr:false %extraOpt%

@echo Off
rem Trigger build process for NFluent
rem usage build [Target] [Configuration]. Configuration is Release by default
Rem target is either 'nightly' (default) for nightly build, 'RC' for release candidate, 'release' for release package
Rem those targets build a tested packaged and pushed it on nuget (assuming a publishing key has been setup)
Rem other targets (e.G. CI) build 'alpha package'
cls
set target=%1
if "%target%"=="" (
	set target=%NFLUENT_STREAM%
)
if "%target%"=="" (
	set target=CI
)
set config=%2
if "%config%" == "" (
   set config=Release
)

set extraOpt=""
if defined APPVEYOR (
    set extraOpt=/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
)

msbuild .\.build\Build.proj /t:%target% /p:Configuration="%config%" /fl /v:m /flp:LogFile=msbuild.log;Verbosity=Diagnostic /nr:false %extraOpt%

fix MSBuild command line error

CI: fix MSBuild command line error


gcc -o map_stuff.exe map_stuff.c map_lib.c

Create comp.bat

Create comp.bat


del "output\correct_output.txt"
call scripts_list >> "output\correct_output.txt"

Add file refresh_tests.bat

Add file refresh_tests.bat


:: USAGE
::     cmdize name [...]
::
:: This tool converts a supported code into a batch file that can be
:: executed without explicit invoking the executable engine. The script
:: creates new file and places it under the same directory as the original
:: one with the same name, replacing the original extension with ".bat".
:: The content of the new file consists of the original file and the
:: special header that being the "polyglot" and having some tricks to be a
:: valid code in batch file and the wrapped code at the same time.
::
:: FEATURES
:: It does comment on "Option Explicit" in VBScript.
:: "<?xml?>" declaration for wsf-files is expected.
:: "Option Explicit" and "<?xml?>" in a single line only are supported.
:: BOM is not supported at all.
::
:: It is possible to select an engine for JavaScript, VBScript and WSF via
:: the command line options /E. If it is not pointed especially, CSCRIPT
:: is used as the default engine for all JavaScript, VBScript and WSF
:: files. Another valid engine is WSCRIPT. Additionally for JavaScript
:: files it is possible to set another engine such as NodeJS, Rhino etc.
:: The predefined option /E DEFAULT resets any previously set engines to
:: the default value.
::
:: SEE ALSO
:: Proceed the following links to learn more the origins
::
:: .js
:: http://forum.script-coding.com/viewtopic.php?pid=79210#p79210
:: http://www.dostips.com/forum/viewtopic.php?p=33879#p33879
:: https://gist.github.com/ildar-shaimordanov/88d7a5544c0eeacaa3bc
::
:: .vbs
:: http://www.dostips.com/forum/viewtopic.php?p=33882#p33882
:: http://www.dostips.com/forum/viewtopic.php?p=32485#p32485
::
:: .pl
:: For details and better support see "pl2bat.bat" from Perl distribution
::
:: .ps1
:: http://blogs.msdn.com/b/jaybaz_ms/archive/2007/04/26/powershell-polyglot.aspx
:: http://stackoverflow.com/a/2611487/3627676
::
:: .hta and .html?
:: http://forum.script-coding.com/viewtopic.php?pid=79322#p79322
::
:: .wsf
:: http://www.dostips.com/forum/viewtopic.php?p=33963#p33963
::
:: COPYRIGHTS
:: Copyright (c) 2014, 2015 Ildar Shaimordanov

@echo off

if "%~1" == "" (
	for %%p in ( powershell.exe ) do if not "%%~$PATH:p" == "" (
		"%%~$PATH:p" -NoProfile -NoLogo -Command "cat '%~f0' | where { $_ -match '^::' } | %% { $_ -replace '::', '' }"
		goto :EOF
	)
	for /f "usebackq tokens=* delims=:" %%s in ( "%~f0" ) do (
		if /i "%%s" == "@echo off" goto :EOF
		echo:%%s
	)
	goto :EOF
)

:cmdize.loop.begin
if "%~1" == "" goto :cmdize.loop.end

if /i "%~1" == "/e" (
	set "CMDIZE_ENGINE="
	if /i not "%~2" == "default" set "CMDIZE_ENGINE=%~2"
	shift
	goto :cmdize.loop.continue
)

if not exist "%~f1" (
	echo:%~n0: File not found: "%~1">&2
	goto :cmdize.loop.continue
)

for %%x in ( .js .vbs .pl .ps1 .hta .htm .html .wsf ) do (
	if /i "%~x1" == "%%~x" (
		call :cmdize%%~x "%~1" >"%~dpn1.bat"
		goto :cmdize.loop.continue
	)
)

echo:%~n0: Unsupported extension: "%~1">&2

:cmdize.loop.continue

shift

goto :cmdize.loop.begin
:cmdize.loop.end

goto :EOF

:cmdize.js
if not defined CMDIZE_ENGINE set "CMDIZE_ENGINE=cscript"
set "CMDIZE_ENGINE_OPTS="
for %%e in ( "%CMDIZE_ENGINE%" ) do (
	if /i "%%~ne" == "cscript" set "CMDIZE_ENGINE_OPTS=//nologo //e:javascript"
	if /i "%%~ne" == "wscript" set "CMDIZE_ENGINE_OPTS=//nologo //e:javascript"
)

echo:0^</*! ::
echo:@echo off
echo:%CMDIZE_ENGINE% %CMDIZE_ENGINE_OPTS% "%%~f0" %%*
echo:goto :EOF */0;
type "%~f1"
goto :EOF

:cmdize.vbs.h
set /p "=::'" <nul
type "%TEMP%\%~n0.$$"
echo:%*
goto :EOF

:cmdize.vbs
if not defined CMDIZE_ENGINE set "CMDIZE_ENGINE=cscript"

copy /y nul + nul /a "%TEMP%\%~n0.$$" /a 1>nul

call :cmdize.vbs.h @echo off
call :cmdize.vbs.h %CMDIZE_ENGINE% //nologo //e:vbscript "%%%%~f0" %%%%*
call :cmdize.vbs.h goto :EOF

del /q "%TEMP%\%~n0.$$"
rem type "%~f1"
for /f "tokens=1,* delims=]" %%r in ( ' call "%windir%\System32\find.exe" /n /v "" ^<"%~f1" ' ) do (
	rem Filtering and commenting "Option Explicit".
	rem This ugly code tries as much as possible to recognize and
	rem comment this directive. It fails if "Option" and "Explicit"
	rem are located on two neighbor lines, consecutively, one by one.
	rem But it is too hard to imagine that there is someone who
	rem practices such a strange coding style.
	for /f "usebackq tokens=1,2" %%a in ( '%%s' ) do if /i "%%~a" == "Option" for /f "usebackq tokens=1,* delims=:'" %%i in ( 'x%%b' ) do if /i "%%~i" == "xExplicit" (
		echo:%~n0: Commenting Option Explicit in "%~1">&2
		echo:rem To prevent compilation error due to embedding into a batch file,
		echo:rem the following line was commented automatically.
		set /p "=rem " <nul
	)
	echo:%%s
)
goto :EOF

:cmdize.pl
echo:@rem = '--*-Perl-*--
echo:@echo off
echo:perl -x -S "%%~f0" %%*
echo:goto :EOF
echo:@rem ';
echo:#!perl
type "%~f1"
goto :EOF

:cmdize.ps1
echo:^<# :
echo:@echo off
echo:setlocal
echo:set "POWERSHELL_BAT_ARGS=%%*"
echo:if defined POWERSHELL_BAT_ARGS set "POWERSHELL_BAT_ARGS=%%POWERSHELL_BAT_ARGS:"=\"%%"
echo:endlocal ^& powershell -NoLogo -NoProfile -Command "$_ = $input; Invoke-Expression $( '$input = $_; $_ = \"\"; $args = @( &{ $args } %%POWERSHELL_BAT_ARGS%% );' + [String]::Join( [char]10, $( Get-Content \"%%~f0\" ) ) )"
echo:rem endlocal ^& powershell -NoLogo -NoProfile -Command "$input | &{ [ScriptBlock]::Create( ( Get-Content \"%%~f0\" ) -join [char]10 ).Invoke( @( &{ $args } %%POWERSHELL_BAT_ARGS%% ) ) }"
echo:goto :EOF
echo:#^>
type "%~f1"
goto :EOF

:cmdize.hta
:cmdize.htm
:cmdize.html
echo:^<!-- :
echo:@echo off
echo:start "" "%%windir%%\System32\mshta.exe" "%%~f0" %%*
echo:goto :EOF
echo:--^>
type "%~f1"
goto :EOF

:cmdize.wsf
if not defined CMDIZE_ENGINE set "CMDIZE_ENGINE=cscript"

for /f "usebackq tokens=1,2,* delims=?" %%a in ( "%~f1" ) do for /f "tokens=1,*" %%d in ( "%%b" ) do (
	rem We use this code to transform the "<?xml?>" declaration
	rem located at the very beginning of the file to the "polyglot"
	rem form to do it acceptable by the batch file.
	echo:%%a?%%d :
	echo:: %%e ?^>^<!--
	echo:@echo off
	echo:%CMDIZE_ENGINE% //nologo "%%~f0?.wsf" %%*
	echo:goto :EOF
	echo:: --%%c
	more +1 <"%~f1"
	goto :EOF
)
goto :EOF

rem EOF

:: USAGE
::     cmdize name [...]
::
:: This tool converts a supported code into a batch file that can be
:: executed without explicit invoking the executable engine. The script
:: creates new file and places it under the same directory as the original
:: one with the same name, replacing the original extension with ".bat".
:: The content of the new file consists of the original file and the
:: special header that being the "polyglot" and having some tricks to be a
:: valid code in batch file and the wrapped code at the same time.
::
:: FEATURES
:: It does comment on "Option Explicit" in VBScript.
:: "<?xml?>" declaration for wsf-files is expected.
:: "Option Explicit" and "<?xml?>" in a single line only are supported.
:: BOM is not supported at all.
::
:: It is possible to select an engine for JavaScript, VBScript and WSF via
:: the command line options /E. If it is not pointed especially, CSCRIPT
:: is used as the default engine for all JavaScript, VBScript and WSF
:: files. Another valid engine is WSCRIPT. Additionally for JavaScript
:: files it is possible to set another engine such as NodeJS, Rhino etc.
:: The predefined option /E DEFAULT resets any previously set engines to
:: the default value.
::
:: SEE ALSO
:: Proceed the following links to learn more the origins
::
:: .js
:: http://forum.script-coding.com/viewtopic.php?pid=79210#p79210
:: http://www.dostips.com/forum/viewtopic.php?p=33879#p33879
:: https://gist.github.com/ildar-shaimordanov/88d7a5544c0eeacaa3bc
::
:: .vbs
:: http://www.dostips.com/forum/viewtopic.php?p=33882#p33882
:: http://www.dostips.com/forum/viewtopic.php?p=32485#p32485
::
:: .pl
:: For details and better support see "pl2bat.bat" from Perl distribution
::
:: .ps1
:: http://blogs.msdn.com/b/jaybaz_ms/archive/2007/04/26/powershell-polyglot.aspx
:: http://stackoverflow.com/a/2611487/3627676
::
:: .hta and .html?
:: http://forum.script-coding.com/viewtopic.php?pid=79322#p79322
::
:: .wsf
:: http://www.dostips.com/forum/viewtopic.php?p=33963#p33963
::
:: COPYRIGHTS
:: Copyright (c) 2014, 2015 Ildar Shaimordanov

@echo off

if "%~1" == "" (
	for %%p in ( powershell.exe ) do if not "%%~$PATH:p" == "" (
		"%%~$PATH:p" -NoProfile -NoLogo -Command "cat '%~f0' | where { $_ -match '^::' } | %% { $_ -replace '::', '' }"
		goto :EOF
	)
	for /f "usebackq tokens=* delims=:" %%s in ( "%~f0" ) do (
		if /i "%%s" == "@echo off" goto :EOF
		echo:%%s
	)
	goto :EOF
)

:cmdize.loop.begin
if "%~1" == "" goto :cmdize.loop.end

if /i "%~1" == "/e" (
	set "CMDIZE_ENGINE="
	if /i not "%~2" == "default" set "CMDIZE_ENGINE=%~2"
	shift
	goto :cmdize.loop.continue
)

if not exist "%~f1" (
	echo:%~n0: File not found: "%~1">&2
	goto :cmdize.loop.continue
)

for %%x in ( .js .vbs .pl .ps1 .hta .htm .html .wsf ) do (
	if /i "%~x1" == "%%~x" (
		call :cmdize%%~x "%~1" >"%~dpn1.bat"
		goto :cmdize.loop.continue
	)
)

echo:%~n0: Unsupported extension: "%~1">&2

:cmdize.loop.continue

shift

goto :cmdize.loop.begin
:cmdize.loop.end

goto :EOF

:cmdize.js
if not defined CMDIZE_ENGINE set "CMDIZE_ENGINE=cscript"
set "CMDIZE_ENGINE_OPTS="
for %%e in ( "%CMDIZE_ENGINE%" ) do (
	if /i "%%~ne" == "cscript" set "CMDIZE_ENGINE_OPTS=//nologo //e:javascript"
	if /i "%%~ne" == "wscript" set "CMDIZE_ENGINE_OPTS=//nologo //e:javascript"
)

echo:0^</*! ::
echo:@echo off
echo:%CMDIZE_ENGINE% %CMDIZE_ENGINE_OPTS% "%%~f0" %%*
echo:goto :EOF */0;
type "%~f1"
goto :EOF

:cmdize.vbs.h
set /p "=::'" <nul
type "%TEMP%\%~n0.$$"
echo:%*
goto :EOF

:cmdize.vbs
if not defined CMDIZE_ENGINE set "CMDIZE_ENGINE=cscript"

copy /y nul + nul /a "%TEMP%\%~n0.$$" /a 1>nul

call :cmdize.vbs.h @echo off
call :cmdize.vbs.h %CMDIZE_ENGINE% //nologo //e:vbscript "%%%%~f0" %%%%*
call :cmdize.vbs.h goto :EOF

del /q "%TEMP%\%~n0.$$"
rem type "%~f1"
for /f "tokens=1,* delims=]" %%r in ( ' call "%windir%\System32\find.exe" /n /v "" ^<"%~f1" ' ) do (
	rem Filtering and commenting "Option Explicit".
	rem This ugly code tries as much as possible to recognize and
	rem comment this directive. It fails if "Option" and "Explicit"
	rem are located on two neighbor lines, consecutively, one by one.
	rem But it is too hard to imagine that there is someone who
	rem practices such a strange coding style.
	for /f "usebackq tokens=1,2" %%a in ( '%%s' ) do if /i "%%~a" == "Option" for /f "usebackq tokens=1,* delims=:'" %%i in ( 'x%%b' ) do if /i "%%~i" == "xExplicit" (
		echo:%~n0: Commenting Option Explicit in "%~1">&2
		echo:rem To prevent compilation error due to embedding into a batch file,
		echo:rem the following line was commented automatically.
		set /p "=rem " <nul
	)
	echo:%%s
)
goto :EOF

:cmdize.pl
echo:@rem = '--*-Perl-*--
echo:@echo off
echo:perl -x -S "%%~f0" %%*
echo:goto :EOF
echo:@rem ';
echo:#!perl
type "%~f1"
goto :EOF

:cmdize.ps1
echo:^<# :
echo:@echo off
echo:setlocal
echo:set "POWERSHELL_BAT_ARGS=%%*"
echo:if defined POWERSHELL_BAT_ARGS set "POWERSHELL_BAT_ARGS=%%POWERSHELL_BAT_ARGS:"=\"%%"
echo:endlocal ^& powershell -NoLogo -NoProfile -Command "$_ = $input; Invoke-Expression $( '$input = $_; $_ = \"\"; $args = @( &{ $args } %%POWERSHELL_BAT_ARGS%% );' + [String]::Join( [char]10, $( Get-Content \"%%~f0\" ) ) )"
echo:rem endlocal ^& powershell -NoLogo -NoProfile -Command "$input | &{ [ScriptBlock]::Create( ( Get-Content \"%%~f0\" ) -join [char]10 ).Invoke( @( &{ $args } %%POWERSHELL_BAT_ARGS%% ) ) }"
echo:goto :EOF
echo:#^>
type "%~f1"
goto :EOF

:cmdize.hta
:cmdize.htm
:cmdize.html
echo:^<!-- :
echo:@echo off
echo:start "" mshta "%%~f0" %%*
echo:goto :EOF
echo:--^>
type "%~f1"
goto :EOF

:cmdize.wsf
if not defined CMDIZE_ENGINE set "CMDIZE_ENGINE=cscript"

for /f "usebackq tokens=1,2,* delims=?" %%a in ( "%~f1" ) do for /f "tokens=1,*" %%d in ( "%%b" ) do (
	rem We use this code to transform the "<?xml?>" declaration
	rem located at the very beginning of the file to the "polyglot"
	rem form to do it acceptable by the batch file.
	echo:%%a?%%d :
	echo:: %%e ?^>^<!--
	echo:@echo off
	echo:%CMDIZE_ENGINE% //nologo "%%~f0?.wsf" %%*
	echo:goto :EOF
	echo:: --%%c
	more +1 <"%~f1"
	goto :EOF
)
goto :EOF

rem EOF

simplify code calling html/hta

cmdize: simplify code calling html/hta


@echo off
cls
"..\packages\NuGet.CommandLine.2.8.6\tools\NuGet.exe" "Install" "FAKE" "-OutputDirectory" "..\..\packages" "-ExcludeVersion"
"..\..\packages\FAKE\tools\Fake.exe" build.fsx
pause

@echo off
cls
"..\packages\NuGet.CommandLine.2.8.6\tools\NuGet.exe" "Install" "FAKE" "-OutputDirectory" "..\..\packages"
"..\..\packages\FAKE\tools\Fake.exe" build.fsx
pause

Remove ExcludedVersion from nuget package generation command line in buld.bat


"%R%" CMD INSTALL --build . %R_ARGS%
IF %ERRORLEVEL% NEQ 0 exit /B 1

Update bld.bat

Update bld.bat


@echo off

rem Process the command line arguments.
set flag_batch=0
for %%a in (%*) do (
    if "%%a"=="/batch" set flag_batch=1
)

rem Build Picol with MSVC.
echo on
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
echo on
nmake /F Makefile.nmake
@if "%flag_batch%"=="0" pause

@echo off

setlocal ENABLEDELAYEDEXPANSION

rem Process the command line arguments.
set flag_batch=0
set msvc_version=14.0
for %%a in (%*) do (
    set flag="%%a"
    if "!flag!"=="/batch" set flag_batch=1
    if "!flag:~0,9!"=="/version:" set version="!arg:~7!"
)

rem Build Picol with MSVC.
echo on
call "C:\Program Files (x86)\Microsoft Visual Studio %msvc_version%\VC\vcvarsall.bat"
echo on
nmake /F Makefile.nmake
@if "%flag_batch%"=="0" pause

build-msvc.cmd: Implement a switch for setting the Microsoft Visual Studio version: /version:foo.


@echo off
rem
rem Phoenix start script.
rem
rem Author: Peter Donald [donaldp@apache.org]
rem
rem Environment Variable Prequisites
rem
rem   PHOENIX_OPTS       (Optional) Java runtime options used when the command is
rem                      executed.
rem
rem   PHOENIX_TMPDIR     (Optional) Directory path location of temporary directory
rem                      the JVM should use (java.io.tmpdir).  Defaults to
rem                      $CATALINA_BASE/temp.
rem
rem   JAVA_HOME          Must point at your Java Development Kit installation.
rem
rem   PHOENIX_JVM_OPTS   (Optional) Java runtime options used when the command is
rem                       executed.
rem
rem -----------------------------------------------------------------------------

rem
rem Determine if JAVA_HOME is set and if so then use it
rem
if not "%JAVA_HOME%"=="" goto found_java

set PHOENIX_JAVACMD=java
goto file_locate

:found_java
set PHOENIX_JAVACMD=%JAVA_HOME%\bin\java

:file_locate

rem
rem Locate where phoenix is in filesystem
rem
if not "%OS%"=="Windows_NT" goto start

rem %~dp0 is name of current script under NT
set PHOENIX_HOME=%~dp0

rem : operator works similar to make : operator
set PHOENIX_HOME=%PHOENIX_HOME:\bin\=%

:start

if not "%PHOENIX_HOME%" == "" goto phoenix_home

echo.
echo Warning: PHOENIX_HOME environment variable is not set.
echo   This needs to be set for Win9x as it's command prompt
echo   scripting bites
echo.
goto end

:phoenix_home

if not "%PHOENIX_TMPDIR%"=="" goto afterTmpDir
set PHOENIX_TMPDIR=%PHOENIX_HOME%\temp
if not exist "%PHOENIX_TMPDIR%" mkdir %PHOENIX_TMPDIR%

:afterTmpDir

echo Using PHOENIX_HOME:   %PHOENIX_HOME%
echo Using PHOENIX_TMPDIR: %PHOENIX_TMPDIR%
echo Using JAVA_HOME:      %JAVA_HOME%

set PHOENIX_SM=

if "%PHOENIX_SECURE%" == "false" goto postSecure

rem Make Phoenix run with security Manager enabled
set PHOENIX_SM="-Djava.security.manager"

:postSecure

rem
rem -Djava.ext.dirs= is needed as some JVM vendors do foolish things
rem like placing jaxp/jaas/xml-parser jars in ext dir
rem thus breaking Phoenix
rem

rem uncomment to get enable remote debugging
rem set DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

rem Kicking the tires and lighting the fires!!!
"%PHOENIX_JAVACMD%" %DEBUG% "-Djava.ext.dirs=%PHOENIX_HOME%\lib" "-Dphoenix.home=%PHOENIX_HOME%" "-Djava.security.policy=jar:file:%PHOENIX_HOME%/bin/phoenix-loader.jar!/META-INF/java.policy" %PHOENIX_JVM_OPTS% %PHOENIX_SECURE% -jar "%PHOENIX_HOME%\bin\phoenix-loader.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9

:end

@echo off
rem
rem Phoenix start script.
rem
rem Author: Peter Donald [donaldp@apache.org]
rem
rem Environment Variable Prequisites
rem
rem   PHOENIX_OPTS       (Optional) Java runtime options used when the command is
rem                      executed.
rem
rem   PHOENIX_TMPDIR     (Optional) Directory path location of temporary directory
rem                      the JVM should use (java.io.tmpdir).  Defaults to
rem                      $CATALINA_BASE/temp.
rem
rem   JAVA_HOME          Must point at your Java Development Kit installation.
rem
rem   PHOENIX_JVM_OPTS   (Optional) Java runtime options used when the command is
rem                       executed.
rem
rem -----------------------------------------------------------------------------

rem
rem Determine if JAVA_HOME is set and if so then use it
rem
if not "%JAVA_HOME%"=="" goto found_java

set PHOENIX_JAVACMD=java
goto file_locate

:found_java
set PHOENIX_JAVACMD=%JAVA_HOME%\bin\java

:file_locate

rem
rem Locate where phoenix is in filesystem
rem
if not "%OS%"=="Windows_NT" goto start

rem %~dp0 is name of current script under NT
set PHOENIX_HOME=%~dp0

rem : operator works similar to make : operator
set PHOENIX_HOME=%PHOENIX_HOME:\bin\=%

:start

if not "%PHOENIX_HOME%" == "" goto phoenix_home

echo.
echo Warning: PHOENIX_HOME environment variable is not set.
echo   This needs to be set for Win9x as it's command prompt
echo   scripting bites
echo.
goto end

:phoenix_home

if not "%PHOENIX_TMPDIR%"=="" goto afterTmpDir
set PHOENIX_TMPDIR=%PHOENIX_HOME%\temp
if not exist "%PHOENIX_TMPDIR%" mkdir "%PHOENIX_TMPDIR%"

:afterTmpDir

echo Using PHOENIX_HOME:   %PHOENIX_HOME%
echo Using PHOENIX_TMPDIR: %PHOENIX_TMPDIR%
echo Using JAVA_HOME:      %JAVA_HOME%

set PHOENIX_SM=

if "%PHOENIX_SECURE%" == "false" goto postSecure

rem Make Phoenix run with security Manager enabled
set PHOENIX_SM="-Djava.security.manager"

:postSecure

rem
rem -Djava.ext.dirs= is needed as some JVM vendors do foolish things
rem like placing jaxp/jaas/xml-parser jars in ext dir
rem thus breaking Phoenix
rem

rem uncomment to get enable remote debugging
rem set DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

rem Kicking the tires and lighting the fires!!!
"%PHOENIX_JAVACMD%" %DEBUG% "-Djava.ext.dirs=%PHOENIX_HOME%\lib" "-Dphoenix.home=%PHOENIX_HOME%" "-Djava.security.policy=jar:file:%PHOENIX_HOME%/bin/phoenix-loader.jar!/META-INF/java.policy" %PHOENIX_JVM_OPTS% %PHOENIX_SECURE% -jar "%PHOENIX_HOME%\bin\phoenix-loader.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9

:end

Fix bug 20645.

Fix bug 20645.

git-svn-id: de9d04cf23151003780adc3e4ddb7078e3680318@108790 13f79535-47bb-0310-9956-ffa450edef68