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

@echo on

set BUILD_ROOT=%cd%
set SRC=%cd%\github\shaderc
set BUILD_TYPE=%1
set VS_VERSION=%2

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

cd %SRC%\third_party
git clone https://github.com/google/googletest.git
git clone https://github.com/google/glslang.git
git clone https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
git clone https://github.com/KhronosGroup/SPIRV-Headers.git spirv-headers
git clone https://github.com/google/re2
git clone https://github.com/google/effcee

cmake --version

:: If you need to pin googletest to a specific revision, uncomment
:: the following two lines (and set the commit hash).
:: cd googletest
:: git checkout e93da23920e5b6887d6a6a291c3a59f83f5b579e

cd %SRC%
mkdir build
cd %SRC%\build

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

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

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

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

echo "Build glslang... %DATE% %TIME%"
ninja glslangValidator
if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%

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

echo "Check Shaderc for copyright notices... %DATE% %TIME%"
ninja check-copyright
if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%
echo "Build Completed %DATE% %TIME%"

:: #########################################
:: Run the tests.
:: #########################################
echo "Running Tests... %DATE% %TIME%"
ctest -C %BUILD_TYPE% --output-on-failure -j4
if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%
echo "Tests Completed %DATE% %TIME%"

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

exit /b %ERRORLEVEL%

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

@echo on

set BUILD_ROOT=%cd%
set SRC=%cd%\github\shaderc
set BUILD_TYPE=%1
set VS_VERSION=%2

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

cd %SRC%\third_party
git clone https://github.com/google/googletest.git
git clone https://github.com/google/glslang.git
git clone https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
git clone https://github.com/KhronosGroup/SPIRV-Headers.git spirv-headers
git clone https://github.com/google/re2
git clone https://github.com/google/effcee

cmake --version

:: If you need to pin googletest to a specific revision, uncomment
:: the following two lines (and set the commit hash).
:: cd googletest
:: git checkout e93da23920e5b6887d6a6a291c3a59f83f5b579e

cd %SRC%
mkdir build
cd %SRC%\build

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

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

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

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

echo "Build glslang... %DATE% %TIME%"
ninja glslangValidator
if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%

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

echo "Check Shaderc for copyright notices... %DATE% %TIME%"
ninja check-copyright
if %ERRORLEVEL% GEQ 1 exit /b %ERRORLEVEL%
echo "Build Completed %DATE% %TIME%"

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

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

exit /b %ERRORLEVEL%

[kokoro] Stop running tests on VS 2013 builds. (#531)


@echo off

msbuild /p:Configuration=Debug /p:Platform=x64 Couchbase.Lite.Tests.UWP.csproj
vstest.console.exe /InIsolation /Platform:x64 AppPackages\Couchbase.Lite.Tests.UWP_1.0.0.0_x64_Debug_Test\Couchbase.Lite.Tests.UWP_1.0.0.0_x64_Debug.appx /Logger:trx /diag:diagnostic.txt

powershell Remove-AppxPackage -Package "eb9a8775-4322-4e36-a34c-eee261241f4e_1.0.0.0_x64__1v3rwxh47wwxj"

msbuild /p:Configuration=Release /p:Platform=x64 Couchbase.Lite.Tests.UWP.csproj
vstest.console.exe /InIsolation /Platform:x64 AppPackages\Couchbase.Lite.Tests.UWP_1.0.0.0_x64_Test\Couchbase.Lite.Tests.UWP_1.0.0.0_x64.appx /Logger:trx /diag:diagnostic.txt

@echo off

powershell Remove-AppxPackage -Package "eb9a8775-4322-4e36-a34c-eee261241f4e_1.0.0.0_x64__1v3rwxh47wwxj"

rmdir /s/q bin
rmdir /s/q obj
rmdir /s/q AppPackages

msbuild /t:Restore Couchbase.Lite.Tests.UWP.csproj
msbuild /p:Configuration=Debug /p:Platform=x64 /t:Rebuild Couchbase.Lite.Tests.UWP.csproj
vstest.console.exe /InIsolation /Platform:x64 AppPackages\Couchbase.Lite.Tests.UWP_1.0.0.0_x64_Debug_Test\Couchbase.Lite.Tests.UWP_1.0.0.0_x64_Debug.appx /Logger:trx /diag:diagnostic.txt

powershell Remove-AppxPackage -Package "eb9a8775-4322-4e36-a34c-eee261241f4e_1.0.0.0_x64__1v3rwxh47wwxj"

rmdir /s/q bin
rmdir /s/q obj
rmdir /s/q AppPackages

msbuild /t:Restore /p:Configuration=Release Couchbase.Lite.Tests.UWP.csproj
msbuild /p:Configuration=Release /p:Platform=x64 /t:Rebuild Couchbase.Lite.Tests.UWP.csproj
vstest.console.exe /InIsolation /Platform:x64 AppPackages\Couchbase.Lite.Tests.UWP_1.0.0.0_x64_Test\Couchbase.Lite.Tests.UWP_1.0.0.0_x64.appx /Logger:trx /diag:diagnostic.txt

Update UWP test script

Update UWP test script


@ECHO OFF
SETLOCAL
SET EL=0

ECHO =========== %~f0 ===========

SET APPVEYOR_REPO_COMMIT_MESSAGE=this is a [build appveyor] test
SET APPVEYOR=true

SET MAPNIK_GIT=3.0.5
SET BOOST_VERSION=58
SET FASTBUILD=1
SET configuration=Release
SET msvs_toolset=14
SET platform=x64
SET APPVEYOR_BUILD_FOLDER=%CD%
CALL scripts\build-appveyor.bat
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

GOTO DONE

:ERROR
ECHO =========== ERROR %~f0 ===========
ECHO ERRORLEVEL^: %ERRORLEVEL%
SET EL=%ERRORLEVEL%

:DONE
ECHO =========== DONE %~f0 ===========

EXIT /b %EL%

@ECHO OFF
SETLOCAL
SET EL=0

ECHO =========== %~f0 ===========

SET APPVEYOR_REPO_COMMIT_MESSAGE=this is a [build appveyor] test
SET APPVEYOR=true
::comment this to get complete AppVeyor behaviour
SET LOCAL_BUILD_DONT_SKIP_TESTS=true

SET MAPNIK_GIT=3.0.5
SET BOOST_VERSION=58
SET FASTBUILD=1
SET configuration=Release
SET msvs_toolset=14
SET platform=x64
SET APPVEYOR_BUILD_FOLDER=%CD%
CALL scripts\build-appveyor.bat
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

GOTO DONE

:ERROR
ECHO =========== ERROR %~f0 ===========
ECHO ERRORLEVEL^: %ERRORLEVEL%
SET EL=%ERRORLEVEL%

:DONE
ECHO =========== DONE %~f0 ===========

EXIT /b %EL%

allow speedy build AppVeyor style, but also run tests


@echo off
:: Microsoft Azure CLI - Windows Installer - Author file components script
:: Copyright (C) Microsoft Corporation. All Rights Reserved.
::
:: This re-builds partial WiX files for use in cloning the repo after install.
:: heat.exe from the WiX toolset is used for this.
::

:: to avoid https://github.com/npm/npm/issues/6438
chcp 850

set NODE_VERSION=0.10.23
set NPM_VERSION=1.3.17

:: Add Git to the path as this should be run through a .NET command prompt
:: and not a Git bash shell... We also need the gnu toolchain (for curl & unzip)
set PATH=%PATH%;"C:\Program Files (x86)\Git\bin;"

pushd %~dp0..\

set NODE_DOWNLOAD_URL=http://nodejs.org/dist/v%NODE_VERSION%/node.exe
set NPM_DOWNLOAD_URL=http://nodejs.org/dist/npm/npm-%NPM_VERSION%.zip

echo Cleaning previous build artifacts...

set OUTPUT_FOLDER=.\out
if exist %OUTPUT_FOLDER% rmdir /s /q %OUTPUT_FOLDER%
mkdir %OUTPUT_FOLDER%

set TEMP_REPO_FOLDER=azure-cli
set TEMP_REPO=%temp%\%TEMP_REPO_FOLDER%
if not exist %TEMP_REPO% goto CLONE_REPO

echo Temporary clone of the repo already exists. Removing it...
pushd %TEMP_REPO%\..\
if exist %TEMP_REPO_FOLDER% rmdir /s /q %TEMP_REPO_FOLDER%
if exist %TEMP_REPO_FOLDER% goto ERROR
popd

:CLONE_REPO
mkdir %TEMP_REPO%
echo Cloning the repo elsewhere on disk...
pushd ..\..\
robocopy . %TEMP_REPO% /MIR /XD .git tools features scripts test node_modules /NFL /NDL /NJH /NJS
if %errorlevel% geq 8 goto ERROR
popd

echo Downloading node and npm...
pushd %TEMP_REPO%\bin
curl -o node.exe %NODE_DOWNLOAD_URL%
if %errorlevel% neq 0 goto ERROR
curl -o npm.zip %NPM_DOWNLOAD_URL%
if %errorlevel% neq 0 goto ERROR
unzip -q npm.zip
if %errorlevel% neq 0 goto ERROR
del npm.zip
popd

echo Running npm install...
pushd %TEMP_REPO%
call bin/npm.cmd install --production
echo.
echo if YOU SEE A FAILURE AT THE BOTTOM OF THE NPM OUTPUT:
echo If you do not have Node.js installed on this local machine, the Azure
echo postinstall command run by npm will fail.
echo.
echo This is fine as long as only the Azure module had this issue. Onward!
echo.
popd

echo Compiling streamline files...
pushd %TEMP_REPO%
.\bin\node.exe node_modules\streamline\bin\_node --verbose -c lib
if %errorlevel% neq 0 goto ERROR
.\bin\node.exe node_modules\streamline\bin\_node --verbose -c node_modules\streamline\lib\streams
if %errorlevel% neq 0 goto ERROR
.\bin\node.exe node_modules\streamline\bin\_node --verbose -c node_modules\streamline-streams\lib
if %errorlevel% neq 0 goto ERROR
popd

echo Removing unneeded files from azure module...
pushd %TEMP_REPO%\node_modules\azure

for %%i in (
    packages
    scripts
    test
    tasks
    examples
    jsdoc
    lib\common
    lib\services\gallery
    lib\services\management
    lib\services\computeManagement
    lib\services\resourceManagement
    lib\services\serviceBusManagement
    lib\services\schedulerManagement
    lib\services\sqlManagement
    lib\services\storageManagement
    lib\services\storeManagement
    lib\services\subscriptionManagement
    lib\services\networkManagement
    lib\services\webSiteManagement
    lib\services\scheduler
) do (
    if exist %%i (
        echo Deleting %%i...
        rd /s /q %%i
    )
)

popd

echo Removing unncessary files from the enlistment for the CLI to function...
:: This is cleaner than using /EXCLUDE:... commands and easier to see line-by-line...
pushd %TEMP_REPO%

for %%i in (
    .idea
    __temp
    bin\node_modules
) do (
    if exist %%i (
        echo Deleting %%i...
        rd /s /q %%i
    )
)

for %%i in (
    *.md
    *.git*
    *.npm*
    azure_error
    azure.err
    checkstyle-result.xml
    test-result.xml
    .travis.yml
    .jshintrc
    .gitattributes
    .gitignore
    ChangeLog.txt
    bin\npm.cmd
    LICENSE.txt
) do (
    if exist %%i (
        echo Deleting %%i...
        del /q %%i
    )
)

echo.
popd

echo Creating the wbin (Windows binaries) folder that will be added to the path...
mkdir %TEMP_REPO%\wbin
copy .\scripts\azure.cmd %TEMP_REPO%\wbin\
if %errorlevel% neq 0 goto ERROR
echo Adding license documents...
copy ..\resources\*.rtf %TEMP_REPO%
if %errorlevel% neq 0 goto ERROR
copy ..\resources\ThirdPartyNotices.txt %TEMP_REPO%
if %errorlevel% neq 0 goto ERROR

echo.

:SUCCESS
echo Looks good.

goto END

:ERROR
echo Something happened. And this script just can't continue.
exit /b 1

:END
exit /b 0
popd

@echo off
:: Microsoft Azure CLI - Windows Installer - Author file components script
:: Copyright (C) Microsoft Corporation. All Rights Reserved.
::
:: This re-builds partial WiX files for use in cloning the repo after install.
:: heat.exe from the WiX toolset is used for this.
::

:: to avoid https://github.com/npm/npm/issues/6438
chcp 850

set NODE_VERSION=0.10.23
set NPM_VERSION=1.3.17

:: Add Git to the path as this should be run through a .NET command prompt
:: and not a Git bash shell... We also need the gnu toolchain (for curl & unzip)
set PATH=%PATH%;"C:\Program Files (x86)\Git\bin;"

pushd %~dp0..\

set NODE_DOWNLOAD_URL=http://nodejs.org/dist/v%NODE_VERSION%/node.exe
set NPM_DOWNLOAD_URL=http://nodejs.org/dist/npm/npm-%NPM_VERSION%.zip

echo Cleaning previous build artifacts...

set OUTPUT_FOLDER=.\out
if exist %OUTPUT_FOLDER% rmdir /s /q %OUTPUT_FOLDER%
mkdir %OUTPUT_FOLDER%

set TEMP_REPO_FOLDER=azure-cli
set TEMP_REPO=%temp%\%TEMP_REPO_FOLDER%
if not exist %TEMP_REPO% goto CLONE_REPO

echo Temporary clone of the repo already exists. Removing it...
pushd %TEMP_REPO%\..\
if exist %TEMP_REPO_FOLDER% rmdir /s /q %TEMP_REPO_FOLDER%
::rmdir always returns 0, so check folder's existence
if exist %TEMP_REPO_FOLDER% goto ERROR
popd

:CLONE_REPO
mkdir %TEMP_REPO%
echo Cloning the repo elsewhere on disk...
pushd ..\..\
robocopy . %TEMP_REPO% /MIR /XD .git tools features scripts test node_modules /NFL /NDL /NJH /NJS
if %errorlevel% geq 8 goto ERROR
popd

echo Downloading node and npm...
pushd %TEMP_REPO%\bin
curl -o node.exe %NODE_DOWNLOAD_URL%
if %errorlevel% neq 0 goto ERROR
curl -o npm.zip %NPM_DOWNLOAD_URL%
if %errorlevel% neq 0 goto ERROR
unzip -q npm.zip
if %errorlevel% neq 0 goto ERROR
del npm.zip
popd

echo Running npm install...
pushd %TEMP_REPO%
call bin/npm.cmd install --production
echo.
echo if YOU SEE A FAILURE AT THE BOTTOM OF THE NPM OUTPUT:
echo If you do not have Node.js installed on this local machine, the Azure
echo postinstall command run by npm will fail.
echo.
echo This is fine as long as only the Azure module had this issue. Onward!
echo.
popd

echo Compiling streamline files...
pushd %TEMP_REPO%
.\bin\node.exe node_modules\streamline\bin\_node --verbose -c lib
if %errorlevel% neq 0 goto ERROR
.\bin\node.exe node_modules\streamline\bin\_node --verbose -c node_modules\streamline\lib\streams
if %errorlevel% neq 0 goto ERROR
.\bin\node.exe node_modules\streamline\bin\_node --verbose -c node_modules\streamline-streams\lib
if %errorlevel% neq 0 goto ERROR
popd

echo Removing unneeded files from azure module...
pushd %TEMP_REPO%\node_modules\azure

for %%i in (
    packages
    scripts
    test
    tasks
    examples
    jsdoc
    lib\common
    lib\services\gallery
    lib\services\management
    lib\services\computeManagement
    lib\services\resourceManagement
    lib\services\serviceBusManagement
    lib\services\schedulerManagement
    lib\services\sqlManagement
    lib\services\storageManagement
    lib\services\storeManagement
    lib\services\subscriptionManagement
    lib\services\networkManagement
    lib\services\webSiteManagement
    lib\services\scheduler
) do (
    if exist %%i (
        echo Deleting %%i...
        rmdir /s /q %%i
    )
)

popd

echo Removing unncessary files from the enlistment for the CLI to function...
:: This is cleaner than using /EXCLUDE:... commands and easier to see line-by-line...
pushd %TEMP_REPO%

for %%i in (
    .idea
    __temp
    bin\node_modules
) do (
    if exist %%i (
        echo Deleting %%i...
        rmdir /s /q %%i
    )
)

for %%i in (
    *.md
    *.git*
    *.npm*
    azure_error
    azure.err
    checkstyle-result.xml
    test-result.xml
    .travis.yml
    .jshintrc
    .gitattributes
    .gitignore
    ChangeLog.txt
    bin\npm.cmd
    LICENSE.txt
) do (
    if exist %%i (
        echo Deleting %%i...
        del /q %%i
    )
)

echo.
popd

echo Creating the wbin (Windows binaries) folder that will be added to the path...
mkdir %TEMP_REPO%\wbin
copy .\scripts\azure.cmd %TEMP_REPO%\wbin\
if %errorlevel% neq 0 goto ERROR
echo Adding license documents...
copy ..\resources\*.rtf %TEMP_REPO%
if %errorlevel% neq 0 goto ERROR
copy ..\resources\ThirdPartyNotices.txt %TEMP_REPO%
if %errorlevel% neq 0 goto ERROR

echo.

:SUCCESS
echo Looks good.

goto END

:ERROR
echo Something happened. And this script just can't continue.
exit /b 1

:END
exit /b 0
popd

add comment for checking the result of rmdir


@if not defined _echo echo off
setlocal

:parseArguments
if "%1"=="" goto doneParsingArguments
if /i "%1"=="--scope" set SCOPE=%2&& shift && shift && goto parseArguments
if /i "%1"=="--target" set TARGET=%2&& shift && shift && goto parseArguments
if /i "%1"=="--host" set HOST=%2&& shift && shift && goto parseArguments
if /i "%1"=="--bootstrap-only" set BOOTSTRAP_ONLY=true&& shift && goto parseArguments

:: Unknown parameters
goto :usage

:doneParsingArguments

if "%SCOPE%"=="Compile" (
    set TARGET_ARG=Build
) else (
    set TARGET_ARG=BuildAndTest
)

:: Assign target configuration

:: Default to full-framework build
if not defined TARGET (
    set TARGET=Desktop
)

set BUILD_CONFIGURATION=
if /i "%TARGET%"=="CoreCLR" (
    set BUILD_CONFIGURATION=Debug-NetCore
) else if /i "%TARGET%"=="Desktop" (
    set BUILD_CONFIGURATION=Debug
) else (
    echo Unsupported target detected: %TARGET%. Aborting.
    goto :error
)

:: Assign runtime host

:: By default match host to target
if not defined HOST (
    if /i "%TARGET%"=="CoreCLR" (
        set HOST=CoreCLR
    ) else (
        set HOST=Desktop
    )
)

set RUNTIME_HOST=
if /i "%HOST%"=="CoreCLR" (
    set RUNTIME_HOST=%~dp0Tools\DotNetCLI\Dotnet.exe
    set MSBUILD_CUSTOM_PATH=%~dp0Tools\MSBuild.exe
) else if /i "%HOST%"=="Desktop" (
    set RUNTIME_HOST=
) else (
    echo Unsupported host detected: %HOST%. Aborting.
    goto :error
)

:: Restore build tools
call %~dp0init-tools.cmd

echo.
echo ** Rebuilding MSBuild with downloaded binaries

set MSBUILDLOGPATH=%~dp0msbuild_bootstrap_build.log
call "%~dp0build.cmd" /t:Rebuild /p:Configuration=%BUILD_CONFIGURATION% /p:"SkipBuildPackages=true"

if %ERRORLEVEL% NEQ 0 (
    echo.
    echo Bootstrap build failed with errorlevel %ERRORLEVEL% 1>&2
    goto :error
)
echo on
if "%BOOTSTRAP_ONLY%"=="true" goto :success

:: Move initial build to bootstrap directory

echo.
echo ** Moving bootstrapped MSBuild to the bootstrap folder

:: Kill Roslyn, which may have handles open to files we want
taskkill /F /IM vbcscompiler.exe

set MSBUILDLOGPATH=%~dp0msbuild_move_bootstrap.log
set MSBUILD_ARGS=/verbosity:minimal BootStrapMSbuild.proj /p:Configuration=%BUILD_CONFIGURATION%

call "%~dp0build.cmd"
if %ERRORLEVEL% NEQ 0 (
    echo.
    echo Failed to create bootstrap folder with errorlevel %ERRORLEVEL% 1>&2
    goto :error
)
set MSBUILD_ARGS=

:: Rebuild with bootstrapped msbuild
set MSBUILDLOGPATH=%~dp0msbuild_local_build.log

:: Only CoreCLR requires an override--it should use the host
:: downloaded as part of its NuGet package references, rather
:: than the possibly-stale one from Tools.
if /i "%TARGET%"=="CoreCLR" (
    set RUNTIME_HOST=%~dp0Tools\DotNetCLI\Dotnet.exe
)

if /i "%TARGET%"=="CoreCLR" (
    set MSBUILD_CUSTOM_PATH="%~dp0bin\Bootstrap\MSBuild.exe"
) else (
    set MSBUILD_CUSTOM_PATH="%~dp0bin\Bootstrap\15.0\Bin\MSBuild.exe"
)

echo.
echo ** Rebuilding MSBuild with locally built binaries

call "%~dp0build.cmd" /t:RebuildAndTest /p:Configuration=%BUILD_CONFIGURATION%

if %ERRORLEVEL% NEQ 0 (
    echo.
    echo Local build failed with error level %ERRORLEVEL% 1>&2
    goto :error
)

:success
echo.
echo ++++++++++++++++
echo + SUCCESS  :-) +
echo ++++++++++++++++
echo.
exit /b 0

:usage
echo Options
echo   --scope ^<scope^>                Scope of the build ^(Compile / Test^)
echo   --target ^<target^>              CoreCLR or Desktop ^(default: Desktop^)
echo   --host ^<host^>                  CoreCLR or Desktop ^(default: Desktop^)
echo   --bootstrap-only               Do not rebuild msbuild with local binaries
exit /b 1

:error
echo.
echo ---------------------------------------
echo - cibuild.cmd FAILED. -
echo ---------------------------------------
exit /b 1

@if not defined _echo echo off
setlocal

:parseArguments
if "%1"=="" goto doneParsingArguments
if /i "%1"=="--scope" set SCOPE=%2&& shift && shift && goto parseArguments
if /i "%1"=="--target" set TARGET=%2&& shift && shift && goto parseArguments
if /i "%1"=="--host" set HOST=%2&& shift && shift && goto parseArguments
if /i "%1"=="--bootstrap-only" set BOOTSTRAP_ONLY=true&& shift && goto parseArguments

:: Unknown parameters
goto :usage

:doneParsingArguments

:: Default target
set TARGET_ARG=RebuildAndTest

if /i "%SCOPE%"=="Compile" set TARGET_ARG=Build
if /i "%SCOPE%"=="Build" set TARGET_ARG=Build

:: Assign target configuration

:: Default to full-framework build
if not defined TARGET (
    set TARGET=Desktop
)

set BUILD_CONFIGURATION=
if /i "%TARGET%"=="CoreCLR" (
    set BUILD_CONFIGURATION=Debug-NetCore
) else if /i "%TARGET%"=="Desktop" (
    set BUILD_CONFIGURATION=Debug
) else (
    echo Unsupported target detected: %TARGET%. Aborting.
    goto :error
)

:: Assign runtime host

:: By default match host to target
if not defined HOST (
    if /i "%TARGET%"=="CoreCLR" (
        set HOST=CoreCLR
    ) else (
        set HOST=Desktop
    )
)

set RUNTIME_HOST=
if /i "%HOST%"=="CoreCLR" (
    set RUNTIME_HOST=%~dp0Tools\DotNetCLI\Dotnet.exe
    set MSBUILD_CUSTOM_PATH=%~dp0Tools\MSBuild.exe
) else if /i "%HOST%"=="Desktop" (
    set RUNTIME_HOST=
) else (
    echo Unsupported host detected: %HOST%. Aborting.
    goto :error
)

:: Restore build tools
call %~dp0init-tools.cmd

echo.
echo ** Rebuilding MSBuild with downloaded binaries

set MSBUILDLOGPATH=%~dp0msbuild_bootstrap_build.log
call "%~dp0build.cmd" /t:Rebuild /p:Configuration=%BUILD_CONFIGURATION% /p:"SkipBuildPackages=true"

if %ERRORLEVEL% NEQ 0 (
    echo.
    echo Bootstrap build failed with errorlevel %ERRORLEVEL% 1>&2
    goto :error
)
echo on
if "%BOOTSTRAP_ONLY%"=="true" goto :success

:: Move initial build to bootstrap directory

echo.
echo ** Moving bootstrapped MSBuild to the bootstrap folder

:: Kill Roslyn, which may have handles open to files we want
taskkill /F /IM vbcscompiler.exe

set MSBUILDLOGPATH=%~dp0msbuild_move_bootstrap.log
set MSBUILD_ARGS=/verbosity:minimal BootStrapMSbuild.proj /p:Configuration=%BUILD_CONFIGURATION%

call "%~dp0build.cmd"
if %ERRORLEVEL% NEQ 0 (
    echo.
    echo Failed to create bootstrap folder with errorlevel %ERRORLEVEL% 1>&2
    goto :error
)
set MSBUILD_ARGS=

:: Rebuild with bootstrapped msbuild
set MSBUILDLOGPATH=%~dp0msbuild_local_build.log

:: Only CoreCLR requires an override--it should use the host
:: downloaded as part of its NuGet package references, rather
:: than the possibly-stale one from Tools.
if /i "%TARGET%"=="CoreCLR" (
    set RUNTIME_HOST=%~dp0Tools\DotNetCLI\Dotnet.exe
)

if /i "%TARGET%"=="CoreCLR" (
    set MSBUILD_CUSTOM_PATH="%~dp0bin\Bootstrap\MSBuild.exe"
) else (
    set MSBUILD_CUSTOM_PATH="%~dp0bin\Bootstrap\15.0\Bin\MSBuild.exe"
)

echo.
echo ** Rebuilding MSBuild with locally built binaries

call "%~dp0build.cmd" /t:%TARGET_ARG% /p:Configuration=%BUILD_CONFIGURATION%

if %ERRORLEVEL% NEQ 0 (
    echo.
    echo Local build failed with error level %ERRORLEVEL% 1>&2
    goto :error
)

:success
echo.
echo ++++++++++++++++
echo + SUCCESS  :-) +
echo ++++++++++++++++
echo.
exit /b 0

:usage
echo Options
echo   --scope ^<scope^>                Scope of the build ^(Compile / Test^)
echo   --target ^<target^>              CoreCLR or Desktop ^(default: Desktop^)
echo   --host ^<host^>                  CoreCLR or Desktop ^(default: Desktop^)
echo   --bootstrap-only               Do not rebuild msbuild with local binaries
exit /b 1

:error
echo.
echo ---------------------------------------
echo - cibuild.cmd FAILED. -
echo ---------------------------------------
exit /b 1

Fix --scope argument in cibuild.cmd (#986)

The variable value wasn't being passed to build.cmd
Also add possible value of "build", make string comparison case insensitive


@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

Add gradle.bat for windows.

Add gradle.bat for windows.


"%PYTHON%" setup.py install
if errorlevel 1 exit 1

:: Add more build steps here, if they are necessary.

:: See
:: http://docs.continuum.io/conda/build.html
:: for a list of environment variables that are set during the build process.

Create bld.bat

Create bld.bat


powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" <NUL

<nul set /p ".=;C:\Chocolatey\bin" >> C:\Windows\Temp\PATH
set /p PATH=<C:\Windows\Temp\PATH
setx PATH "%PATH%" /m

powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" <NUL

<nul set /p ".=;%ALLUSERSPROFILE%\chocolatey\bin" >> C:\Windows\Temp\PATH
set /p PATH=<C:\Windows\Temp\PATH
setx PATH "%PATH%" /m

Update chocolatey scripts with 0.9.8.27's default install location.


@echo off
..\..\Tools\PhpNetTester.exe /compiler:..\..\Deployment\Debug\phpc.exe /php:..\..\Tools\PHP\php.exe
del /s *.pdb *.exe EmittedNodes.csv LibraryCalls.csv UnknownCalls.csv __input.txt Debug.log > nul
pause

@echo off
..\..\Tools\PhpNetTester.exe /compiler:..\..\Deployment\Debug\phpc.exe /php:..\..\Tools\PHP\php.exe
del /s *.pdb *.exe EmittedNodes.csv LibraryCalls.csv UnknownCalls.csv __input.txt Debug.log > nul

@echo Deleting empty log files...
for /f "delims=" %%i in ('dir /s/b/a-d *.log') do if %~zi==0 del %%i
pause

Test runner batch now deletes empty log files.


@echo off
rem -----------------------------------
rem TO BE RUN FROM THE ROOT OF THE REPO
rem -----------------------------------

set BUILD_MODE=%1
if "%BUILD_MODE%"=="debug" set TARGET="debug"
if "%BUILD_MODE%"=="appveyor" set TARGET="debug"
if "%BUILD_MODE%"=="release" set TARGET="release"
if "%BUILD_MODE%"=="fulldebug" set TARGET="debug"
if "%BUILD_MODE%"=="fullrelease" set TARGET="release"

SET ROOT_DIR="%cd%"
echo "Root directory is %ROOT_DIR%"
echo "Build mode is %BUILD_MODE%"

rem for Windows 10+ only
rem set PRINT_PREFIX="^<ESC^>[32m [32mGreen[0m"
set PRINT_PREFIX="-"
set NMAKE_OPTIONS="clean all /f Makefile"

set XPIKS_DEPS_ROOT="%ROOT_DIR%\..\xpiks-deps"
set XPIKS_DEPS_LIBS="%XPIKS_DEPS_ROOT%\windows-libs\%TARGET%-x64"

if "%BUILD_MODE%"=="appveyor" (
   set PRINT_PREFIX=""
   set QMAKE_EXE="qmake"
   set ARCH="x64"
   rem call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %ARCH%
   git submodule update --init --recursive
) else (
  set QMAKE_EXE="C:\Qt\Qt5.6.2\5.6\msvc2015_64\bin\qmake.exe"
)

rem chillout
echo "%PRINT_PREFIX% Building chillout..."
cd %ROOT_DIR%\vendors\chillout\src\chillout
%QMAKE_EXE% "CONFIG+=%TARGET%" chillout.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\chillout.* ..\..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building chillout... - done"

rem zlib
echo "%PRINT_PREFIX% Building zlib..."
move %XPIKS_DEPS_ROOT%\zlib-1.2.11 %ROOT_DIR%\vendors
cd %ROOT_DIR%\vendors\zlib-project
%QMAKE_EXE% "CONFIG+=%TARGET%" zlib.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\z.* ..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building zlib... - done"

rem mman
echo "%PRINT_PREFIX% Building mman..."
cd %ROOT_DIR%\vendors\cpp-libface\mman-win32
%QMAKE_EXE% "CONFIG+=%TARGET%" mman-win32.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\mman.* ..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building mman... - done"

rem tiny-aes
echo "%PRINT_PREFIX% Renaming tiny-aes..."
cd %ROOT_DIR%\vendors\tiny-aes
ren aes.c aes.cpp
echo "%PRINT_PREFIX% Renaming tiny-aes... - done"

rem cpp-libface
echo "%PRINT_PREFIX% Building cpp-libface..."
cd %ROOT_DIR%\vendors\cpp-libface\libface-project
%QMAKE_EXE% "CONFIG+=%TARGET%" libface.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\face.* ..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building cpp-libface... - done"

rem ssdll
echo "%PRINT_PREFIX% Building ssdll..."
cd %ROOT_DIR%\vendors\ssdll\src\ssdll
%QMAKE_EXE% "CONFIG+=%TARGET% %BUILD_MODE%" ssdll.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\ssdll.* ..\..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building ssdll... - done"

rem quazip
echo "%PRINT_PREFIX% Building quazip..."
cd %ROOT_DIR%\vendors\quazip\quazip
%QMAKE_EXE% "CONFIG+=%TARGET%" quazip.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\quazip* ..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building quazip... - done"

rem hunspell
echo "%PRINT_PREFIX% Building hunspell..."
cd %ROOT_DIR%\vendors\hunspell
%QMAKE_EXE% "CONFIG+=%TARGET%" hunspell.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\hunspell.* ..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building hunspell... - done"

cd %XPKS_ROOT%\src\recoverty
%QMAKE_EXE% "CONFIG+=%TARGET%" recoverty.pro
nmake.exe "%NMAKE_OPTIONS%"
echo "%PRINT_PREFIX% Building recoverty... - done"

set XPKS_ROOT="%ROOT_DIR%\..\libxpks"
set THMBNLR_ROOT="%ROOT_DIR%\..\libthmbnlr"

if not "%BUILD_MODE%"=="appveyor" (
  set "TRUE="
  IF "%BUILD_MODE%"=="fulldebug" set TRUE=1
  IF "%BUILD_MODE%"=="fullrelease" set TRUE=1
  IF defined TRUE (
      rem libxpks
      echo "%PRINT_PREFIX% Building real libxpks..."
      copy %ROOT_DIR%\libs\%TARGET%\*curl* %XPKS_ROOT%\libs\%TARGET%
      copy %ROOT_DIR%\libs\%TARGET%\quazip* %XPKS_ROOT%\libs\%TARGET%
      cd %XPKS_ROOT%\src\xpks
      %QMAKE_EXE% "CONFIG+=%TARGET%" xpks.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\xpks.* %ROOT_DIR%\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libxpks... - done"

      rem libthmbnlr
      echo "%PRINT_PREFIX% Building real libthmbnlr..."
      cd "%THMBNLR_ROOT%\src\libthmbnlr"
      %QMAKE_EXE% "CONFIG+=%TARGET%" libthmbnlr.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\thmbnlr.* %ROOT_DIR%\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libthmbnlr... - done"
    ) else (
      rem libxpks
      echo "%PRINT_PREFIX% Building stub libxpks..."
      cd %ROOT_DIR%\src\libxpks_stub
      %QMAKE_EXE% "CONFIG+=%TARGET%" libxpks_stub.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\xpks.* ..\..\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libxpks... - done"

      rem libthmbnlr
      echo "%PRINT_PREFIX% Building stub libthmbnlr..."
      cd "%ROOT_DIR%\vendors\libthmbnlr"
      %QMAKE_EXE% "CONFIG+=%TARGET%" thmbnlr.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\thmbnlr.* %ROOT_DIR%\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libthmbnlr... - done"
    )
) else (
  echo "%PRINT_PREFIX% Copying non-buildable artifacts from xpiks-deps..."
  echo "%PRINT_PREFIX% xpiks-deps root is %XPIKS_DEPS_LIBS%"

  rem ffmpeg
  xcopy /s %XPIKS_DEPS_ROOT%\windows-libs\ffmpeg-x64\%TARGET% %ROOT_DIR%\libs\%TARGET%

  rem xpiks deps
  copy %XPIKS_DEPS_LIBS%\*curl* %ROOT_DIR%\libs\%TARGET%
  copy %XPIKS_DEPS_LIBS%\thmbnlr.* %ROOT_DIR%\libs\%TARGET%
  copy %XPIKS_DEPS_LIBS%\xpks.* %ROOT_DIR%\libs\%TARGET%
  rem integration tests deps
  copy %XPIKS_DEPS_LIBS%\libexpat.* %ROOT_DIR%\libs\%TARGET%
  copy %XPIKS_DEPS_LIBS%\libexiv2.* %ROOT_DIR%\libs\%TARGET%
)

echo "%PRINT_PREFIX% Vendors preparation for %BUILD_MODE%: done"

@echo off
rem -----------------------------------
rem TO BE RUN FROM THE ROOT OF THE REPO
rem -----------------------------------

set BUILD_MODE=%1
if "%BUILD_MODE%"=="debug" set TARGET="debug"
if "%BUILD_MODE%"=="appveyor" set TARGET="debug"
if "%BUILD_MODE%"=="release" set TARGET="release"
if "%BUILD_MODE%"=="fulldebug" set TARGET="debug"
if "%BUILD_MODE%"=="fullrelease" set TARGET="release"

SET ROOT_DIR="%cd%"
echo "Root directory is %ROOT_DIR%"
echo "Build mode is %BUILD_MODE%"

rem for Windows 10+ only
rem set PRINT_PREFIX="^<ESC^>[32m [32mGreen[0m"
set PRINT_PREFIX="-"
set NMAKE_OPTIONS="clean all /f Makefile"

set XPIKS_DEPS_ROOT="%ROOT_DIR%\..\xpiks-deps"
set XPIKS_DEPS_LIBS="%XPIKS_DEPS_ROOT%\windows-libs\%TARGET%-x64"

if "%BUILD_MODE%"=="appveyor" (
   set PRINT_PREFIX=""
   set QMAKE_EXE="qmake"
   set ARCH="x64"
   rem call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %ARCH%
   git submodule update --init --recursive
) else (
  set QMAKE_EXE="C:\Qt\Qt5.6.2\5.6\msvc2015_64\bin\qmake.exe"
)

rem chillout
echo "%PRINT_PREFIX% Building chillout..."
cd %ROOT_DIR%\vendors\chillout\src\chillout
%QMAKE_EXE% "CONFIG+=%TARGET%" chillout.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\chillout.* ..\..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building chillout... - done"

rem zlib
echo "%PRINT_PREFIX% Building zlib..."
move %XPIKS_DEPS_ROOT%\zlib-1.2.11 %ROOT_DIR%\vendors
cd %ROOT_DIR%\vendors\zlib-project
%QMAKE_EXE% "CONFIG+=%TARGET%" zlib.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\z.* ..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building zlib... - done"

rem mman
echo "%PRINT_PREFIX% Building mman..."
cd %ROOT_DIR%\vendors\cpp-libface\mman-win32
%QMAKE_EXE% "CONFIG+=%TARGET%" mman-win32.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\mman.* ..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building mman... - done"

rem tiny-aes
echo "%PRINT_PREFIX% Renaming tiny-aes..."
cd %ROOT_DIR%\vendors\tiny-aes
ren aes.c aes.cpp
echo "%PRINT_PREFIX% Renaming tiny-aes... - done"

rem cpp-libface
echo "%PRINT_PREFIX% Building cpp-libface..."
cd %ROOT_DIR%\vendors\cpp-libface\libface-project
%QMAKE_EXE% "CONFIG+=%TARGET%" libface.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\face.* ..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building cpp-libface... - done"

rem ssdll
echo "%PRINT_PREFIX% Building ssdll..."
cd %ROOT_DIR%\vendors\ssdll\src\ssdll
%QMAKE_EXE% "CONFIG+=%TARGET% %BUILD_MODE%" ssdll.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\ssdll.* ..\..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building ssdll... - done"

rem quazip
echo "%PRINT_PREFIX% Building quazip..."
cd %ROOT_DIR%\vendors\quazip\quazip
%QMAKE_EXE% "CONFIG+=%TARGET%" quazip.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\quazip* ..\..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building quazip... - done"

rem hunspell
echo "%PRINT_PREFIX% Building hunspell..."
cd %ROOT_DIR%\vendors\hunspell
%QMAKE_EXE% "CONFIG+=%TARGET%" hunspell.pro
nmake.exe "%NMAKE_OPTIONS%"
copy %TARGET%\hunspell.* ..\..\libs\%TARGET%
echo "%PRINT_PREFIX% Building hunspell... - done"

cd %ROOT_DIR%\src\recoverty
%QMAKE_EXE% "CONFIG+=%TARGET%" recoverty.pro
nmake.exe "%NMAKE_OPTIONS%"
echo "%PRINT_PREFIX% Building recoverty... - done"

set XPKS_ROOT="%ROOT_DIR%\..\libxpks"
set THMBNLR_ROOT="%ROOT_DIR%\..\libthmbnlr"

if not "%BUILD_MODE%"=="appveyor" (
  set "TRUE="
  IF "%BUILD_MODE%"=="fulldebug" set TRUE=1
  IF "%BUILD_MODE%"=="fullrelease" set TRUE=1
  IF defined TRUE (
      rem libxpks
      echo "%PRINT_PREFIX% Building real libxpks..."
      copy %ROOT_DIR%\libs\%TARGET%\*curl* %XPKS_ROOT%\libs\%TARGET%
      copy %ROOT_DIR%\libs\%TARGET%\quazip* %XPKS_ROOT%\libs\%TARGET%
      cd %XPKS_ROOT%\src\xpks
      %QMAKE_EXE% "CONFIG+=%TARGET%" xpks.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\xpks.* %ROOT_DIR%\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libxpks... - done"

      rem libthmbnlr
      echo "%PRINT_PREFIX% Building real libthmbnlr..."
      cd "%THMBNLR_ROOT%\src\libthmbnlr"
      %QMAKE_EXE% "CONFIG+=%TARGET%" libthmbnlr.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\thmbnlr.* %ROOT_DIR%\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libthmbnlr... - done"
    ) else (
      rem libxpks
      echo "%PRINT_PREFIX% Building stub libxpks..."
      cd %ROOT_DIR%\src\libxpks_stub
      %QMAKE_EXE% "CONFIG+=%TARGET%" libxpks_stub.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\xpks.* ..\..\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libxpks... - done"

      rem libthmbnlr
      echo "%PRINT_PREFIX% Building stub libthmbnlr..."
      cd "%ROOT_DIR%\vendors\libthmbnlr"
      %QMAKE_EXE% "CONFIG+=%TARGET%" thmbnlr.pro
      nmake.exe "%NMAKE_OPTIONS%"
      copy %TARGET%\thmbnlr.* %ROOT_DIR%\libs\%TARGET%
      echo "%PRINT_PREFIX% Building libthmbnlr... - done"
    )
) else (
  echo "%PRINT_PREFIX% Copying non-buildable artifacts from xpiks-deps..."
  echo "%PRINT_PREFIX% xpiks-deps root is %XPIKS_DEPS_LIBS%"

  rem ffmpeg
  xcopy /s %XPIKS_DEPS_ROOT%\windows-libs\ffmpeg-x64\%TARGET% %ROOT_DIR%\libs\%TARGET%

  rem xpiks deps
  copy %XPIKS_DEPS_LIBS%\*curl* %ROOT_DIR%\libs\%TARGET%
  copy %XPIKS_DEPS_LIBS%\thmbnlr.* %ROOT_DIR%\libs\%TARGET%
  copy %XPIKS_DEPS_LIBS%\xpks.* %ROOT_DIR%\libs\%TARGET%
  rem integration tests deps
  copy %XPIKS_DEPS_LIBS%\libexpat.* %ROOT_DIR%\libs\%TARGET%
  copy %XPIKS_DEPS_LIBS%\libexiv2.* %ROOT_DIR%\libs\%TARGET%
)

echo "%PRINT_PREFIX% Vendors preparation for %BUILD_MODE%: done"

Fix typo

Fix typo


# attempt to debug cmake problem
echo %PATH%
where cmake

cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -D CMAKE_BUILD_TYPE=Release ^
    -D INSTALL_PYTHON_USING_PREFIX=OFF ^
    -D PYTHON_EXE=%PYTHON% ^
    -D BOOST_INCLUDE_DIR=%LIBRARY_INC% ^
    -D BOOST_LIB_PATH=%LIBRARY_LIB% ^
    -D GDAL_INCLUDE_DIR=%LIBRARY_INC% ^
    -D GDAL_LIB_PATH=%LIBRARY_LIB% ^
    -D HDF5_INCLUDE_DIR=%LIBRARY_INC% ^
    -D HDF5_LIB_PATH=%LIBRARY_LIB% ^
    -D XERCESC_INCLUDE_DIR=%LIBRARY_INC% ^
    -D XERCESC_LIB_PATH=%LIBRARY_LIB% ^
    -D GSL_INCLUDE_DIR=%LIBRARY_INC% ^
    -D GSL_LIB_PATH=%LIBRARY_LIB% ^
    -D GEOS_INCLUDE_DIR=%LIBRARY_INC% ^
    -D GEOS_LIB_PATH=%LIBRARY_LIB% ^
    -D MUPARSER_INCLUDE_DIR=%LIBRARY_INC% ^
    -D MUPARSER_LIB_PATH=%LIBRARY_LIB% ^
    -D CGAL_INCLUDE_DIR=%LIBRARY_LIB% ^
    -D CGAL_LIB_PATH=%LIBRARY_LIB% ^
    -D GMP_INCLUDE_DIR=%LIBRARY_INC% ^
    -D GMP_LIB_PATH=%LIBRARY_LIB% ^
    -D MPFR_INCLUDE_DIR=%LIBRARY_INC% ^
    -D MPFR_LIB_PATH=%LIBRARY_LIB% ^
    -D KEA_INCLUDE_DIR=%LIBRARY_INC% ^
    -D KEA_LIB_PATH=%LIBRARY_LIB% ^
    .
if errorlevel 1 exit 1

nmake
if errorlevel 1 exit 1

nmake install
if errorlevel 1 exit 1

REM Must run tests now since they require the source tree
cd python_tests\RSGISLibTests
%PYTHON% RSGIStests.py --all
if errorlevel 1 exit 1

remove cmake debugging

remove cmake debugging


msiexec /a %PKG_NAME%-%PKG_VERSION%-%TARGET_ARCH%-Setup.msi /qb TARGETDIR=%TEMP% || exit 1

if not exist %SCRIPTS% mkdir %SCRIPTS% || exit 1

xcopy /s %TEMP%\Cppcheck\* %SCRIPTS% || exit 1

msiexec /a %PKG_NAME%-%PKG_VERSION%-%TARGET_ARCH%-Setup.msi /qb TARGETDIR=%TEMP% || exit 1

if not exist %SCRIPTS% mkdir %SCRIPTS% || exit 1

xcopy /s %TEMP%\PFiles\Cppcheck\* %SCRIPTS% || exit 1

Fix path to binaries

Fix path to binaries


@echo off
setlocal
setlocal enabledelayedexpansion
setlocal enableextensions
set errorlevel=0
erase /s *.nupkg
msbuild /property:Configuration=release Microsoft.Bot.Builder.csproj
for /f %%v in ('powershell -noprofile "(Get-Command .\bin\release\Microsoft.Bot.Connector.dll).FileVersionInfo.FileVersion"') do set version=%%v
..\..\packages\NuGet.CommandLine.3.4.3\tools\NuGet.exe pack Microsoft.Bot.Connector.nuspec -symbols -properties version=%version%

@echo off
setlocal
setlocal enabledelayedexpansion
setlocal enableextensions
set errorlevel=0
erase /s *.nupkg
msbuild /property:Configuration=release Microsoft.Bot.Connector.csproj
for /f %%v in ('powershell -noprofile "(Get-Command .\bin\release\Microsoft.Bot.Connector.dll).FileVersionInfo.FileVersion"') do set version=%%v
..\..\packages\NuGet.CommandLine.3.4.3\tools\NuGet.exe pack Microsoft.Bot.Connector.nuspec -symbols -properties version=%version%

Fix connector createpackage.cmd

Fix connector createpackage.cmd


:: %~dp0 gives the dirname of the script

cmd /c %~dp0common.bat

:: %~dp0 gives the dirname of the script
cmd /c %~dp0install-cygwin-sshd.bat

Remove a level of indirection

Remove a level of indirection


@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.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install                Install the service using Tomcat@VERSION_MAJOR@ as service name.
rem                        Service is installed using default settings.
rem remove                 Remove the service from the System.
rem
rem name        (optional) If the second argument is present it is considered
rem                        to be new service name
rem
rem $Id$
rem ---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%cd%
if exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome
rem CD to the upper dir
cd ..
set CATALINA_HOME=%cd%
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end
:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase

set EXECUTABLE=%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe

rem Set default Service name
set SERVICE_NAME=Tomcat@VERSION_MAJOR@
set PR_DISPLAYNAME=Apache Tomcat @VERSION_MAJOR@

if "%1" == "" goto displayUsage
if "%2" == "" goto setServiceName
set SERVICE_NAME=%2
set PR_DISPLAYNAME=Apache Tomcat %2
:setServiceName
if %1 == install goto doInstall
if %1 == remove goto doRemove
if %1 == uninstall goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name]
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME:    %CATALINA_HOME%
echo Using CATALINA_BASE:    %CATALINA_BASE%
echo Using JAVA_HOME:        %JAVA_HOME%

rem Use the environment variables as an example
rem Each command line option is prefixed with PR_

set PR_DESCRIPTION=Apache Tomcat @VERSION@ Server - http://tomcat.apache.org/
set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar
rem Set the server jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\jre\bin\client\jvm.dll
if exist "%PR_JVM%" goto foundJvm
set PR_JVM=auto
:foundJvm
echo Using JVM:              %PR_JVM%
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%

@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.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install                Install the service using Tomcat@VERSION_MAJOR@ as service name.
rem                        Service is installed using default settings.
rem remove                 Remove the service from the System.
rem
rem name        (optional) If the second argument is present it is considered
rem                        to be new service name
rem
rem $Id$
rem ---------------------------------------------------------------------------

set SELF=%~dp0%service.bat
rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%cd%
if exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome
rem CD to the upper dir
cd ..
set CATALINA_HOME=%cd%
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end
:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase

set EXECUTABLE=%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe

rem Set default Service name
set SERVICE_NAME=Tomcat@VERSION_MAJOR@
set PR_DISPLAYNAME=Apache Tomcat @VERSION_MAJOR@

if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
:checkUser
if "x%1x" == "x/userx" goto runAsUser
if "x%1x" == "x--userx" goto runAsUser
set SERVICE_NAME=%1
set PR_DISPLAYNAME=Apache Tomcat %1
shift
if "x%1x" == "xx" goto checkServiceCmd
goto checkUser
:runAsUser
shift
if "x%1x" == "xx" goto displayUsage
set SERVICE_USER=%1
shift
runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%"
goto end
:checkServiceCmd
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == uninstall goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name] [/user username]
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
if not errorlevel 1 goto removed
echo Failed removing '%SERVICE_NAME%' service
goto end
:removed
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME:    %CATALINA_HOME%
echo Using CATALINA_BASE:    %CATALINA_BASE%
echo Using JAVA_HOME:        %JAVA_HOME%

rem Use the environment variables as an example
rem Each command line option is prefixed with PR_

set PR_DESCRIPTION=Apache Tomcat @VERSION@ Server - http://tomcat.apache.org/
set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar
rem Set the server jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%\jre\bin\client\jvm.dll
if exist "%PR_JVM%" goto foundJvm
set PR_JVM=auto
:foundJvm
echo Using JVM:              %PR_JVM%
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set PR_LOGPATH=%CATALINA_BASE%\logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%

Fix bz41564 by adding /user option to service.bat which respawns the service.bat
using runas command. This pops-up a new window with elevated security on Vista+

git-svn-id: 79cef5a5a257cc9dbe40a45ac190115b4780e2d0@779047 13f79535-47bb-0310-9956-ffa450edef68


mkdir build && cd build

cmake -G "Ninja" ^
 -D CMAKE_BUILD_TYPE:STRING=Release ^
 -D CMAKE_INSTALL_PREFIX:FILEPATH="%LIBRARY_PREFIX%" ^
 -D CMAKE_PREFIX_PATH:FILEPATH="%LIBRARY_PREFIX%" ^
 -D CMAKE_SYSTEM_PREFIX_PATH:FILEPATH="%LIBRARY_PREFIX%" ^
 -D BOOST_LIBRARYDIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^
 -D BOOST_INCLUDEDIR:FILEPATH="%LIBRARY_PREFIX%\include" ^
 -D OCC_INCLUDE_DIR:FILEPATH="%LIBRARY_PREFIX%\include\opencasade" ^
 -D OCC_LIBRARY_DIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^
 -D COLLADA_SUPPORT:BOOL=OFF ^
 -D BUILD_EXAMPLES:BOOL=OFF ^
 -D BUILD_GEOMSERVER:BOOL=OFF ^
 -D BUILD_CONVERT:BOOL=OFF ^
 ../cmake

if errorlevel 1 exit 1
ninja install
if errorlevel 1 exit 1

mkdir build && cd build

cmake -G "Ninja" ^
 -D CMAKE_BUILD_TYPE:STRING=Release ^
 -D CMAKE_INSTALL_PREFIX:FILEPATH="%LIBRARY_PREFIX%" ^
 -D CMAKE_PREFIX_PATH:FILEPATH="%LIBRARY_PREFIX%" ^
 -D CMAKE_SYSTEM_PREFIX_PATH:FILEPATH="%LIBRARY_PREFIX%" ^
 -D BOOST_LIBRARYDIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^
 -D BOOST_INCLUDEDIR:FILEPATH="%LIBRARY_PREFIX%\include" ^
 -D OCC_INCLUDE_DIR:FILEPATH="%LIBRARY_PREFIX%\include\opencascade" ^
 -D OCC_LIBRARY_DIR:FILEPATH="%LIBRARY_PREFIX%\lib" ^
 -D COLLADA_SUPPORT:BOOL=OFF ^
 -D BUILD_EXAMPLES:BOOL=OFF ^
 -D BUILD_GEOMSERVER:BOOL=OFF ^
 -D BUILD_CONVERT:BOOL=OFF ^
 ../cmake

if errorlevel 1 exit 1
ninja install
if errorlevel 1 exit 1

Fix typo

Fix typo


:: XX-Net
:: Enable IPV6
:: https://github.com/XX-net/XX-Net-dev/issues/53

:: https://www.zhihu.com/question/34541107/answer/137174053
@echo off
echo Get Admin
::ver|findstr "[6,10]\.[0-9]\.[0-9][0-9]*" > nul && (goto Main)
::ver|findstr "[3-5]\.[0-9]\.[0-9][0-9]*" > nul && (goto isBelowNT6)

:: :isBelowNT6

:Main
@echo off
cd /d "%~dp0"
cacls.exe "%SystemDrive%\System Volume Information" >nul 2>nul
if %errorlevel%==0 goto Admin
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
echo Set RequestUAC = CreateObject^("Shell.Application"^)>"%temp%\getadmin.vbs"
echo RequestUAC.ShellExecute "%~s0","","","runas",1 >>"%temp%\getadmin.vbs"
echo WScript.Quit >>"%temp%\getadmin.vbs"
"%temp%\getadmin.vbs" /f
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
exit

:Admin
@echo off

sc config RpcEptMapper start= auto
sc start RpcEptMapper

sc config DcomLaunch start= auto
sc start DcomLaunch

sc config RpcSs start= auto
sc start RpcSs

sc config nsi start= auto
sc start nsi
sc config Wingmt start= auto
sc start Winmgmt

sc config Dhcp start= auto
sc start Dhcp

sc config WinHttpAutoProxySvc start= auto
sc start WinHttpAutoProxySvc

sc config iphlpsvc start= auto
sc start iphlpsvc

netsh int ipv6 reset

netsh int teredo set state default
netsh int 6to4 set state default
netsh int isatap set state default
netsh int teredo set state server=teredo.remlab.net
netsh int ipv6 set teredo enterpriseclient
netsh int ter set state enterpriseclient
route DELETE ::/0
netsh int ipv6 add route ::/0 "Teredo Tunneling Pseudo-Interface"
netsh int ipv6 set prefix 2002::/16 30 1
netsh int ipv6 set prefix 2001::/32 5 1
Reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dnscache\Parameters /v AddrConfigControl /t REG_DWORD /d 0 /f

Reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0 /f

:: Set Group Policy
:: HKLM\Software\Policies\Microsoft\Windows\TCPIP\v6Transition -Name Teredo_DefaultQualified
:: HKLM\Software\Policies\Microsoft\Windows\TCPIP\v6Transition -Name Teredo_State

netsh int teredo set state default
netsh int 6to4 set state default
netsh int isatap set state default
netsh int teredo set state server=teredo.remlab.net
netsh int ipv6 set teredo enterpriseclient
netsh int ter set state enterpriseclient
route DELETE ::/0
netsh int ipv6 add route ::/0 "Teredo Tunneling Pseudo-Interface"
netsh int ipv6 set prefix 2002::/16 30 1
netsh int ipv6 set prefix 2001::/32 5 1
Reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dnscache\Parameters /v AddrConfigControl /t REG_DWORD /d 0 /f

ipconfig /flushdns

set time=%date:~0,4%-%date:~5,2%-%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
@call :output>..\..\..\..\..\data\gae_proxy\ipv6-state%time%.txt
exit

:output
@echo off
ipconfig /all
netsh int ipv6 show teredo
netsh int ipv6 show route
netsh int ipv6 show int
netsh int ipv6 show prefix
netsh int ipv6 show address
route print
notepad ..\..\..\..\..\data\gae_proxy\ipv6-state%time%.txt

:: XX-Net
:: Enable IPV6
:: https://github.com/XX-net/XX-Net-dev/issues/53

:: https://www.zhihu.com/question/34541107/answer/137174053
@echo off
echo Get Admin
::ver|findstr "[6,10]\.[0-9]\.[0-9][0-9]*" > nul && (goto Main)
::ver|findstr "[3-5]\.[0-9]\.[0-9][0-9]*" > nul && (goto isBelowNT6)

:: :isBelowNT6

:Main
@echo off
cd /d "%~dp0"
cacls.exe "%SystemDrive%\System Volume Information" >nul 2>nul
if %errorlevel%==0 goto Admin
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
echo Set RequestUAC = CreateObject^("Shell.Application"^)>"%temp%\getadmin.vbs"
echo RequestUAC.ShellExecute "%~s0","","","runas",1 >>"%temp%\getadmin.vbs"
echo WScript.Quit >>"%temp%\getadmin.vbs"
"%temp%\getadmin.vbs" /f
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
exit

:Admin
@echo off

sc config RpcEptMapper start= auto
sc start RpcEptMapper

sc config DcomLaunch start= auto
sc start DcomLaunch

sc config RpcSs start= auto
sc start RpcSs

sc config nsi start= auto
sc start nsi
sc config Winmgmt start= auto
sc start Winmgmt

sc config Dhcp start= auto
sc start Dhcp

sc config WinHttpAutoProxySvc start= auto
sc start WinHttpAutoProxySvc

sc config iphlpsvc start= auto
sc start iphlpsvc

netsh int ipv6 reset

netsh int teredo set state default
netsh int 6to4 set state default
netsh int isatap set state default
netsh int teredo set state server=teredo.remlab.net
netsh int ipv6 set teredo enterpriseclient
netsh int ter set state enterpriseclient
route DELETE ::/0
netsh int ipv6 add route ::/0 "Teredo Tunneling Pseudo-Interface"
netsh int ipv6 set prefix 2002::/16 30 1
netsh int ipv6 set prefix 2001::/32 5 1
Reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dnscache\Parameters /v AddrConfigControl /t REG_DWORD /d 0 /f

Reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0 /f

:: Set Group Policy
:: HKLM\Software\Policies\Microsoft\Windows\TCPIP\v6Transition -Name Teredo_DefaultQualified
:: HKLM\Software\Policies\Microsoft\Windows\TCPIP\v6Transition -Name Teredo_State

netsh int teredo set state default
netsh int 6to4 set state default
netsh int isatap set state default
netsh int teredo set state server=teredo.remlab.net
netsh int ipv6 set teredo enterpriseclient
netsh int ter set state enterpriseclient
route DELETE ::/0
netsh int ipv6 add route ::/0 "Teredo Tunneling Pseudo-Interface"
netsh int ipv6 set prefix 2002::/16 30 1
netsh int ipv6 set prefix 2001::/32 5 1
Reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dnscache\Parameters /v AddrConfigControl /t REG_DWORD /d 0 /f

ipconfig /flushdns

set time=%date:~0,4%-%date:~5,2%-%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
@call :output>..\..\..\..\..\data\gae_proxy\ipv6-state%time%.txt
exit

:output
@echo off
ipconfig /all
netsh int ipv6 show teredo
netsh int ipv6 show route
netsh int ipv6 show int
netsh int ipv6 show prefix
netsh int ipv6 show address
route print
notepad ..\..\..\..\..\data\gae_proxy\ipv6-state%time%.txt

Update enable_ipv6.bat

Update enable_ipv6.bat

change "sc config Wingmt start= auto" to "sc config Winmgmt start=auto"


@setlocal enabledelayedexpansion

REM Parse Arguments.

set RoslynRoot=%~dp0
set BuildConfiguration=Debug

REM Because override the C#/VB toolset to build against our LKG package, it is important
REM that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
REM we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
set MSBuildAdditionalCommandLineArgs=/nologo /m /nodeReuse:false /consoleloggerparameters:Verbosity=minimal /filelogger /fileloggerparameters:Verbosity=normal

:ParseArguments
if "%1" == "" goto :DoneParsing
if /I "%1" == "/?" call :Usage && exit /b 1
if /I "%1" == "/debug" set BuildConfiguration=Debug&&shift&& goto :ParseArguments
if /I "%1" == "/release" set BuildConfiguration=Release&&shift&& goto :ParseArguments
if /I "%1" == "/test32" set Test64=false&&shift&& goto :ParseArguments
if /I "%1" == "/test64" set Test64=true&&shift&& goto :ParseArguments
if /I "%1" == "/testDeterminism" set TestDeterminism=true&&shift&& goto :ParseArguments
call :Usage && exit /b 1
:DoneParsing

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" || goto :BuildFailed

powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-branch.ps1" || goto :BuildFailed

REM Output the commit that we're building, for reference in Jenkins logs
echo Building this commit:
git show --no-patch --pretty=raw HEAD

REM Restore the NuGet packages
call "%RoslynRoot%\Restore.cmd" || goto :BuildFailed

REM Ensure the binaries directory exists because msbuild can fail when part of the path to LogFile isn't present.
set bindir=%RoslynRoot%Binaries
if not exist "%bindir%" mkdir "%bindir%" || goto :BuildFailed

REM Set the build version only so the assembly version is set to the semantic version,
REM which allows analyzers to load because the compiler has binding redirects to the
REM semantic version
msbuild %MSBuildAdditionalCommandLineArgs% /p:BuildVersion=0.0.0.0 "%RoslynRoot%build\Toolset.sln" /p:NuGetRestorePackages=false /p:Configuration=%BuildConfiguration% /fileloggerparameters:LogFile="%bindir%\Bootstrap.log" || goto :BuildFailed
powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-msbuild.ps1" "%bindir%\Bootstrap.log" || goto :BuildFailed

if not exist "%bindir%\Bootstrap" mkdir "%bindir%\Bootstrap" || goto :BuildFailed
move "Binaries\%BuildConfiguration%\*" "%bindir%\Bootstrap" || goto :BuildFailed
copy "build\bootstrap\*" "%bindir%\Bootstrap" || goto :BuildFailed

REM Clean the previous build
msbuild %MSBuildAdditionalCommandLineArgs% /t:Clean build/Toolset.sln /p:Configuration=%BuildConfiguration%  /fileloggerparameters:LogFile="%bindir%\BootstrapClean.log" || goto :BuildFailed

call :TerminateBuildProcesses

if defined TestDeterminism (
    powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\test-determinism.ps1" "%bindir%\Bootstrap" || goto :BuildFailed
    call :TerminateBuildProcesses
    exit /b 0
)

msbuild %MSBuildAdditionalCommandLineArgs% /p:BootstrapBuildPath="%bindir%\Bootstrap" BuildAndTest.proj /p:Configuration=%BuildConfiguration% /p:Test64=%Test64% /p:PathMap="%RoslynRoot%=q:\roslyn" /p:Feature=pdb-path-determinism /fileloggerparameters:LogFile="%bindir%\Build.log";verbosity=diagnostic || goto :BuildFailed
powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-msbuild.ps1" "%bindir%\Build.log" || goto :BuildFailed

call :TerminateBuildProcesses

REM Verify that our project.lock.json files didn't change as a result of
REM restore.  If they do then the commit changed the dependencies without
REM updating the lock files.
REM git diff --exit-code --quiet
REM if ERRORLEVEL 1 (
REM    echo Commit changed dependencies without updating project.lock.json
REM    git diff --exit-code
REM    exit /b 1
REM )

REM Ensure caller sees successful exit.
exit /b 0

:Usage
@echo Usage: cibuild.cmd [/debug^|/release] [/test32^|/test64] [/restore]
@echo   /debug   Perform debug build.  This is the default.
@echo   /release Perform release build.
@echo   /test32  Run unit tests in the 32-bit runner.  This is the default.
@echo   /test64  Run units tests in the 64-bit runner.
@echo.
@goto :eof

:BuildFailed
echo Build failed with ERRORLEVEL %ERRORLEVEL%
call :TerminateBuildProcesses
exit /b 1

:TerminateBuildProcesses
@REM Kill any instances VBCSCompiler.exe to release locked files, ignoring stderr if process is not open
@REM This prevents future CI runs from failing while trying to delete those files.
@REM Kill any instances of msbuild.exe to ensure that we never reuse nodes (e.g. if a non-roslyn CI run
@REM left some floating around).

taskkill /F /IM vbcscompiler.exe 2> nul
taskkill /F /IM msbuild.exe 2> nul

@setlocal enabledelayedexpansion

REM Parse Arguments.

set RoslynRoot=%~dp0
set BuildConfiguration=Debug

REM Because override the C#/VB toolset to build against our LKG package, it is important
REM that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
REM we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
set MSBuildAdditionalCommandLineArgs=/nologo /m /nodeReuse:false /consoleloggerparameters:Verbosity=minimal /filelogger /fileloggerparameters:Verbosity=normal

:ParseArguments
if "%1" == "" goto :DoneParsing
if /I "%1" == "/?" call :Usage && exit /b 1
if /I "%1" == "/debug" set BuildConfiguration=Debug&&shift&& goto :ParseArguments
if /I "%1" == "/release" set BuildConfiguration=Release&&shift&& goto :ParseArguments
if /I "%1" == "/test32" set Test64=false&&shift&& goto :ParseArguments
if /I "%1" == "/test64" set Test64=true&&shift&& goto :ParseArguments
if /I "%1" == "/testDeterminism" set TestDeterminism=true&&shift&& goto :ParseArguments

REM /buildTimeLimit is the time limit, measured in minutes, for the Jenkins job that runs
REM the build. The Jenkins script netci.groovy passes the time limit to this script.

REM netci.groovy does not yet pass the time limit to cibuild.cmd. We are making this
REM change to cibuild.cmd in all branches *before* modifying netci.groovy. If we didn't
REM do things in this order, we'd have to modify cibuild.cmd in *all* branches *at the
REM same time* we made the change to netci.groovy. This way, we'll be able to first
REM modify netci.groovy to pass the new parameter without causing any harm. Then we'll
REM be able go to each branch in turn, modifying cibuild.cmd and BuildAndTest.cmd to
REM actually make use of the new parameter.
if /I "%1" == "/buildTimeLimit" set BuildTimeLimit=%2&&shift&&shift&& goto:ParseArguments

call :Usage && exit /b 1
:DoneParsing

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" || goto :BuildFailed

powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-branch.ps1" || goto :BuildFailed

REM Output the commit that we're building, for reference in Jenkins logs
echo Building this commit:
git show --no-patch --pretty=raw HEAD

REM Restore the NuGet packages
call "%RoslynRoot%\Restore.cmd" || goto :BuildFailed

REM Ensure the binaries directory exists because msbuild can fail when part of the path to LogFile isn't present.
set bindir=%RoslynRoot%Binaries
if not exist "%bindir%" mkdir "%bindir%" || goto :BuildFailed

REM Set the build version only so the assembly version is set to the semantic version,
REM which allows analyzers to load because the compiler has binding redirects to the
REM semantic version
msbuild %MSBuildAdditionalCommandLineArgs% /p:BuildVersion=0.0.0.0 "%RoslynRoot%build\Toolset.sln" /p:NuGetRestorePackages=false /p:Configuration=%BuildConfiguration% /fileloggerparameters:LogFile="%bindir%\Bootstrap.log" || goto :BuildFailed
powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-msbuild.ps1" "%bindir%\Bootstrap.log" || goto :BuildFailed

if not exist "%bindir%\Bootstrap" mkdir "%bindir%\Bootstrap" || goto :BuildFailed
move "Binaries\%BuildConfiguration%\*" "%bindir%\Bootstrap" || goto :BuildFailed
copy "build\bootstrap\*" "%bindir%\Bootstrap" || goto :BuildFailed

REM Clean the previous build
msbuild %MSBuildAdditionalCommandLineArgs% /t:Clean build/Toolset.sln /p:Configuration=%BuildConfiguration%  /fileloggerparameters:LogFile="%bindir%\BootstrapClean.log" || goto :BuildFailed

call :TerminateBuildProcesses

if defined TestDeterminism (
    powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\test-determinism.ps1" "%bindir%\Bootstrap" || goto :BuildFailed
    call :TerminateBuildProcesses
    exit /b 0
)

msbuild %MSBuildAdditionalCommandLineArgs% /p:BootstrapBuildPath="%bindir%\Bootstrap" BuildAndTest.proj /p:Configuration=%BuildConfiguration% /p:Test64=%Test64% /p:PathMap="%RoslynRoot%=q:\roslyn" /p:Feature=pdb-path-determinism /fileloggerparameters:LogFile="%bindir%\Build.log";verbosity=diagnostic || goto :BuildFailed
powershell -noprofile -executionPolicy RemoteSigned -file "%RoslynRoot%\build\scripts\check-msbuild.ps1" "%bindir%\Build.log" || goto :BuildFailed

call :TerminateBuildProcesses

REM Verify that our project.lock.json files didn't change as a result of
REM restore.  If they do then the commit changed the dependencies without
REM updating the lock files.
REM git diff --exit-code --quiet
REM if ERRORLEVEL 1 (
REM    echo Commit changed dependencies without updating project.lock.json
REM    git diff --exit-code
REM    exit /b 1
REM )

REM Ensure caller sees successful exit.
exit /b 0

:Usage
@echo Usage: cibuild.cmd [/debug^|/release] [/test32^|/test64] [/restore]
@echo   /debug   Perform debug build.  This is the default.
@echo   /release Perform release build.
@echo   /test32  Run unit tests in the 32-bit runner.  This is the default.
@echo   /test64  Run units tests in the 64-bit runner.
@echo.
@goto :eof

:BuildFailed
echo Build failed with ERRORLEVEL %ERRORLEVEL%
call :TerminateBuildProcesses
exit /b 1

:TerminateBuildProcesses
@REM Kill any instances VBCSCompiler.exe to release locked files, ignoring stderr if process is not open
@REM This prevents future CI runs from failing while trying to delete those files.
@REM Kill any instances of msbuild.exe to ensure that we never reuse nodes (e.g. if a non-roslyn CI run
@REM left some floating around).

taskkill /F /IM vbcscompiler.exe 2> nul
taskkill /F /IM msbuild.exe 2> nul

Prepare cibuild.cmd to receive /buildTimeLimit

/buildTimeLimit is the time limit, measured in minutes, for the Jenkins
job that runs the build. The Jenkins script netci.groovy passes the time
limit to cibuild.cmd.

netci.groovy does not yet pass the time limit to cibuild.cmd. We are
making this change to cibuild.cmd in all branches *before* modifying
netci.groovy. If we didn't do things in this order, we'd have to modify
cibuild.cmd in *all* branches *at the same time* we made the change to
netci.groovy. This way, we'll be able to first modify netci.groovy to
pass the new parameter without causing any harm. Then we'll be able to
go to each branch in turn, modifying cibuild.cmd and BuildAndTest.cmd to
actually make use of the new parameter.


@mkdir _shake 2> nul
@ghc --make Main.hs -rtsopts -with-rtsopts=-I0 -outputdir=_shake -o _shake/build && _shake\build --lint --directory ".." %*

Add shake launcher.

Add shake launcher.


@if "%1" == "" goto  :needpackage
@if "%2" == "" goto :needfeed
..\packages\NuGet.CommandLine.3.3.0\tools\nuget push %1 -Source https://fuselabs.pkgs.visualstudio.com/DefaultCollection/_packaging/packages/nuget/v3/index.json -ApiKey %2
@goto end

:needpackage
@echo "You need to pass a package as first parameter"
@goto end

:needfeed
@echo "You need to pass a feed name, either: fuse or fusesymbols"

:end

@if "%1" == "" goto  :needpackage
@if "%2" == "" goto :needfeed
..\packages\NuGet.CommandLine.3.4.3\tools\nuget push %1 -Source https://fuselabs.pkgs.visualstudio.com/DefaultCollection/_packaging/packages/nuget/v3/index.json -ApiKey %2
@goto end

:needpackage
@echo "You need to pass a package as first parameter"
@goto end

:needfeed
@echo "You need to pass a feed name, either: fuse or fusesymbols"

:end

Change to use latest nuget.

Change to use latest nuget.


@REM
@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.

@echo off
if "%OS%" == "Windows_NT" setlocal

if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0..
if NOT DEFINED JAVA_HOME goto :err

REM Ensure that any user defined CLASSPATH variables are not used on startup
set CLASSPATH="%CASSANDRA_HOME%\conf"

REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable.
for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i"
goto okClasspath

:append
set CLASSPATH=%CLASSPATH%;%1
goto :eof

:okClasspath
REM Include the build\classes\main directory so it works in development
set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift"
goto runNodeTool

:runNodeTool
echo Starting NodeTool
"%JAVA_HOME%\bin\java" -cp %CASSANDRA_CLASSPATH% -Dlogback.configurationFile=logback-tools.xml org.apache.cassandra.tools.NodeCmd %*
goto finally

:err
echo The JAVA_HOME environment variable must be set to run this program!
pause

:finally

ENDLOCAL

@REM
@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.

@echo off
if "%OS%" == "Windows_NT" setlocal

if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0..
if NOT DEFINED JAVA_HOME goto :err

REM Ensure that any user defined CLASSPATH variables are not used on startup
set CLASSPATH="%CASSANDRA_HOME%\conf"

REM For each jar in the CASSANDRA_HOME lib directory call append to build the CLASSPATH variable.
for %%i in ("%CASSANDRA_HOME%\lib\*.jar") do call :append "%%i"
goto okClasspath

:append
set CLASSPATH=%CLASSPATH%;%1
goto :eof

:okClasspath
REM Include the build\classes\main directory so it works in development
set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift"
goto runNodeTool

:runNodeTool
echo Starting NodeTool
"%JAVA_HOME%\bin\java" -cp %CASSANDRA_CLASSPATH% -Dlogback.configurationFile=logback-tools.xml org.apache.cassandra.tools.NodeTool %*
goto finally

:err
echo The JAVA_HOME environment variable must be set to run this program!
pause

:finally

ENDLOCAL

update nodetool.bat for #6381

update nodetool.bat for #6381


@echo off
echo Starting script with Forever mode on...
echo Please note that the shutdown command will not activate and will make this script think there is an error
:main
node app.js
echo Uh oh... Looks like the bot crashed, rebooting it now
goto main

Create runForever.bat

Create runForever.bat


@setlocal EnableDelayedExpansion EnableExtensions
@for %%i in (a:\_packer_config*.cmd) do @call "%%~i"
@if defined PACKER_DEBUG (@echo on) else (@echo off)

if not defined PACKER_SEARCH_PATHS set PACKER_SEARCH_PATHS="%USERPROFILE%" a: b: c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z:
if not defined SEVENZIP_32_URL set SEVENZIP_32_URL=http://downloads.sourceforge.net/sevenzip/7z938.msi
if not defined SEVENZIP_64_URL set SEVENZIP_64_URL=http://downloads.sourceforge.net/sevenzip/7z938-x64.msi
if not defined VBOX_ISO_URL set VBOX_ISO_URL=http://download.virtualbox.org/virtualbox/4.3.26/VBoxGuestAdditions_4.3.26.iso
if not defined VMWARE_TOOLS_TAR_URL set VMWARE_TOOLS_TAR_URL=https://softwareupdate.vmware.com/cds/vmw-desktop/ws/11.1.0/2496824/windows/packages/tools-windows-9.9.2.exe.tar
goto main

::::::::::::
:install_sevenzip
::::::::::::
if defined ProgramFiles(x86) (
  set SEVENZIP_URL=%SEVENZIP_64_URL%
) else (
  set SEVENZIP_URL=%SEVENZIP_32_URL%
)
pushd .
set SEVENZIP_EXE=
set SEVENZIP_DLL=
for %%i in (7z.exe) do set SEVENZIP_EXE=%%~$PATH:i
if defined SEVENZIP_EXE goto return0
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined SEVENZIP_EXE @if exist "%%~i\7z.exe" set SEVENZIP_EXE=%%~i\7z.exe
if not defined SEVENZIP_EXE goto get_sevenzip
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined SEVENZIP_DLL @if exist "%%~i\7z.dll" set SEVENZIP_DLL=%%~i\7z.dll
if not defined SEVENZIP_DLL goto get_sevenzip
ver >nul
call :copy_sevenzip
if not errorlevel 1 goto return0

:get_sevenzip
for %%i in ("%SEVENZIP_URL%") do set SEVENZIP_MSI=%%~nxi
set SEVENZIP_DIR=%TEMP%\sevenzip
set SEVENZIP_PATH=%SEVENZIP_DIR%\%SEVENZIP_MSI%
echo ==^> Creating "%SEVENZIP_DIR%"
mkdir "%SEVENZIP_DIR%"
cd /d "%SEVENZIP_DIR%"
if exist "%SystemRoot%\_download.cmd" (
  call "%SystemRoot%\_download.cmd" "%SEVENZIP_URL%" "%SEVENZIP_PATH%"
) else (
  echo ==^> Downloading "%SEVENZIP_URL%" to "%SEVENZIP_PATH%"
  powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SEVENZIP_URL%', '%SEVENZIP_PATH%')" <NUL
)
if not exist "%SEVENZIP_PATH%" goto return1
echo ==^> Installing "%SEVENZIP_PATH%"
msiexec /qb /i "%SEVENZIP_PATH%"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: msiexec /qb /i "%SEVENZIP_PATH%"
ver>nul
if exist "%ProgramFiles%\7-Zip" cd /D "%ProgramFiles%\7-Zip" & goto find_sevenzip
if defined ProgramFiles(x86) if exist "%ProgramFiles(x86)%\7-Zip" cd /D "%ProgramFiles(x86)%\7-Zip" & goto find_sevenzip
echo ==^> ERROR: Directory not found: "%ProgramFiles%\7-Zip"
goto return1

:find_sevenzip
set SEVENZIP_EXE=
for /r %%i in (7z.exe) do if exist "%%~i" set SEVENZIP_EXE=%%~i
if not exist "%SEVENZIP_EXE%" echo ==^> ERROR: Failed to unzip "%SEVENZIP_PATH%" & goto return1
set SEVENZIP_DLL=
for /r %%i in (7z.dll) do if exist "%%~i" set SEVENZIP_DLL=%%~i
if not exist "%SEVENZIP_DLL%" echo ==^> ERROR: Failed to unzip "%SEVENZIP_PATH%" & goto return1

:copy_sevenzip
echo ==^> Copying "%SEVENZIP_EXE%" to "%SystemRoot%"
copy /y "%SEVENZIP_EXE%" "%SystemRoot%\" || goto return1
copy /y "%SEVENZIP_DLL%" "%SystemRoot%\" || goto return1

:return0
popd
ver>nul
goto return

:return1
popd
verify other 2>nul

:return
goto :eof

::::::::::::
:main
::::::::::::
echo "%PACKER_BUILDER_TYPE%" | findstr /i "vmware" >nul
if not errorlevel 1 goto vmware
echo "%PACKER_BUILDER_TYPE%" | findstr /i "virtualbox" >nul
if not errorlevel 1 goto virtualbox
echo "%PACKER_BUILDER_TYPE%" | findstr /i "parallels" >nul
if not errorlevel 1 goto parallels
echo ==^> ERROR: Unknown PACKER_BUILDER_TYPE: "%PACKER_BUILDER_TYPE%"
pushd .
goto exit1

::::::::::::
:vmware
::::::::::::
if defined ProgramFiles(x86) (
  set VMWARE_TOOLS_SETUP_EXE=setup64.exe
) else (
  set VMWARE_TOOLS_SETUP_EXE=setup.exe
)
for %%i in ("%VMWARE_TOOLS_TAR_URL%") do set VMWARE_TOOLS_TAR=%%~nxi
set VMWARE_TOOLS_DIR=%TEMP%\vmware
set VMWARE_TOOLS_TAR_PATH=%VMWARE_TOOLS_DIR%\%VMWARE_TOOLS_TAR%
set VMWARE_TOOLS_ISO=windows.iso
mkdir "%VMWARE_TOOLS_DIR%"
pushd "%VMWARE_TOOLS_DIR%"
set VMWARE_TOOLS_SETUP_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VMWARE_TOOLS_SETUP_PATH @if exist "%%~i\VMwareToolsUpgrader.exe" set VMWARE_TOOLS_SETUP_PATH=%%~i\%VMWARE_TOOLS_SETUP_EXE%
if defined VMWARE_TOOLS_SETUP_PATH goto install_vmware_tools
set VMWARE_TOOLS_ISO_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VMWARE_TOOLS_ISO_PATH @if exist "%%~i\%VMWARE_TOOLS_ISO%" set VMWARE_TOOLS_ISO_PATH=%%~i\%VMWARE_TOOLS_ISO%
if defined VMWARE_TOOLS_ISO_PATH goto install_vmware_tools_from_iso
if exist "%SystemRoot%\_download.cmd" (
  call "%SystemRoot%\_download.cmd" "%VMWARE_TOOLS_TAR_URL%" "%VMWARE_TOOLS_TAR_PATH%"
) else (
  echo ==^> Downloading "%VMWARE_TOOLS_TAR_URL%" to "%VMWARE_TOOLS_TAR_PATH%"
  powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VMWARE_TOOLS_TAR_URL%', '%VMWARE_TOOLS_TAR_PATH%')" <NUL
)
if not exist "%VMWARE_TOOLS_TAR_PATH%" goto exit1
call :install_sevenzip
if errorlevel 1 goto exit1
7z e -y -o"%VMWARE_TOOLS_DIR%" "%VMWARE_TOOLS_TAR_PATH%" tools-windows-*.exe
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: 7z e "%VMWARE_TOOLS_TAR_PATH%"
ver>nul
set VMWARE_TOOLS_INSTALLER_PATH=
for %%i in (tools-windows-*.exe) do set VMWARE_TOOLS_INSTALLER_PATH=%CD%\%%~i
if not exist "%VMWARE_TOOLS_INSTALLER_PATH%" echo ==^> ERROR: Failed to unzip "%VMWARE_TOOLS_TAR_PATH%" & goto exit1
"%VMWARE_TOOLS_INSTALLER_PATH%" /s
set VMWARE_TOOLS_PROGRAM_FILES_DIR=%ProgramFiles%\VMware
if defined ProgramFiles(x86) set VMWARE_TOOLS_PROGRAM_FILES_DIR=%ProgramFiles(x86)%\VMware
if not exist "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" echo ==^> ERROR: Directory not found: "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" & goto exit1
set VMWARE_TOOLS_PROGRAM_FILES_ISO=
for /r "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" %%i in (%VMWARE_TOOLS_ISO%) do if exist "%%~i" set VMWARE_TOOLS_PROGRAM_FILES_ISO=%%~i
if not exist "%VMWARE_TOOLS_PROGRAM_FILES_ISO%" echo ==^> ERROR: File not found: "%VMWARE_TOOLS_ISO%" in "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" & goto exit1
set VMWARE_TOOLS_ISO_PATH="%VMWARE_TOOLS_DIR%\%VMWARE_TOOLS_ISO%"
copy /y "%VMWARE_TOOLS_PROGRAM_FILES_ISO%" "%VMWARE_TOOLS_ISO_PATH%"
if not exist "%VMWARE_TOOLS_ISO_PATH%" echo ==^> ERROR: File not found: "%VMWARE_TOOLS_ISO_PATH%" & goto exit1
rmdir /q /s "%VMWARE_TOOLS_PROGRAM_FILES_DIR%\tools-windows" || ver>nul
rmdir "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" || ver>nul

:install_vmware_tools_from_iso
call :install_sevenzip
if errorlevel 1 goto exit1
echo ==^> Extracting the VMWare Tools installer
7z e -o"%VMWARE_TOOLS_DIR%" "%VMWARE_TOOLS_ISO_PATH%" "%VMWARE_TOOLS_SETUP_EXE%"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: 7z e -o"%VMWARE_TOOLS_DIR%" "%VMWARE_TOOLS_ISO_PATH%" "%VMWARE_TOOLS_SETUP_EXE%"
ver>nul
set VMWARE_TOOLS_SETUP_PATH=%VMWARE_TOOLS_DIR%\%VMWARE_TOOLS_SETUP_EXE%
if not exist "%VMWARE_TOOLS_SETUP_PATH%" echo ==^> Unable to unzip "%VMWARE_TOOLS_ISO_PATH%" & goto exit1

:install_vmware_tools
echo ==^> Installing VMware tools
"%VMWARE_TOOLS_SETUP_PATH%" /S /v "/qn REBOOT=R ADDLOCAL=ALL"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: "%VMWARE_TOOLS_SETUP_PATH%" /S /v "/qn REBOOT=R ADDLOCAL=ALL"
ver>nul
goto exit0

::::::::::::
:virtualbox
::::::::::::
if exist "%SystemDrive%\Program Files (x86)" (
  set VBOX_SETUP_EXE=VBoxWindowsAdditions-amd64.exe
) else (
  set VBOX_SETUP_EXE=VBoxWindowsAdditions-x86.exe
)
for %%i in ("%VBOX_ISO_URL%") do set VBOX_ISO=%%~nxi
set VBOX_ISO_DIR=%TEMP%\vmware
set VBOX_ISO_PATH=%VBOX_ISO_DIR%\%VBOX_ISO%
set VBOX_ISO=VBoxGuestAdditions.iso
mkdir "%VBOX_ISO_DIR%"
pushd "%VBOX_ISO_DIR%"
set VBOX_SETUP_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VBOX_SETUP_PATH @if exist "%%~i\%VBOX_SETUP_EXE%" set VBOX_SETUP_PATH=%%~i\%VBOX_SETUP_EXE%
if defined VBOX_SETUP_PATH goto install_vbox_guest_additions
set VBOX_ISO_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VBOX_ISO_PATH @if exist "%%~i\%VBOX_ISO%" set VBOX_ISO_PATH=%%~i\%VBOX_ISO%
if defined VBOX_ISO_PATH goto install_vbox_guest_additions_from_iso
if exist "%SystemRoot%\_download.cmd" (
  call "%SystemRoot%\_download.cmd" "%VBOX_ISO_URL%" "%VBOX_ISO_PATH%"
) else (
  echo ==^> Downloading "%VBOX_ISO_URL%" to "%VBOX_ISO_PATH%"
  powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VBOX_ISO_URL%', '%VBOX_ISO_PATH%')" <NUL
)
if not exist "%VBOX_ISO_PATH%" goto exit1

:install_vbox_guest_additions_from_iso
call :install_sevenzip
if errorlevel 1 goto exit1
echo ==^> Extracting the VirtualBox Guest Additions installer
7z e -o"%VBOX_ISO_DIR%" "%VBOX_ISO_PATH%" "%VBOX_SETUP_EXE%"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: 7z e -o"%VBOX_ISO_DIR%" "%VBOX_ISO_PATH%" "%VBOX_SETUP_EXE%"
ver>nul
set VBOX_SETUP_PATH=%VBOX_ISO_DIR%\%VBOX_SETUP_EXE%
if not exist "%VBOX_SETUP_PATH%" echo ==^> Unable to unzip "%VBOX_ISO_PATH%" & goto exit1

:install_vbox_guest_additions
if not exist a:\oracle-cert.cer echo ==^> ERROR: File not found: a:\oracle-cert.cer & goto exit1
echo ==^> Installing Oracle certificate to keep install silent
certutil -addstore -f "TrustedPublisher" a:\oracle-cert.cer
echo ==^> Installing VirtualBox Guest Additions
"%VBOX_SETUP_PATH%" /S
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: "%VBOX_SETUP_PATH%" /S
ver>nul
goto :exit0

::::::::::::
:parallels
::::::::::::
set PARALLELS_INSTALL=PTAgent.exe
REM parallels tools don't have a download :(
call :install_sevenzip
if errorlevel 1 goto exit1
echo ==^> Extracting the Parallels Tools installer
echo ==^>   to %TEMP%\parallels\*
7z x -o"%TEMP%\parallels" "%USERPROFILE%\prl-tools-win.iso"
ping 127.0.0.1
echo ==^> Installing Parallels Tools
echo ==^>   from %TEMP%\parallels\%PARALLELS_INSTALL%
"%TEMP%\parallels\%PARALLELS_INSTALL%" /install_silent
REM parallels tools installer tends to exit while the install agent
REM is still running, need to sleep while it's running so we don't
REM delete the tools.
@if errorlevel 1 echo=^> WARNING: Error %ERRORLEVEL% was returned by: "%PARALLELS_INSTALL%" /install_silent
ver>nul
echo ==^> Cleaning up Parallels Tools install
del /F /S /Q "%TEMP%\parallels"
echo ==^> Removing "%USERPROFILE%\prl-tools-win.iso"
del /F "%USERPROFILE%\prl-tools-win.iso"
goto :exit0

:exit0
popd
@ping 127.0.0.1
@ver>nul
@goto :exit

:exit1
popd
@ping 127.0.0.1
@verify other 2>nul

:exit
@echo ==^> Script exiting with errorlevel %ERRORLEVEL%
@exit /b %ERRORLEVEL%

@setlocal EnableDelayedExpansion EnableExtensions
@for %%i in (a:\_packer_config*.cmd) do @call "%%~i"
@if defined PACKER_DEBUG (@echo on) else (@echo off)

if not defined PACKER_SEARCH_PATHS set PACKER_SEARCH_PATHS="%USERPROFILE%" a: b: c: d: e: f: g: h: i: j: k: l: m: n: o: p: q: r: s: t: u: v: w: x: y: z:
if not defined SEVENZIP_32_URL set SEVENZIP_32_URL=http://downloads.sourceforge.net/sevenzip/7z938.msi
if not defined SEVENZIP_64_URL set SEVENZIP_64_URL=http://downloads.sourceforge.net/sevenzip/7z938-x64.msi
if not defined VBOX_ISO_URL set VBOX_ISO_URL=http://download.virtualbox.org/virtualbox/4.3.26/VBoxGuestAdditions_4.3.26.iso
if not defined VMWARE_TOOLS_TAR_URL set VMWARE_TOOLS_TAR_URL=https://softwareupdate.vmware.com/cds/vmw-desktop/ws/11.1.0/2496824/windows/packages/tools-windows-9.9.2.exe.tar
goto main

::::::::::::
:install_sevenzip
::::::::::::
if defined ProgramFiles(x86) (
  set SEVENZIP_URL=%SEVENZIP_64_URL%
) else (
  set SEVENZIP_URL=%SEVENZIP_32_URL%
)
pushd .
set SEVENZIP_EXE=
set SEVENZIP_DLL=
for %%i in (7z.exe) do set SEVENZIP_EXE=%%~$PATH:i
if defined SEVENZIP_EXE goto return0
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined SEVENZIP_EXE @if exist "%%~i\7z.exe" set SEVENZIP_EXE=%%~i\7z.exe
if not defined SEVENZIP_EXE goto get_sevenzip
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined SEVENZIP_DLL @if exist "%%~i\7z.dll" set SEVENZIP_DLL=%%~i\7z.dll
if not defined SEVENZIP_DLL goto get_sevenzip
ver >nul
call :copy_sevenzip
if not errorlevel 1 goto return0

:get_sevenzip
for %%i in ("%SEVENZIP_URL%") do set SEVENZIP_MSI=%%~nxi
set SEVENZIP_DIR=%TEMP%\sevenzip
set SEVENZIP_PATH=%SEVENZIP_DIR%\%SEVENZIP_MSI%
echo ==^> Creating "%SEVENZIP_DIR%"
mkdir "%SEVENZIP_DIR%"
cd /d "%SEVENZIP_DIR%"
if exist "%SystemRoot%\_download.cmd" (
  call "%SystemRoot%\_download.cmd" "%SEVENZIP_URL%" "%SEVENZIP_PATH%"
) else (
  echo ==^> Downloading "%SEVENZIP_URL%" to "%SEVENZIP_PATH%"
  powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SEVENZIP_URL%', '%SEVENZIP_PATH%')" <NUL
)
if not exist "%SEVENZIP_PATH%" goto return1
echo ==^> Installing "%SEVENZIP_PATH%"
msiexec /qb /i "%SEVENZIP_PATH%"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: msiexec /qb /i "%SEVENZIP_PATH%"
ver>nul
if exist "%ProgramFiles%\7-Zip" cd /D "%ProgramFiles%\7-Zip" & goto find_sevenzip
if defined ProgramW6432 if exist "%ProgramW6432%\7-Zip" cd /D "%ProgramW6432%\7-Zip" & goto find_sevenzip
if defined ProgramFiles(x86) if exist "%ProgramFiles(x86)%\7-Zip" cd /D "%ProgramFiles(x86)%\7-Zip" & goto find_sevenzip
echo ==^> ERROR: Directory not found: "%ProgramFiles%\7-Zip"
goto return1

:find_sevenzip
set SEVENZIP_EXE=
for /r %%i in (7z.exe) do if exist "%%~i" set SEVENZIP_EXE=%%~i
if not exist "%SEVENZIP_EXE%" echo ==^> ERROR: Failed to unzip "%SEVENZIP_PATH%" & goto return1
set SEVENZIP_DLL=
for /r %%i in (7z.dll) do if exist "%%~i" set SEVENZIP_DLL=%%~i
if not exist "%SEVENZIP_DLL%" echo ==^> ERROR: Failed to unzip "%SEVENZIP_PATH%" & goto return1

:copy_sevenzip
echo ==^> Copying "%SEVENZIP_EXE%" to "%SystemRoot%"
copy /y "%SEVENZIP_EXE%" "%SystemRoot%\" || goto return1
copy /y "%SEVENZIP_DLL%" "%SystemRoot%\" || goto return1

:return0
popd
ver>nul
goto return

:return1
popd
verify other 2>nul

:return
goto :eof

::::::::::::
:main
::::::::::::
echo "%PACKER_BUILDER_TYPE%" | findstr /i "vmware" >nul
if not errorlevel 1 goto vmware
echo "%PACKER_BUILDER_TYPE%" | findstr /i "virtualbox" >nul
if not errorlevel 1 goto virtualbox
echo "%PACKER_BUILDER_TYPE%" | findstr /i "parallels" >nul
if not errorlevel 1 goto parallels
echo ==^> ERROR: Unknown PACKER_BUILDER_TYPE: "%PACKER_BUILDER_TYPE%"
pushd .
goto exit1

::::::::::::
:vmware
::::::::::::
if defined ProgramFiles(x86) (
  set VMWARE_TOOLS_SETUP_EXE=setup64.exe
) else (
  set VMWARE_TOOLS_SETUP_EXE=setup.exe
)
for %%i in ("%VMWARE_TOOLS_TAR_URL%") do set VMWARE_TOOLS_TAR=%%~nxi
set VMWARE_TOOLS_DIR=%TEMP%\vmware
set VMWARE_TOOLS_TAR_PATH=%VMWARE_TOOLS_DIR%\%VMWARE_TOOLS_TAR%
set VMWARE_TOOLS_ISO=windows.iso
mkdir "%VMWARE_TOOLS_DIR%"
pushd "%VMWARE_TOOLS_DIR%"
set VMWARE_TOOLS_SETUP_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VMWARE_TOOLS_SETUP_PATH @if exist "%%~i\VMwareToolsUpgrader.exe" set VMWARE_TOOLS_SETUP_PATH=%%~i\%VMWARE_TOOLS_SETUP_EXE%
if defined VMWARE_TOOLS_SETUP_PATH goto install_vmware_tools
set VMWARE_TOOLS_ISO_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VMWARE_TOOLS_ISO_PATH @if exist "%%~i\%VMWARE_TOOLS_ISO%" set VMWARE_TOOLS_ISO_PATH=%%~i\%VMWARE_TOOLS_ISO%
if defined VMWARE_TOOLS_ISO_PATH goto install_vmware_tools_from_iso
if exist "%SystemRoot%\_download.cmd" (
  call "%SystemRoot%\_download.cmd" "%VMWARE_TOOLS_TAR_URL%" "%VMWARE_TOOLS_TAR_PATH%"
) else (
  echo ==^> Downloading "%VMWARE_TOOLS_TAR_URL%" to "%VMWARE_TOOLS_TAR_PATH%"
  powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VMWARE_TOOLS_TAR_URL%', '%VMWARE_TOOLS_TAR_PATH%')" <NUL
)
if not exist "%VMWARE_TOOLS_TAR_PATH%" goto exit1
call :install_sevenzip
if errorlevel 1 goto exit1
7z e -y -o"%VMWARE_TOOLS_DIR%" "%VMWARE_TOOLS_TAR_PATH%" tools-windows-*.exe
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: 7z e "%VMWARE_TOOLS_TAR_PATH%"
ver>nul
set VMWARE_TOOLS_INSTALLER_PATH=
for %%i in (tools-windows-*.exe) do set VMWARE_TOOLS_INSTALLER_PATH=%CD%\%%~i
if not exist "%VMWARE_TOOLS_INSTALLER_PATH%" echo ==^> ERROR: Failed to unzip "%VMWARE_TOOLS_TAR_PATH%" & goto exit1
"%VMWARE_TOOLS_INSTALLER_PATH%" /s
set VMWARE_TOOLS_PROGRAM_FILES_DIR=%ProgramFiles%\VMware
if defined ProgramFiles(x86) set VMWARE_TOOLS_PROGRAM_FILES_DIR=%ProgramFiles(x86)%\VMware
if not exist "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" echo ==^> ERROR: Directory not found: "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" & goto exit1
set VMWARE_TOOLS_PROGRAM_FILES_ISO=
for /r "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" %%i in (%VMWARE_TOOLS_ISO%) do if exist "%%~i" set VMWARE_TOOLS_PROGRAM_FILES_ISO=%%~i
if not exist "%VMWARE_TOOLS_PROGRAM_FILES_ISO%" echo ==^> ERROR: File not found: "%VMWARE_TOOLS_ISO%" in "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" & goto exit1
set VMWARE_TOOLS_ISO_PATH="%VMWARE_TOOLS_DIR%\%VMWARE_TOOLS_ISO%"
copy /y "%VMWARE_TOOLS_PROGRAM_FILES_ISO%" "%VMWARE_TOOLS_ISO_PATH%"
if not exist "%VMWARE_TOOLS_ISO_PATH%" echo ==^> ERROR: File not found: "%VMWARE_TOOLS_ISO_PATH%" & goto exit1
rmdir /q /s "%VMWARE_TOOLS_PROGRAM_FILES_DIR%\tools-windows" || ver>nul
rmdir "%VMWARE_TOOLS_PROGRAM_FILES_DIR%" || ver>nul

:install_vmware_tools_from_iso
call :install_sevenzip
if errorlevel 1 goto exit1
echo ==^> Extracting the VMWare Tools installer
7z e -o"%VMWARE_TOOLS_DIR%" "%VMWARE_TOOLS_ISO_PATH%" "%VMWARE_TOOLS_SETUP_EXE%"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: 7z e -o"%VMWARE_TOOLS_DIR%" "%VMWARE_TOOLS_ISO_PATH%" "%VMWARE_TOOLS_SETUP_EXE%"
ver>nul
set VMWARE_TOOLS_SETUP_PATH=%VMWARE_TOOLS_DIR%\%VMWARE_TOOLS_SETUP_EXE%
if not exist "%VMWARE_TOOLS_SETUP_PATH%" echo ==^> Unable to unzip "%VMWARE_TOOLS_ISO_PATH%" & goto exit1

:install_vmware_tools
echo ==^> Installing VMware tools
"%VMWARE_TOOLS_SETUP_PATH%" /S /v "/qn REBOOT=R ADDLOCAL=ALL"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: "%VMWARE_TOOLS_SETUP_PATH%" /S /v "/qn REBOOT=R ADDLOCAL=ALL"
ver>nul
goto exit0

::::::::::::
:virtualbox
::::::::::::
if exist "%SystemDrive%\Program Files (x86)" (
  set VBOX_SETUP_EXE=VBoxWindowsAdditions-amd64.exe
) else (
  set VBOX_SETUP_EXE=VBoxWindowsAdditions-x86.exe
)
for %%i in ("%VBOX_ISO_URL%") do set VBOX_ISO=%%~nxi
set VBOX_ISO_DIR=%TEMP%\vmware
set VBOX_ISO_PATH=%VBOX_ISO_DIR%\%VBOX_ISO%
set VBOX_ISO=VBoxGuestAdditions.iso
mkdir "%VBOX_ISO_DIR%"
pushd "%VBOX_ISO_DIR%"
set VBOX_SETUP_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VBOX_SETUP_PATH @if exist "%%~i\%VBOX_SETUP_EXE%" set VBOX_SETUP_PATH=%%~i\%VBOX_SETUP_EXE%
if defined VBOX_SETUP_PATH goto install_vbox_guest_additions
set VBOX_ISO_PATH=
@for %%i in (%PACKER_SEARCH_PATHS%) do @if not defined VBOX_ISO_PATH @if exist "%%~i\%VBOX_ISO%" set VBOX_ISO_PATH=%%~i\%VBOX_ISO%
if defined VBOX_ISO_PATH goto install_vbox_guest_additions_from_iso
if exist "%SystemRoot%\_download.cmd" (
  call "%SystemRoot%\_download.cmd" "%VBOX_ISO_URL%" "%VBOX_ISO_PATH%"
) else (
  echo ==^> Downloading "%VBOX_ISO_URL%" to "%VBOX_ISO_PATH%"
  powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%VBOX_ISO_URL%', '%VBOX_ISO_PATH%')" <NUL
)
if not exist "%VBOX_ISO_PATH%" goto exit1

:install_vbox_guest_additions_from_iso
call :install_sevenzip
if errorlevel 1 goto exit1
echo ==^> Extracting the VirtualBox Guest Additions installer
7z e -o"%VBOX_ISO_DIR%" "%VBOX_ISO_PATH%" "%VBOX_SETUP_EXE%"
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: 7z e -o"%VBOX_ISO_DIR%" "%VBOX_ISO_PATH%" "%VBOX_SETUP_EXE%"
ver>nul
set VBOX_SETUP_PATH=%VBOX_ISO_DIR%\%VBOX_SETUP_EXE%
if not exist "%VBOX_SETUP_PATH%" echo ==^> Unable to unzip "%VBOX_ISO_PATH%" & goto exit1

:install_vbox_guest_additions
if not exist a:\oracle-cert.cer echo ==^> ERROR: File not found: a:\oracle-cert.cer & goto exit1
echo ==^> Installing Oracle certificate to keep install silent
certutil -addstore -f "TrustedPublisher" a:\oracle-cert.cer
echo ==^> Installing VirtualBox Guest Additions
"%VBOX_SETUP_PATH%" /S
@if errorlevel 1 echo ==^> WARNING: Error %ERRORLEVEL% was returned by: "%VBOX_SETUP_PATH%" /S
ver>nul
goto :exit0

::::::::::::
:parallels
::::::::::::
set PARALLELS_INSTALL=PTAgent.exe
REM parallels tools don't have a download :(
call :install_sevenzip
if errorlevel 1 goto exit1
echo ==^> Extracting the Parallels Tools installer
echo ==^>   to %TEMP%\parallels\*
7z x -o"%TEMP%\parallels" "%USERPROFILE%\prl-tools-win.iso"
ping 127.0.0.1
echo ==^> Installing Parallels Tools
echo ==^>   from %TEMP%\parallels\%PARALLELS_INSTALL%
"%TEMP%\parallels\%PARALLELS_INSTALL%" /install_silent
REM parallels tools installer tends to exit while the install agent
REM is still running, need to sleep while it's running so we don't
REM delete the tools.
@if errorlevel 1 echo=^> WARNING: Error %ERRORLEVEL% was returned by: "%PARALLELS_INSTALL%" /install_silent
ver>nul
echo ==^> Cleaning up Parallels Tools install
del /F /S /Q "%TEMP%\parallels"
echo ==^> Removing "%USERPROFILE%\prl-tools-win.iso"
del /F "%USERPROFILE%\prl-tools-win.iso"
goto :exit0

:exit0
popd
@ping 127.0.0.1
@ver>nul
@goto :exit

:exit1
popd
@ping 127.0.0.1
@verify other 2>nul

:exit
@echo ==^> Script exiting with errorlevel %ERRORLEVEL%
@exit /b %ERRORLEVEL%

Update vmtool.bat

Update vmtool.bat