@echo off

:: ---------------------------------------------------------------------------------------
:: The MIT License (MIT)
::
:: Copyright (c) 2014 Andrew Meserole
::
:: Permission is hereby granted, free of charge, to any person obtaining a copy
:: of this software and associated documentation files (the "Software"), to deal
:: in the Software without restriction, including without limitation the rights
:: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
:: copies of the Software, and to permit persons to whom the Software is
:: furnished to do so, subject to the following conditions:
::
:: The above copyright notice and this permission notice shall be included in all
:: copies or substantial portions of the Software.
::
:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
:: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
:: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
:: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
:: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
:: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
:: SOFTWARE.
:: ---------------------------------------------------------------------------------------
::
:: Batch file for Tableau Server 8.2+.
:: The purpose of this batch file is to provide a way to
:: export a multi-tab workbook to PDF format and to
:: automatically email the result as an attachment.
::
:: It is written to echo all commands and output to a log file for debug.
::
:: It also assumes you have created certain directories on your Tableau server
:: where the actual bat files that you might want to run as scheduled Windows tasks.
:: C:\Program Files\Tableau\Tableau Server\tableau_tasks
:: C:\Program Files\Tableau\Tableau Server\tableau_tasks\logs
:: C:\Program Files\Tableau\Tableau Server\tableau_exports
::
:: It also assumes you have febooti command line email utility installed.
:: See here for info: http://www.febooti.com/products/command-line-email/
:: This is a very affordable tool and super easy to install.
:: Approx. $160 for 1 corporate license + 3 years maintenance as of August 2014.
::
:: It also uses information gleaned from these Tableau Support pages:
:: http://onlinehelp.tableausoftware.com/v8.2/server/en-us/tabcmd_cmd.htm#id7cb8d032-a4ff-43da-9990-15bdfe64bcd0
:: http://kb.tableausoftware.com/articles/knowledgebase/using-tabcmd
::
:: You should be able to easily modify this script to export csv or png.
:: There are several of switches you can alter to control page layout and size.
::
:: After you have made your changes, you can schedule it via Windows Server Task Scheduler.
:: Be sure to schedule to run with elevated permissions to avoid problems.

::setup date time key
for /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
for /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
for /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
for /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
for /F "TOKENS=1 DELIMS=: " %%h in ('time /T') do set hour=%%h
for /F "TOKENS=2 DELIMS=: " %%m in ('time /T') do set minutes=%%m
set dt_key=%yyyy%%mm%%dd%
set ts_key=%yyyy%%mm%%dd%-%hour%%minutes%
set date_string=%mm%/%dd%/%yyyy%

:: START EDITING HERE!

:: THIS SETUP VAR SECTION IS THE ONLY PLACE YOU SHOULD NEED TO MAKE CHANGES.
:: But you MUST check them all.  The ones below are either for examples or stubs.
:: SETUP VARS
:: This set variable section is the only place you should need to make changes to export and email PDFs.
:: Note I install Tableau Server not to Program Files/Tableau Server but to a path with no spaces in the name.
:: There are a variety of odd-ball situations that can cocur that are caused by having spaces in the path.
set tableau_drive=C:
set tableau_root=C:\tableau\tableauserver
set tableau_bin_dir="%tableau_root%\8.2\bin"
set script_drive=C:
set script_root=C:
set script_dir=%script_root%\tableau_tasks
set usr=<Put your username here. Remove the brackets of course.>
set pwd="<Put your password here.  Keep the double quotes!>"
set svr="https://your.tableau.host"
:: or possibly set svr="http://your.tableau.host"
:: or maybe with ssl.  So set svr="https://your.tableau.host"
::
:: If workbook is in default site,
:: site variable should be left empty
:: Otherwise set like this...
:: set site=-t <site name>
:: So for default.
set site=
:: For another site such as Sales
:: set site=-t Sales
set log_dir=%script_dir%\logs
set log_file=report_log
set log_ext=log
set log="%log_dir%\%log_file%-%dt_key%.%log_ext%"
set report_admin=some.email.addr.you.choose@yourcompany.com
:: report_loc is the workbook in Tableau.
:: Format is <Workbook-Name>/<Name-of-First-Tab>.
:: You can figure this out by just navigating to the workbook
:: in a browser and checking the path.
set report_loc="Workbook/FirstTab"
set export_dir=%script_root%\tableau_exports
set report=report_name_%dt_key%.pdf
:: Formatting options for export vars.
:: Format choices are --csv, --pdf, --png, --fullpdf.
set format=--fullpdf
:: Pagelayout choices are landscape, portrait.
set pagelayout=--pagelayout portrait
:: Pagesize options are letter, legal, note folio, tabloid, ledger, statement, executive, a3, a4, a5, b4, b5, quatro
set pagesize=--pagesize letter
:: Email related vars.
set attachment="%export_dir%\%report%"
set smtp_server=smtp.yourcompany.com
set from_email=some.email.addr@yourcompany.com
:: At least one of to_email, cc_email, bcc_email is required.
:: But any of them can just be left empty.
::set to_email=
set to_email=-TO "some-email-address@company-aye.com; some-other-mail-address@company-bee.com"
set cc_email=
set bcc_email=-BCC "%report_admin%"
set email_subject=-SUBJECT "Your report for %date_string%."
set email_body=-BODY "Please find attached your report for %date_string%.  Please direct question to %from_email%."

:: STOP EDITING HERE!

echo ---------------------------------------------- > %log%
echo ---------- variables ------------------------- >> %log%
echo ---------------------------------------------- >> %log%
echo dt_key          = %dt_key% >> %log%
echo ts_key          = %ts_key% >> %log%
echo date_string     = %date_string% >> %log%
echo tableau_drive   = %tableau_drive% >> %log%
echo tableau_root    = %tableau_root% >> %log%
echo tableau_bin_dir = %tableau_bin_dir% >> %log%
echo script_drive    = %script_drive% >> %log%
echo script_dir      = %script_dir% >> %log%
echo usr             = %usr% >> %log%
echo svr             = %svr% >> %log%
echo site            = %site% >> %log%
echo log_dir         = %log_dir% >> %log%
echo log_file        = %log_file% >> %log%
echo log_ext         = %log_ext% >> %log%
echo log             = %log% >> %log%
echo report_admin    = %report_admin% >> %log%
echo report_loc      = %report_loc% >> %log%
echo export_dir      = %export_dir% >> %log%
echo report          = %report% >> %log%
echo format          = %format% >> %log%
echo pagelayout      = %pagelayout% >> %log%
echo pagesize        = %pagesize% >> %log%
echo attachment      = %attachment% >> %log%
echo smtp_server     = %smtp_server% >> %log%
echo from_email      = %from_email% >> %log%
echo to_email        = %to_email% >> %log%
echo cc_email        = %cc_email% >> %log%
echo bcc_email       = %bcc_email% >> %log%
echo email_subject   = %email_subject% >> %log%
echo email_body      = %email_body% >> %log%
echo. >> %log%
echo. >> %log%

echo ----------------------------------------------- >> %log%
echo ---------- change to Tableau bin dir ---------- >> %log%
echo ----------------------------------------------- >> %log%
%tableau_drive% >> %log%
cd %tableau_bin_dir% >> %log%
echo Current location check: %CD% >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- logging in to tableau site ---------- >> %log%
echo ------------------------------------------------ >> %log%
echo tabcmd login -u %usr% -p %pwd% -s %svr% %site% --no-certcheck >> %log%
tabcmd login -u %usr% -p %pwd% -s %svr% %site% --no-certcheck >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- export the report ------------------- >> %log%
echo ------------------------------------------------ >> %log%
echo tabcmd export %site% %report_loc% %format% %pagelayout% %pagesize% -f %attachment% >> %log%
tabcmd export %site% %report_loc% %format% %pagelayout% %pagesize% -f %attachment% >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- email the report -------------------- >> %log%
echo ------------------------------------------------ >> %log%
echo febootimail.exe -SMTP %smtp_server% -FROM %from_email% %to_email% %cc_email% %bcc_email% %email_subject% -ATTACH %attachment% %email_body% >> %log%
febootimail.exe -SMTP %smtp_server% -FROM %from_email% %to_email% %cc_email% %bcc_email% %email_subject% -ATTACH %attachment% %email_body% >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- logging in to Default site ---------- >> %log%
echo ------------------------------------------------ >> %log%
echo tabcmd logout >> %log%
tabcmd logout >> %log%
echo. >> %log%
echo. >> %log%

exit

@echo off

:: ---------------------------------------------------------------------------------------
:: The MIT License (MIT)
::
:: Copyright (c) 2014 Andrew Meserole
::
:: Permission is hereby granted, free of charge, to any person obtaining a copy
:: of this software and associated documentation files (the "Software"), to deal
:: in the Software without restriction, including without limitation the rights
:: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
:: copies of the Software, and to permit persons to whom the Software is
:: furnished to do so, subject to the following conditions:
::
:: The above copyright notice and this permission notice shall be included in all
:: copies or substantial portions of the Software.
::
:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
:: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
:: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
:: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
:: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
:: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
:: SOFTWARE.
:: ---------------------------------------------------------------------------------------
::
:: Batch file for Tableau Server 8.2+.
:: The purpose of this batch file is to provide a way to
:: export a multi-tab workbook to PDF format and to
:: automatically email the result as an attachment.
::
:: It is written to echo all commands and output to a log file for debug.
::
:: It also assumes you have created certain directories on your Tableau server
:: where the actual bat files that you might want to run as scheduled Windows tasks.
:: C:\Program Files\Tableau\Tableau Server\tableau_tasks
:: C:\Program Files\Tableau\Tableau Server\tableau_tasks\logs
:: C:\Program Files\Tableau\Tableau Server\tableau_exports
::
:: It also assumes you have febooti command line email utility installed.
:: See here for info: http://www.febooti.com/products/command-line-email/
:: This is a very affordable tool and super easy to install.
:: Approx. $160 for 1 corporate license + 3 years maintenance as of August 2014.
::
:: It also uses information gleaned from these Tableau Support pages:
:: http://onlinehelp.tableausoftware.com/v8.2/server/en-us/tabcmd_cmd.htm#id7cb8d032-a4ff-43da-9990-15bdfe64bcd0
:: http://kb.tableausoftware.com/articles/knowledgebase/using-tabcmd
::
:: You should be able to easily modify this script to export csv or png.
:: There are several of switches you can alter to control page layout and size.
::
:: After you have made your changes, you can schedule it via Windows Server Task Scheduler.
:: Be sure to schedule to run with elevated permissions to avoid problems.

:: START EDITING HERE!

::setup date time key
for /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
for /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
for /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
for /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
for /F "TOKENS=1 DELIMS=: " %%h in ('time /T') do set hour=%%h
for /F "TOKENS=2 DELIMS=: " %%m in ('time /T') do set minutes=%%m
set dt_key=%yyyy%%mm%%dd%
set ts_key=%yyyy%%mm%%dd%-%hour%%minutes%
set date_string=%mm%/%dd%/%yyyy%

:: THIS SETUP VAR SECTION IS THE ONLY PLACE YOU SHOULD NEED TO MAKE CHANGES.
:: But you MUST check them all.  The ones below are either for examples or stubs.
:: SETUP VARS
:: This set variable section is the only place you should need to make changes to export and email PDFs.
:: Note I install Tableau Server not to Program Files/Tableau Server but to a path with no spaces in the name.
:: There are a variety of odd-ball situations that can cocur that are caused by having spaces in the path.
set tableau_drive=C:
set tableau_root=C:\tableau\tableauserver
set tableau_bin_dir="%tableau_root%\8.2\bin"
set script_drive=C:
set script_root=C:
set script_dir=%script_root%\tableau_tasks
set usr=<Put your username here. Remove the brackets of course.>
set pwd="<Put your password here.  Keep the double quotes!>"
set svr="https://your.tableau.host"
:: or possibly set svr="http://your.tableau.host"
:: or maybe with ssl.  So set svr="https://your.tableau.host"
::
:: If workbook is in default site,
:: site variable should be left empty
:: Otherwise set like this...
:: set site=-t <site name>
:: So for default.
set site=
:: For another site such as Sales
:: set site=-t Sales
set log_dir=%script_dir%\logs
set log_file=report_log
set log_ext=log
set log="%log_dir%\%log_file%-%dt_key%.%log_ext%"
set report_admin=some.email.addr.you.choose@yourcompany.com
:: report_loc is the workbook in Tableau.
:: Format is <Workbook-Name>/<Name-of-First-Tab>.
:: You can figure this out by just navigating to the workbook
:: in a browser and checking the path.
set report_loc="Workbook/FirstTab"
set export_dir=%script_root%\tableau_exports
set report=report_name_%dt_key%.pdf
:: Formatting options for export vars.
:: Format choices are --csv, --pdf, --png, --fullpdf.
set format=--fullpdf
:: Pagelayout choices are landscape, portrait.
set pagelayout=--pagelayout portrait
:: Pagesize options are letter, legal, note folio, tabloid, ledger, statement, executive, a3, a4, a5, b4, b5, quatro
set pagesize=--pagesize letter
:: Email related vars.
set attachment="%export_dir%\%report%"
set smtp_server=smtp.yourcompany.com
set from_email=some.email.addr@yourcompany.com
:: At least one of to_email, cc_email, bcc_email is required.
:: But any of them can just be left empty.
::set to_email=
set to_email=-TO "some-email-address@company-aye.com; some-other-mail-address@company-bee.com"
set cc_email=
set bcc_email=-BCC "%report_admin%"
set email_subject=-SUBJECT "Your report for %date_string%."
set email_body=-BODY "Please find attached your report for %date_string%.  Please direct question to %from_email%."

:: STOP EDITING HERE!

echo ---------------------------------------------- > %log%
echo ---------- variables ------------------------- >> %log%
echo ---------------------------------------------- >> %log%
echo dt_key          = %dt_key% >> %log%
echo ts_key          = %ts_key% >> %log%
echo date_string     = %date_string% >> %log%
echo tableau_drive   = %tableau_drive% >> %log%
echo tableau_root    = %tableau_root% >> %log%
echo tableau_bin_dir = %tableau_bin_dir% >> %log%
echo script_drive    = %script_drive% >> %log%
echo script_dir      = %script_dir% >> %log%
echo usr             = %usr% >> %log%
echo svr             = %svr% >> %log%
echo site            = %site% >> %log%
echo log_dir         = %log_dir% >> %log%
echo log_file        = %log_file% >> %log%
echo log_ext         = %log_ext% >> %log%
echo log             = %log% >> %log%
echo report_admin    = %report_admin% >> %log%
echo report_loc      = %report_loc% >> %log%
echo export_dir      = %export_dir% >> %log%
echo report          = %report% >> %log%
echo format          = %format% >> %log%
echo pagelayout      = %pagelayout% >> %log%
echo pagesize        = %pagesize% >> %log%
echo attachment      = %attachment% >> %log%
echo smtp_server     = %smtp_server% >> %log%
echo from_email      = %from_email% >> %log%
echo to_email        = %to_email% >> %log%
echo cc_email        = %cc_email% >> %log%
echo bcc_email       = %bcc_email% >> %log%
echo email_subject   = %email_subject% >> %log%
echo email_body      = %email_body% >> %log%
echo. >> %log%
echo. >> %log%

echo ----------------------------------------------- >> %log%
echo ---------- change to Tableau bin dir ---------- >> %log%
echo ----------------------------------------------- >> %log%
%tableau_drive% >> %log%
cd %tableau_bin_dir% >> %log%
echo Current location check: %CD% >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- logging in to tableau site ---------- >> %log%
echo ------------------------------------------------ >> %log%
echo tabcmd login -u %usr% -p %pwd% -s %svr% %site% --no-certcheck >> %log%
tabcmd login -u %usr% -p %pwd% -s %svr% %site% --no-certcheck >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- export the report ------------------- >> %log%
echo ------------------------------------------------ >> %log%
echo tabcmd export %site% %report_loc% %format% %pagelayout% %pagesize% -f %attachment% >> %log%
tabcmd export %site% %report_loc% %format% %pagelayout% %pagesize% -f %attachment% >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- email the report -------------------- >> %log%
echo ------------------------------------------------ >> %log%
echo febootimail.exe -SMTP %smtp_server% -FROM %from_email% %to_email% %cc_email% %bcc_email% %email_subject% -ATTACH %attachment% %email_body% >> %log%
febootimail.exe -SMTP %smtp_server% -FROM %from_email% %to_email% %cc_email% %bcc_email% %email_subject% -ATTACH %attachment% %email_body% >> %log%
echo. >> %log%
echo. >> %log%

echo ------------------------------------------------ >> %log%
echo ---------- logging in to Default site ---------- >> %log%
echo ------------------------------------------------ >> %log%
echo tabcmd logout >> %log%
tabcmd logout >> %log%
echo. >> %log%
echo. >> %log%

exit

Revert "Minor change."

Revert "Minor change."

This reverts commit 202f21a25d0b692dab3e6b2f25cce9b230ab31d4.


@echo off
setlocal

set ATOM_SHELL_INTERNAL_RUN_AS_NODE=1

pushd %~dp0\..
.\.build\electron\electron.exe .\node_modules\mocha\bin\_mocha %*
popd

endlocal

remove echo off from tests

remove echo off from tests


@echo off

set INSTALLER=InstallDocker.exe

rem for Windows 10 Pro (Latest)
set URL="https://download.docker.com/win/stable/Docker for Windows Installer.exe"

rem for Windows 7/8/8.1 (Legacy)
rem set URL="https://download.docker.com/win/stable/DockerToolbox.exe"

cd /d %~dp0
bitsadmin /RawReturn /TRANSFER download %URL% %CD%\%INSTALLER%

call %INSTALLER%
del /q %INSTALLER%

pause
exit

add bat script

scripts: add bat script


@echo off

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

rem
rem mxmlc.bat script to launch falcon-mxmlc.jar in Windows Command Prompt.
rem On OSX, Unix, or Cygwin, use the mxmlc shell script instead.
rem

if "x%FALCON_HOME%"=="x"  (set "FALCON_HOME=%~dp0..\..") else echo Using Falcon codebase: %FALCON_HOME%

if "x%FLEX_HOME%"=="x" (set "FLEX_HOME=%~dp0..\..") else echo Using Flex SDK: %FLEX_HOME%

@java -Dsun.io.useCanonCaches=false -Xms32m -Xmx512m -Dflexcompiler="%FALCON_HOME%" -Dflexlib="%FLEX_HOME%\frameworks" -jar "%FALCON_HOME%\js\lib\mxmlc.jar" -js-output-type=FLEXJS -external-library-path="%FLEX_HOME%\js\libs\js.swc" -external-library-path+="%FLEX_HOME%\js\libs\jquery.swc" %*

add a batch file for jquery

add a batch file for jquery


cls
@echo This is only a placeholder file; all Windows 7/8/8.1 telemetry purging code is directly integrated into the main Tron script
pause

Create purge_windows_7-8-81_telemetry.bat


C:\Python27\Scripts\aws glacier initiate-job --account-id - ^
    --vault-name demschooltools-backups ^
    --job-parameters "{\"Type\": \"inventory-retrieval\"}"

rem request an archive
rem C:\Python27\Scripts\aws glacier initiate-job --account-id - ^
rem     --vault-name demschooltools-backups ^
rem     --job-parameters file://args.json

rem put this in a file to request an archive
rem {
rem      "Type": "archive-retrieval",
rem      "ArchiveId": "...",
rem      "Description": "6/14"
rem }

rem get finished archive retrieval or inventory
rem C:\Python27\Scripts\aws glacier get-job-output --account-id - ^
rem     --vault-name demschooltools-backups ^
rem     --job-id Ip0zLTco2QAzzxlVZSVxJaCEHDmw8ozVwR_iFKE3xkaN79CXDSZ8gCihliK_N25IhsEN2U2QLzj1Bo_ttzxze1rv_voR ^
rem     june_14.zip

rem show jobs that are in progress
rem C:\Python27\Scripts\aws glacier list-jobs ^
rem     --account-id - --vault-name demschooltools-backups

Add sample commands for using Glacier

Add sample commands for using Glacier


@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script with Functions Package restore
:: Version: 1.0.6
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Installing npm packages

FOR /F %%d in ('DIR /a:d /B') DO (
    cd %%d

    IF EXIST "package.json" (
        Echo Installing packages for %%d
        call npm install
    )
)

:: NuGet package restore
echo "Restoring function packages"

FOR /F %%d in ('DIR "Project.json" /S /B') DO (
  call nuget restore %%d -PackagesDirectory %home%\data\Functions\packages\nuget
)

echo Handling Basic Web Site deployment.

:: KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd;Project.json"
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

Add deploy.cmd for function auto deployment


@if "%_echo%" neq "on" echo off
rem
rem This file invokes cmake and generates the build system for windows.

set argC=0
for %%x in (%*) do Set /A argC+=1

if NOT %argC%==3 GOTO :USAGE
if %1=="/?" GOTO :USAGE

setlocal
set __sourceDir=%~dp0
set __ExtraCmakeParams=

if "%__VSVersion%" == "vs2019" (
  :: CMAKE 3.14 or later is required to use VS2019
  set __VSString=16 2019
) else (
  :: VS 2017 is the minimum supported toolset
  set __VSString=15 2017
)

:: x86 is the default arch selected by cmake.
if /i "%3" == "x64"     (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%3" == "arm"     (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%3" == "arm64"   (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%3" == "wasm"    (set __sourceDir=%~dp0..\Unix && goto DoGen)

if defined CMakePath goto DoGen

:: Eval the output from probe-win1.ps1
pushd "%__sourceDir%"
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\probe-win.ps1"') do %%a
popd

:DoGen

if "%3" == "wasm" (
    emcmake cmake "-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1" "-DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/Emscripten.cmake" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" -G "NMake Makefiles" %__sourceDir%
) else (
    "%CMakePath%" %__SDKVersion% "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" -G "Visual Studio %__VSString%" -B. -H%1 %__ExtraCmakeParams%
)
endlocal
GOTO :DONE

:USAGE
  echo "Usage..."
  echo "gen-buildsys-win.bat <path to top level CMakeLists.txt> <VSVersion> <Target Architecture>"
  echo "Specify the path to the top level CMake file"
  echo "Specify the VSVersion to be used - VS2017"
  echo "Specify the Target Architecture - AnyCPU, x86, x64, ARM, or ARM64."
  EXIT /B 1

:DONE
  EXIT /B 0

@if "%_echo%" neq "on" echo off
rem
rem This file invokes cmake and generates the build system for windows.

set argC=0
for %%x in (%*) do Set /A argC+=1

if NOT %argC%==3 GOTO :USAGE
if %1=="/?" GOTO :USAGE

setlocal
set __sourceDir=%~dp0
set __ExtraCmakeParams=

if "%__VSVersion%" == "vs2019" (
  :: CMAKE 3.14 or later is required to use VS2019
  set __VSString=16 2019
) else (
  :: VS 2017 is the minimum supported toolset
  set __VSString=15 2017
)

if /i "%3" == "x64"     (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%3" == "x86"     (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
if /i "%3" == "arm"     (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%3" == "arm64"   (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%3" == "wasm"    (set __sourceDir=%~dp0..\Unix && goto DoGen)

if defined CMakePath goto DoGen

:: Eval the output from probe-win1.ps1
pushd "%__sourceDir%"
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\probe-win.ps1"') do %%a
popd

:DoGen

if "%3" == "wasm" (
    emcmake cmake "-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1" "-DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/Emscripten.cmake" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" -G "NMake Makefiles" %__sourceDir%
) else (
    "%CMakePath%" %__SDKVersion% "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" -G "Visual Studio %__VSString%" -B. -H%1 %__ExtraCmakeParams%
)
endlocal
GOTO :DONE

:USAGE
  echo "Usage..."
  echo "gen-buildsys-win.bat <path to top level CMakeLists.txt> <VSVersion> <Target Architecture>"
  echo "Specify the path to the top level CMake file"
  echo "Specify the VSVersion to be used - VS2017"
  echo "Specify the Target Architecture - AnyCPU, x86, x64, ARM, or ARM64."
  EXIT /B 1

:DONE
  EXIT /B 0

Fix native build for x86 (#35289)

Fix native build for x86 (#35289)


rmdir /s /q build include
mkdir include & xcopy ..\include include
swig -Iinclude -c++ -python tst.i
c:\python23\python setup.py clean build --compile=mingw32 install sdist bdist_wininst
rmdir /s /q build include

Build for Python 2.3

Build for Python 2.3


@ECHO OFF

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

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

ECHO [behave.userdata] > %USERINI%
ECHO cf_apiurl = api.run.pcfbeta.io >> %USERINI%
ECHO cf_org = STEELTOE >> %USERINI%
ECHO cf_username = %CF_USER% >> %USERINI%
ECHO cf_password = %CF_PASS% >> %USERINI%
ECHO output = C:\steeltoe-test >> %USERINI%

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

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

@ECHO OFF

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

SET PYTHON_HOME=C:\Python36
SET DOTNET_HOME=C:\Program Files\dotnet
SET JAVA_HOME=C:\opt\oracle-jdk-8
SET GIT_HOME=C:\Program Files\Git
SET MAVEN_HOME=C:\opt\apache-maven-3.3.9
SET TEST_OUT=C:\st\%~nx1

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

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

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

Use unique test out for each sample

Use unique test out for each sample


@echo off
setlocal enabledelayedexpansion

set sourcetreepath=SourceTree\SourceTree.exe
if exist "%programfiles%\Atlassian\%sourcetreepath%" (
    set sourcetreepath=%programfiles%\Atlassian\%sourcetreepath%
) else if exist "%programfiles(x86)%\Atlassian\%sourcetreepath%" (
    set "sourcetreepath=%programfiles(x86)%\Atlassian\%sourcetreepath%"
) else if exist "%localappdata%\%sourcetreepath%" (
    set sourcetreepath=%localappdata%\%sourcetreepath%
) else (
    echo [Error]: Could not find SourceTree.exe - is it installed? 1>&2
    goto :eof
)

REM Convert the first argument to a full path
set directory=%~f1
REM If the first argument is empty use the current directory
if "%directory%" == "" set directory=%CD%

REM If the first argument is not a directory (e.g. a file) remove the filename
if exist "%directory%\" (
    set directory=%directory%
) else (
    set directory=%~dp1
)

REM go to the target directory
pushd "%directory%"

REM get the root of the repository
for /f "delims=" %%i in ('git rev-parse --show-toplevel') do set directory=%%i
git rev-parse --show-toplevel 1> nul 2> nul

if %errorlevel% EQU 0 (
    start "" "%sourcetreepath%" -f "%directory:/=\%"
)

popd
endlocal

@echo off
setlocal enabledelayedexpansion

set sourcetreepath=SourceTree\SourceTree.exe
if exist "%programfiles%\Atlassian\%sourcetreepath%" (
    set sourcetreepath=%programfiles%\Atlassian\%sourcetreepath%
) else if exist "%programfiles(x86)%\Atlassian\%sourcetreepath%" (
    set "sourcetreepath=%programfiles(x86)%\Atlassian\%sourcetreepath%"
) else if exist "%localappdata%\%sourcetreepath%" (
    set sourcetreepath=%localappdata%\%sourcetreepath%
) else (
    echo [Error]: Could not find SourceTree.exe - is it installed? 1>&2
    goto :eof
)

REM Convert the first argument to a full path
set directory=%~f1
REM If the first argument is empty use the current directory
if "%directory%" == "" set directory=%CD%

REM If the first argument is not a directory (e.g. a file) remove the filename
if not exist "%directory%\*" (
    set directory=%~dp1
)

REM go to the target directory
pushd "%directory%"

REM get the root of the repository
for /f "delims=" %%i in ('git rev-parse --show-toplevel') do set directory=%%i
git rev-parse --show-toplevel 1> nul 2> nul

if %errorlevel% EQU 0 (
    start "" "%sourcetreepath%" -f "%directory:/=\%"
)

popd
endlocal

Check if argument is a directory with star suffix


:: Fix for https://github.com/jkriege2/JKQtPlotter/issues/35
set "CXXFLAGS=%CXXFLAGS:-GL=%"

mkdir build
cd build
cmake ^
    -G "Ninja" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DJKQtPlotter_BUILD_EXAMPLES=OFF ^
    -DJKQtPlotter_BUILD_STATIC_LIBS=OFF ^
    -DCMAKE_BUILD_TYPE=Release ^
    ..
if errorlevel 1 exit 1
ninja install -j%CPU_COUNT%
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%/doc/_Readme.txt
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%/doc/_LICENSE.txt
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%/doc/_XITS_LICENSE.txt
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%/doc/_XITS_README.md
if errorlevel 1 exit 1

:: Fix for https://github.com/jkriege2/JKQtPlotter/issues/35
set "CXXFLAGS=%CXXFLAGS:-GL=%"

mkdir build
cd build
cmake ^
    -G "Ninja" ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DJKQtPlotter_BUILD_EXAMPLES=OFF ^
    -DJKQtPlotter_BUILD_STATIC_LIBS=OFF ^
    -DCMAKE_BUILD_TYPE=Release ^
    ..
if errorlevel 1 exit 1
ninja install -j%CPU_COUNT%
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\doc\_Readme.txt
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\doc\_LICENSE.txt
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\doc\_XITS_LICENSE.txt
if errorlevel 1 exit 1
del %LIBRARY_PREFIX%\doc\_XITS_README.md
if errorlevel 1 exit 1

Change / to \

Change / to \


Create bootstrap.cmd

Create bootstrap.cmd


@echo off

call npm publish ./
echo.

del npm-debug.log
pause

Update npm-publish.bat

Update npm-publish.bat


@REM
@REM Copyright © Red Gate Software Ltd 2010-2021
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@REM you may not use this file except in compliance with the License.
@REM 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.
@REM

@Echo off

setlocal

@REM Set the current directory to the installation directory
call :getCurrentBatch INSTALLDIR1
set INSTALLDIR=%INSTALLDIR1%
set INSTALLDIR=%INSTALLDIR:~0,-10%

if exist "%INSTALLDIR%\jre\bin\java.exe" (
 set JAVA_CMD="%INSTALLDIR%\jre\bin\java.exe"
) else (
 @REM Use JAVA_HOME if it is set
 if "%JAVA_HOME%"=="" (
  set JAVA_CMD=java
 ) else (
  set JAVA_CMD="%JAVA_HOME%\bin\java.exe"
 )
)

if "%JAVA_ARGS%"=="" (
  set JAVA_ARGS=
)

@REM Determine Flyway edition to use
:loop
IF NOT [%1]==[] (
    IF [%1]==[-community] (
        SET FLYWAY_EDITION=community
        GOTO :loop-end
    )
    IF [%1]==[-pro] (
        SET FLYWAY_EDITION=enterprise
        GOTO :loop-end
    )
    IF [%1]==[-enterprise] (
        SET FLYWAY_EDITION=enterprise
        GOTO :loop-end
    )
    IF [%1]==[-teams] (
        SET FLYWAY_EDITION=enterprise
        GOTO :loop-end
    )
    SHIFT /1
    GOTO :loop
)
:loop-end
if "%FLYWAY_EDITION%"=="" (
  set FLYWAY_EDITION=community
)
if "%FLYWAY_EDITION%"=="pro" (
  set FLYWAY_EDITION=enterprise
)
if "%FLYWAY_EDITION%"=="teams" (
  set FLYWAY_EDITION=enterprise
)

@REM Validate the Flyway edition
set editionValid=false
for %%E in ("community" "pro" "enterprise" "teams" "community") do (
  if "%FLYWAY_EDITION%"==%%E (
    set editionValid=true
  )
)
if %editionValid%==false (
  @Echo on
  echo invalid edition "%FLYWAY_EDITION%"
  @Echo off
  EXIT /B 1
)

%JAVA_CMD% -Djava.library.path="%INSTALLDIR%\native" %JAVA_ARGS% -cp "%CLASSPATH%;%INSTALLDIR%\lib\*;%INSTALLDIR%\lib\%FLYWAY_EDITION%\*;%INSTALLDIR%\drivers\*" org.flywaydb.commandline.Main %*

@REM Exit using the same code returned from Java
EXIT /B %ERRORLEVEL%

:getCurrentBatch
    set "%~1=%~f0"
    goto :eof

@REM
@REM Copyright © Red Gate Software Ltd 2010-2021
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@REM you may not use this file except in compliance with the License.
@REM 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.
@REM

@Echo off

setlocal

@REM Set the current directory to the installation directory
set INSTALLDIR=%~dp0

if exist "%INSTALLDIR%\jre\bin\java.exe" (
 set JAVA_CMD="%INSTALLDIR%\jre\bin\java.exe"
) else (
 @REM Use JAVA_HOME if it is set
 if "%JAVA_HOME%"=="" (
  set JAVA_CMD=java
 ) else (
  set JAVA_CMD="%JAVA_HOME%\bin\java.exe"
 )
)

if "%JAVA_ARGS%"=="" (
  set JAVA_ARGS=
)

@REM Determine Flyway edition to use
:loop
IF NOT [%1]==[] (
    IF [%1]==[-community] (
        SET FLYWAY_EDITION=community
        GOTO :loop-end
    )
    IF [%1]==[-pro] (
        SET FLYWAY_EDITION=enterprise
        GOTO :loop-end
    )
    IF [%1]==[-enterprise] (
        SET FLYWAY_EDITION=enterprise
        GOTO :loop-end
    )
    IF [%1]==[-teams] (
        SET FLYWAY_EDITION=enterprise
        GOTO :loop-end
    )
    SHIFT /1
    GOTO :loop
)
:loop-end
if "%FLYWAY_EDITION%"=="" (
  set FLYWAY_EDITION=community
)
if "%FLYWAY_EDITION%"=="pro" (
  set FLYWAY_EDITION=enterprise
)
if "%FLYWAY_EDITION%"=="teams" (
  set FLYWAY_EDITION=enterprise
)

@REM Validate the Flyway edition
set editionValid=false
for %%E in ("community" "pro" "enterprise" "teams" "community") do (
  if "%FLYWAY_EDITION%"==%%E (
    set editionValid=true
  )
)
if %editionValid%==false (
  @Echo on
  echo invalid edition "%FLYWAY_EDITION%"
  @Echo off
  EXIT /B 1
)

%JAVA_CMD% -Djava.library.path="%INSTALLDIR%\native" %JAVA_ARGS% -cp "%CLASSPATH%;%INSTALLDIR%\lib\*;%INSTALLDIR%\lib\%FLYWAY_EDITION%\*;%INSTALLDIR%\drivers\*" org.flywaydb.commandline.Main %*

@REM Exit using the same code returned from Java
EXIT /B %ERRORLEVEL%

Make flyway.cmd more robust

Make flyway.cmd more robust


@echo off
if "%1" == ""   goto :usage
if "%2" == ""   goto :usage
goto :main

:usage
echo Usage: %~n0 [directory] [build]
echo.
echo Recursively replaces all occurrences of 4.0.XX-beta-YYYYY in
echo [directory]\*.config;*.csproj;*.nuspec with 4.0.XX-beta-[build]
goto :eof

:main
pushd %1 && git clean -f packages && call :replace %2 && call :cleanup && popd
goto :eof

:replace
for /r %%f in (*.config *.csproj *.nuspec) do (
   perl -i.tmp_spb -p -e "s/(4\.0\.[0-9]+-beta)-([0-9]+)/$1-%1/" %%f || goto :eof
)
goto :eof

:cleanup
del /s *.tmp_spb
goto :eof

Add script to bump all prerelease corefx package build numbers


@echo off
if exist src\tools\msvc\buildenv.bat call src\tools\msvc\buildenv.bat

SET BV=
for /F "tokens=4 usebackq" %%f in (`bison -V`) do if "!BV!"=="" SET BV=%%f
if "%BV%"=="" goto novarexp
if %BV% LSS 1.875 goto nobison
if %BV% EQU 2.1 goto nobison

if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\include\parser\parse.h
if "%1" == "src\backend\bootstrap\bootparse.y" call :generate %1 src\backend\bootstrap\bootparse.c src\backend\bootstrap\bootstrap_tokens.h
if "%1" == "src\pl\plpgsql\src\gram.y" call :generate %1 src\pl\plpgsql\src\pl_gram.c src\pl\plpgsql\src\pl.tab.h
if "%1" == "src\interfaces\ecpg\preproc\preproc.y" call :generate %1 src\interfaces\ecpg\preproc\preproc.c src\interfaces\ecpg\preproc\preproc.h
if "%1" == "contrib\cube\cubeparse.y" call :generate %1 contrib\cube\cubeparse.c contrib\cube\cubeparse.h
if "%1" == "contrib\seg\segparse.y" call :generate %1 contrib\seg\segparse.c contrib\seg\segparse.h

echo Unknown bison input: %1
exit 1

:generate
SET fn=%1
bison -d %fn%
if errorlevel 1 exit 1
copy /y %fn:~0,-2%.tab.c %2
if errorlevel 1 exit 1
copy /y %fn:~0,-2%.tab.h %3
if errorlevel 1 exit 1
del %fn:~0,-2%.tab.*
exit 0

:novarexp
echo pgbison must be called with cmd /V:ON /C pgbison to work!
exit 1

:nobison
echo WARNING! Bison install not found, or unsupported Bison version.
echo Attempting to build without.
exit 0

@echo off
if exist src\tools\msvc\buildenv.bat call src\tools\msvc\buildenv.bat

SET BV=
for /F "tokens=4 usebackq" %%f in (`bison -V`) do if "!BV!"=="" SET BV=%%f
if "%BV%"=="" goto novarexp
if %BV% LSS 1.875 goto nobison
if %BV% EQU 2.1 goto nobison

if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\include\parser\parse.h
if "%1" == "src\backend\bootstrap\bootparse.y" call :generate %1 src\backend\bootstrap\bootparse.c src\backend\bootstrap\bootstrap_tokens.h
if "%1" == "src\pl\plpgsql\src\gram.y" call :generate %1 src\pl\plpgsql\src\pl_gram.c src\pl\plpgsql\src\pl.tab.h
if "%1" == "src\interfaces\ecpg\preproc\preproc.y" call :generate %1 src\interfaces\ecpg\preproc\preproc.c src\interfaces\ecpg\preproc\preproc.h
if "%1" == "contrib\cube\cubeparse.y" call :generate %1 contrib\cube\cubeparse.c contrib\cube\cubeparse.h
if "%1" == "contrib\seg\segparse.y" call :generate %1 contrib\seg\segparse.c contrib\seg\segparse.h

echo Unknown bison input: %1
exit 1

:generate
SET fn=%1
SET cf=%2
bison.exe -d %fn% -o %cf%
if errorlevel 1 exit 1
SET hf=%cf:~0,-2%.h
if not "%hf%"=="%3" (
        copy /y %hf% %3
        if errorlevel 1 exit 1
        del %hf%
)
exit 0

:novarexp
echo pgbison must be called with cmd /V:ON /C pgbison to work!
exit 1

:nobison
echo WARNING! Bison install not found, or unsupported Bison version.
echo Attempting to build without.
exit 0

Fix path problem in MSVC bison wrapper. per Joachim Wieland.


@ECHO OFF
Setlocal EnableDelayedExpansion

CALL __Global.cmd

ECHO *** Go Build ***
ECHO Build compiles packages and dependencies with race condition detector
ECHO.

FOR /F "tokens=*" %%A IN (Packages.txt) DO (
SET PACKAGE=%%A

ECHO Building: !PACKAGE!
cd "%GOPATH%\src\!PACKAGE!"
go build -v -race %LDFLAGS% !PACKAGE!
ECHO.

IF !ERRORLEVEL! NEQ 0 PAUSE

)

@ECHO OFF
Setlocal EnableDelayedExpansion

CALL __Global.cmd

ECHO *** Go Build ***
ECHO Build compiles packages and dependencies with race condition detector
ECHO.

FOR /F "tokens=*" %%A IN (Packages.txt) DO (
SET PACKAGE=%%A

ECHO Building: !PACKAGE!
cd "%GOPATH%\src\!PACKAGE!"
DEL /Q /F *.syso
go build -v -race %LDFLAGS% !PACKAGE!
ECHO.

IF !ERRORLEVEL! NEQ 0 PAUSE

)

Delete syso file before building with race detector

It will throw an error otherwise


@ECHO OFF
IF NOT DEFINED PROJECT_ROOT (
	ECHO "PROJECT_ROOT not defined, please setup your environment"
	GOTO :eof
)
PUSHD "%PROJECT_ROOT%"

IF EXIST "%PROJECT_ROOT%\tmp\.m-clears-screen" CLS

IF EXIST Makefile (
	m_make %*
) ELSE (
	IF EXIST build.gradle (
		m_gradle %*
	) ELSE (
		ECHO Don't know how to build this kind of project.
		GOTO :fixup
	)
)

:fixup
POPD

@ECHO OFF
IF NOT DEFINED PROJECT_ROOT (
	ECHO "PROJECT_ROOT not defined, please setup your environment"
	GOTO :eof
)
PUSHD "%PROJECT_ROOT%"

IF EXIST "%PROJECT_ROOT%\tmp\.m-clears-screen" CLS

IF EXIST Makefile (
	CALL m_make %*
) ELSE (
	IF EXIST build.gradle (
		CALL m_gradle %*
	) ELSE (
		ECHO Don't know how to build this kind of project.
		GOTO :fixup
	)
)

:fixup
POPD

Fix Windows m.cmd never popd'ing back.

Fix Windows m.cmd never popd'ing back.


@echo off

SETLOCAL
rem only if we are running from a checkout
IF EXIST "%~dp0\.git" (
  rem verify that we have 7zip in the path
  7z.exe --help > nul
  IF errorlevel 1 (
    REM For some reason, without quotes this line causes an error
    echo "Please install 7z.exe (7-Zip) and put it into your PATH"
    exit /b 1
  )

  rem if dev_bundle is not present, get it
  IF NOT EXIST "%~dp0\dev_bundle" (
    REM need `< con` so that we can run this file from Node
    REM (See http://stackoverflow.com/questions/9155289/calling-powershell-from-nodejs)
    PowerShell.exe -executionpolicy ByPass -file "%~dp0\scripts\windows\download-dev-bundle.ps1" < con
  )

  rem if dev_bundle is the wrong version, remove it and get a new one
  PowerShell.exe -executionpolicy ByPass -file "%~dp0\scripts\windows\check-dev-bundle.ps1" < con

  IF errorlevel 1 (
    rmdir /s /q "%~dp0\dev_bundle"
    IF EXIST "%~dp0\dev_bundle" (
      echo Couldn't delete old dependency kit. Please try again.
      exit /b 1
    )
    PowerShell.exe -executionpolicy ByPass -file "%~dp0\scripts\windows\download-dev-bundle.ps1" < con
  )

  rem Only set this when we're in a checkout. When running from a release,
  rem this is correctly set in the top-level `meteor.bat` file
  SET METEOR_INSTALLATION=%~dp0
)

SET NODE_PATH=%~dp0\dev_bundle\lib\node_modules
SET BABEL_CACHE_DIR=%~dp0\.babel-cache

"%~dp0\dev_bundle\bin\node.exe" "%~dp0\tools\index.js" %*
ENDLOCAL

EXIT /b %ERRORLEVEL%

@echo off

SETLOCAL
rem only if we are running from a checkout
IF EXIST "%~dp0\.git" (
  rem verify that we have 7zip in the path
  7z.exe --help > nul
  IF errorlevel 1 (
    REM For some reason, without quotes this line causes an error
    echo "Please install 7z.exe (7-Zip) and put it into your PATH"
    exit /b 1
  )

  rem if dev_bundle is not present, get it
  IF NOT EXIST "%~dp0\dev_bundle" (
    REM need `< con` so that we can run this file from Node
    REM (See http://stackoverflow.com/questions/9155289/calling-powershell-from-nodejs)
    PowerShell.exe -executionpolicy ByPass -file "%~dp0\scripts\windows\download-dev-bundle.ps1" < con
  )

  rem if dev_bundle is the wrong version, remove it and get a new one
  PowerShell.exe -executionpolicy ByPass -file "%~dp0\scripts\windows\check-dev-bundle.ps1" < con

  IF errorlevel 1 (
    rmdir /s /q "%~dp0\dev_bundle"
    IF EXIST "%~dp0\dev_bundle" (
      echo Couldn't delete old dependency kit. Please try again.
      exit /b 1
    )
    PowerShell.exe -executionpolicy ByPass -file "%~dp0\scripts\windows\download-dev-bundle.ps1" < con
  )

  rem Only set this when we're in a checkout. When running from a release,
  rem this is correctly set in the top-level `meteor.bat` file
  SET METEOR_INSTALLATION=%~dp0
)

SET NODE_PATH=%~dp0\dev_bundle\lib\node_modules
SET BABEL_CACHE_DIR=%~dp0\.babel-cache

"%~dp0\dev_bundle\bin\node.exe" %TOOL_NODE_FLAGS% "%~dp0\tools\index.js" %*
ENDLOCAL

EXIT /b %ERRORLEVEL%

Add TOOL_NODE_FLAGS support for Windows in the same way as Unix. (#8517)

In Unix we support adding `TOOL_NODE_FLAGS` when debugging the Meteor
tool itself, however Windows did not currently support it.  This should
add that support.  As this is a .bat file, I have every reason to
believe that this syntax should work on older versions of Windows as the
syntax of .bat files hasn't changed much.

Helps with meteor/meteor#8513.


### test_app.bat - 201x - Fabien Desert ###
version = "1.2.0"
build_hour = "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

### test_app.bat - 201x - Fabien Desert ###
version= "1.2.0"
build_hour= "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

update minor master version

update minor master version


@echo off

:: This script will create a packaged version of the app in firmware_flasher in your home folder.
:: After executing this script, use NSIS to create an installer from the firmware_flasher.win32.nsi file located there.
:: You may need to run npm install electron-packager --global once before this will work correctly.

set PLATFORM=win32
set ARCH=ia32
set OUTPUT_DIR=%userprofile%\firmware_flasher
set PACKAGE_DIR="%OUTPUT_DIR%\QMK Firmware Flasher-%PLATFORM%-%ARCH%"

call electron-packager . --platform=%PLATFORM% --arch=%ARCH% --out %OUTPUT_DIR% --overwrite

copy firmware_flasher.win32.nsi %PACKAGE_DIR%

Add script to build a Windows package on Windows


@REM create resource group
az group create --name k8-lab --location canadacentral

@REM create aci
az container create --name mycontainer --image tutum/hello-world --resource-group myResourceGroup --ip-address public --port 80

@REM show details and public ip
az container show --name mycontainer --resource-group k8-lab

@REM show logs
@REM az container logs --name mycontainer --resource-group myResourceGroup

@REM delete everything
@REM az container delete --name mycontainer --resource-group myResourceGroup
@REM az group delete -n myResourceGroup --yes

@REM create resource group
az group create --name myResourceGroup --location westeurope

@REM create aci
az container create --name mycontainer --image tutum/hello-world --resource-group myResourceGroup --ip-address public --port 80

@REM show details and public ip
az container show --name mycontainer --resource-group myResourceGroup

@REM show logs
@REM az container logs --name mycontainer --resource-group myResourceGroup

@REM delete everything
@REM az container delete --name mycontainer --resource-group myResourceGroup
@REM az group delete -n myResourceGroup --yes

Update aci.cmd

Update aci.cmd


@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
REM XXX @"ruby.exe" "ChefExtensionHandler\chef-client" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*

fix review comment, its only winnt.

fix review comment, its only winnt.


XCopy /S /C output "%USERPROFILE%\Google Drive\DujingAcademy\ClassicBook"

Add release.bat

Add release.bat


@echo off

set BOOST_ROOT=D:/dev/boost_1_65_1
set BOOST_LIBRARYDIR=D:/dev/boost_1_65_1/lib/stage
set INCLUDE=%BOOST_ROOT%
set QL_DIR=%CD%\QuantLib
set QLEXT_DIR=%CD%\QuantLib-Ext
set BUILD_TYPE=Debug
set ADDRESS_MODEL=Win64

cd QuantLib

if exist build (
  rem build folder already exists.
) else (
  mkdir build
)

if %ADDRESS_MODEL%==Win64 (
  set PLATFORM=x64
) else (
  set PLATFORM=Win32
)

cd build

if %ADDRESS_MODEL%==Win64 (
  cmake -G "Visual Studio 14 2015 %ADDRESS_MODEL%" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
) else (
  cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
)

msbuild Project.sln /target:QuantLib /m /p:Configuration=%BUILD_TYPE% /p:Platform=%PLATFORM%

cd ..\..\QuantLib-Ext

if exist build (
  rem build folder already exists.
) else (
  mkdir build
)

cd build

if %ADDRESS_MODEL%==Win64 (
  cmake -G "Visual Studio 14 2015 %ADDRESS_MODEL%" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
) else (
  cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
)

msbuild QuantLibExt.sln /target:QuantLibExt /m /p:Configuration=%BUILD_TYPE% /p:Platform=%PLATFORM%

cd ..\..\QuantLib-SWIG\Python

python setup.py wrap
python setup.py build
python setup.py bdist_wheel
python setup.py install

cd ..\..

@echo on

@echo off

set BOOST_ROOT=D:/dev/boost_1_64_0
set BOOST_LIBRARYDIR=D:/dev/boost_1_64_0/lib/stage
set INCLUDE=%BOOST_ROOT%
set QL_DIR=%CD%\QuantLib
set QLEXT_DIR=%CD%\QuantLib-Ext
set BUILD_TYPE=Debug
set ADDRESS_MODEL=Win64

cd QuantLib

if exist build (
  rem build folder already exists.
) else (
  mkdir build
)

if %ADDRESS_MODEL%==Win64 (
  set PLATFORM=x64
) else (
  set PLATFORM=Win32
)

cd build

if %ADDRESS_MODEL%==Win64 (
  cmake -G "Visual Studio 14 2015 %ADDRESS_MODEL%" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
) else (
  cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
)

msbuild Project.sln /target:QuantLib_Static /m /p:Configuration=%BUILD_TYPE% /p:Platform=%PLATFORM%

cd ..\..\QuantLib-Ext

if exist build (
  rem build folder already exists.
) else (
  mkdir build
)

cd build

if %ADDRESS_MODEL%==Win64 (
  cmake -G "Visual Studio 14 2015 %ADDRESS_MODEL%" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
) else (
  cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..
)

msbuild QuantLibExt.sln /target:QuantLibExt /m /p:Configuration=%BUILD_TYPE% /p:Platform=%PLATFORM%

cd ..\..\QuantLib-SWIG\Python

python setup.py wrap
python setup.py build
python setup.py bdist_wheel
python setup.py install

cd ..\..

@echo on

make consistent with QuantLib setting

make consistent with QuantLib setting


@echo off
setlocal enabledelayedexpansion
if "%SPARK_HOME%" == "" goto :sparkhomeerror
if "%JAVA_HOME%" == "" goto :javahomeerror
if "%SPARKCLR_HOME%" == "" goto :sparkclrhomeerror

if "%SPARK_CONF_DIR%" == "" (
	SET SPARK_CONF_DIR=%SPARK_HOME%\conf
)

call %SPARK_HOME%\bin\load-spark-env.cmd

rem Test that an argument was given
if "x%1"=="x" (
  goto :usage
)

set ASSEMBLY_DIR=%SPARK_HOME%\lib

for %%d in (%ASSEMBLY_DIR%\spark-assembly*hadoop*.jar) do (
  set SPARK_ASSEMBLY_JAR=%%d
)
if "%SPARK_ASSEMBLY_JAR%"=="0" (
  echo Failed to find Spark assembly JAR.
  exit /b 1
)

set SPARKCLR_JAR=csharp-spark-1.4.1-SNAPSHOT.jar
set SPARKCLR_CLASSPATH=%SPARKCLR_HOME%\lib\%SPARKCLR_JAR%
set LAUNCH_CLASSPATH=%SPARK_ASSEMBLY_JAR%;%SPARKCLR_CLASSPATH%
set SPARKCLR_SUBMIT_CLASS=org.apache.spark.deploy.csharp.SparkCLRSubmit
set SPARK_SUBMIT_CLASS=org.apache.spark.deploy.SparkSubmit
set JARS=%SPARKCLR_CLASSPATH%
if not "%SPARKCSV_JARS%" == "" (
	SET JARS=%JARS%,%SPARKCSV_JARS%
)
if not "%CSHARPSPARK_APP_JARS%" == "" (
	SET JARS=%JARS%,%CSHARPSPARK_APP_JARS%
)

if "%1"=="debug" (
  goto :debugmode
)

rem The launcher library prints the command to be executed in a single line suitable for being
rem executed by the batch interpreter. So read all the output of the launcher into a variable.
set LAUNCHER_OUTPUT=%temp%\spark-class-launcher-output-%RANDOM%.txt
%JAVA_HOME%\bin\java -cp %LAUNCH_CLASSPATH% org.apache.spark.launcher.Main %SPARK_SUBMIT_CLASS% --jars %JARS% --class %SPARKCLR_SUBMIT_CLASS% %* > %LAUNCHER_OUTPUT%

REM *********************************************************************************
REM ** TODO ** - replace the following sections in the script with a functionality that is implemented in scala
REM ** TODO ** - that will call org.apache.spark.launcher.Main, perform class name substituition, do classpath prefixing and generate the command to run
REM Following sections are simply a hack to leverage existing Spark artifacts - this will also help keeping CSharpSpark aligned with Spark's approach for arg parsing etc.
REM Following block replaces SparkSubmit with SparkCLRSubmit
REM *********************************************************************************
set LAUNCHER_OUTPUT_TEMP=sparkclr-submit-temp.txt
for /f "tokens=* delims= " %%A in ( '"type %LAUNCHER_OUTPUT%"') do (
SET originalstring=%%A
SET modifiedstring=!originalstring:%SPARK_SUBMIT_CLASS%=%SPARKCLR_SUBMIT_CLASS%!

echo !modifiedstring! >> %LAUNCHER_OUTPUT_TEMP%
)

del %LAUNCHER_OUTPUT%
REM *********************************************************************************

REM *********************************************************************************
REM Following block prefixes classpath with SPARKCLR_JAR
REM *********************************************************************************
set LAUNCHER_OUTPUT_TEMP2=sparkclr-submit-temp2.txt
set CLASSPATH_SUBSTRING=-cp "
set UPDATED_CLASSPATH_SUBSTRING=-cp "%SPARKCLR_CLASSPATH%;
for /f "tokens=* delims= " %%A in ( '"type %LAUNCHER_OUTPUT_TEMP%"') do (
SET originalstring2=%%A
SET modifiedstring2=!originalstring2:%CLASSPATH_SUBSTRING%=%UPDATED_CLASSPATH_SUBSTRING%!

echo !modifiedstring2! >> %LAUNCHER_OUTPUT_TEMP2%
)

del %LAUNCHER_OUTPUT_TEMP%
REM *********************************************************************************

for /f "tokens=*" %%i in (%LAUNCHER_OUTPUT_TEMP2%) do (
  set SPARK_CMD=%%i
)

del %LAUNCHER_OUTPUT_TEMP2%
REM launches the Spark job with SparkCLRSubmit as the Main class
echo Command to run %SPARK_CMD%
%SPARK_CMD%

goto :eof

:debugmode
%JAVA_HOME%\bin\java -cp %LAUNCH_CLASSPATH% org.apache.spark.deploy.csharp.CSharpRunner debug
goto :eof

:sparkhomeerror
	@echo Error - SPARK_HOME environment variable is not set
	@echo Note that SPARK_HOME environment variable should not have trailing \
	goto :eof

:javahomeerror
	@echo Error - JAVA_HOME environment variable is not set
	@echo Note that JAVA_HOME environment variable should not have trailing \
	goto :eof

:sparkclrhomeerror
	@echo Error - SPARKCLR_HOME environment variable is not set
	@echo SPARKCLR_HOME need to be set to the folder path for csharp-spark*.jar
	@echo Note that SPARKCLR_HOME environment variable should not have trailing \
	goto :eof

:usage
	@echo Error - usage error.
	@echo Correct usage is as follows
	@echo sparkclr-submit.cmd [--verbose] [--master local] [--name testapp] d:\SparkCLRHome\lib\spark-clr-1.4.1-SNAPSHOT.jar c:\sparkclrapp\driver\csdriver.exe arg1 arg2 arg3

@echo off
setlocal enabledelayedexpansion
if "%SPARK_HOME%" == "" goto :sparkhomeerror
if "%JAVA_HOME%" == "" goto :javahomeerror
if "%SPARKCLR_HOME%" == "" goto :sparkclrhomeerror

if "%SPARK_CONF_DIR%" == "" (
	SET SPARK_CONF_DIR=%SPARK_HOME%\conf
)

call %SPARK_HOME%\bin\load-spark-env.cmd

rem Test that an argument was given
if "x%1"=="x" (
  goto :usage
)

set ASSEMBLY_DIR=%SPARK_HOME%\lib

for %%d in (%ASSEMBLY_DIR%\spark-assembly*hadoop*.jar) do (
  set SPARK_ASSEMBLY_JAR=%%d
)
if "%SPARK_ASSEMBLY_JAR%"=="0" (
  echo Failed to find Spark assembly JAR.
  exit /b 1
)

set SPARKCLR_JAR=spark-clr-1.4.1-SNAPSHOT.jar
set SPARKCLR_CLASSPATH=%SPARKCLR_HOME%\lib\%SPARKCLR_JAR%
set LAUNCH_CLASSPATH=%SPARK_ASSEMBLY_JAR%;%SPARKCLR_CLASSPATH%
set SPARKCLR_SUBMIT_CLASS=org.apache.spark.deploy.csharp.SparkCLRSubmit
set SPARK_SUBMIT_CLASS=org.apache.spark.deploy.SparkSubmit
set JARS=%SPARKCLR_CLASSPATH%
if not "%SPARKCSV_JARS%" == "" (
	SET JARS=%JARS%,%SPARKCSV_JARS%
)
if not "%CSHARPSPARK_APP_JARS%" == "" (
	SET JARS=%JARS%,%CSHARPSPARK_APP_JARS%
)

if "%1"=="debug" (
  goto :debugmode
)

rem The launcher library prints the command to be executed in a single line suitable for being
rem executed by the batch interpreter. So read all the output of the launcher into a variable.
set LAUNCHER_OUTPUT=%temp%\spark-class-launcher-output-%RANDOM%.txt
%JAVA_HOME%\bin\java -cp %LAUNCH_CLASSPATH% org.apache.spark.launcher.Main %SPARK_SUBMIT_CLASS% --jars %JARS% --class %SPARKCLR_SUBMIT_CLASS% %* > %LAUNCHER_OUTPUT%

REM *********************************************************************************
REM ** TODO ** - replace the following sections in the script with a functionality that is implemented in scala
REM ** TODO ** - that will call org.apache.spark.launcher.Main, perform class name substituition, do classpath prefixing and generate the command to run
REM Following sections are simply a hack to leverage existing Spark artifacts - this will also help keeping CSharpSpark aligned with Spark's approach for arg parsing etc.
REM Following block replaces SparkSubmit with SparkCLRSubmit
REM *********************************************************************************
set LAUNCHER_OUTPUT_TEMP=sparkclr-submit-temp.txt
for /f "tokens=* delims= " %%A in ( '"type %LAUNCHER_OUTPUT%"') do (
SET originalstring=%%A
SET modifiedstring=!originalstring:%SPARK_SUBMIT_CLASS%=%SPARKCLR_SUBMIT_CLASS%!

echo !modifiedstring! >> %LAUNCHER_OUTPUT_TEMP%
)

del %LAUNCHER_OUTPUT%
REM *********************************************************************************

REM *********************************************************************************
REM Following block prefixes classpath with SPARKCLR_JAR
REM *********************************************************************************
set LAUNCHER_OUTPUT_TEMP2=sparkclr-submit-temp2.txt
set CLASSPATH_SUBSTRING=-cp "
set UPDATED_CLASSPATH_SUBSTRING=-cp "%SPARKCLR_CLASSPATH%;
for /f "tokens=* delims= " %%A in ( '"type %LAUNCHER_OUTPUT_TEMP%"') do (
SET originalstring2=%%A
SET modifiedstring2=!originalstring2:%CLASSPATH_SUBSTRING%=%UPDATED_CLASSPATH_SUBSTRING%!

echo !modifiedstring2! >> %LAUNCHER_OUTPUT_TEMP2%
)

del %LAUNCHER_OUTPUT_TEMP%
REM *********************************************************************************

for /f "tokens=*" %%i in (%LAUNCHER_OUTPUT_TEMP2%) do (
  set SPARK_CMD=%%i
)

del %LAUNCHER_OUTPUT_TEMP2%
REM launches the Spark job with SparkCLRSubmit as the Main class
echo Command to run %SPARK_CMD%
%SPARK_CMD%

goto :eof

:debugmode
%JAVA_HOME%\bin\java -cp %LAUNCH_CLASSPATH% org.apache.spark.deploy.csharp.CSharpRunner debug
goto :eof

:sparkhomeerror
	@echo Error - SPARK_HOME environment variable is not set
	@echo Note that SPARK_HOME environment variable should not have trailing \
	goto :eof

:javahomeerror
	@echo Error - JAVA_HOME environment variable is not set
	@echo Note that JAVA_HOME environment variable should not have trailing \
	goto :eof

:sparkclrhomeerror
	@echo Error - SPARKCLR_HOME environment variable is not set
	@echo SPARKCLR_HOME need to be set to the folder path for csharp-spark*.jar
	@echo Note that SPARKCLR_HOME environment variable should not have trailing \
	goto :eof

:usage
	@echo Error - usage error.
	@echo Correct usage is as follows
	@echo sparkclr-submit.cmd [--verbose] [--master local] [--name testapp] d:\SparkCLRHome\lib\spark-clr-1.4.1-SNAPSHOT.jar c:\sparkclrapp\driver\csdriver.exe arg1 arg2 arg3

Fix the bug that wrong SPARKCLR_JAR is specified in sparkclr-submit.cmd


:: Force-updates AutoRain.exe and rain.kv with the latest versions available on github
powershell -noprofile -command ^
Invoke-WebRequest -OutFile "rain.kv" -URI https://raw.githubusercontent.com/EdvardasDlugauskas/Auto-Rain/master/rain.kv;^
Invoke-WebRequest -OutFile "AutoRain.exe" -URI https://github.com/EdvardasDlugauskas/Auto-Rain/raw/master/dist/AutoRain.exe;^
Invoke-WebRequest -OutFile "force_update.bat" -URI https://github.com/EdvardasDlugauskas/Auto-Rain/raw/master/dist/force_update.bat;

:: Force-updates AutoRain.exe and rain.kv with the latest versions available on github
powershell -noprofile -command
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;^
Invoke-WebRequest -OutFile "rain.kv" -URI https://raw.githubusercontent.com/EdvardasDlugauskas/Auto-Rain/master/rain.kv;
Invoke-WebRequest -OutFile "AutoRain.exe" -URI https://github.com/EdvardasDlugauskas/Auto-Rain/raw/master/dist/AutoRain.exe;
Invoke-WebRequest -OutFile "force_update.bat" -URI https://github.com/EdvardasDlugauskas/Auto-Rain/raw/master/dist/force_update.bat;

Fix force_update.bat

Fix force_update.bat


@echo off
setlocal EnableExtensions EnableDelayedExpansion

rem ==========================================
rem            PARSE ARGUMENTS
rem ==========================================

set CSCOPE_EXE=cscope
set CSCOPE_ARGS=
set DB_FILE=cscope.out
set FILE_LIST_CMD=
set LOG_FILE=

:ParseArgs
if [%1]==[] goto :DoneParseArgs
if [%1]==[-e] (
    set CSCOPE_EXE=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-f] (
    set DB_FILE=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-p] (
    set PROJ_ROOT=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-L] (
    set FILE_LIST_CMD=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-l] (
    set LOG_FILE=%~2
    shift
    goto :LoopParseArgs
)
echo Invalid Argument: %1
goto :Usage

:LoopParseArgs
shift
goto :ParseArgs

:DoneParseArgs

rem ==========================================
rem             GENERATE DATABASE
rem ==========================================

if [%LOG_FILE%]==[] set LOG_FILE=CON

echo Locking db file > %LOG_FILE%
echo locked > "%DB_FILE%.lock"

echo Running cscope >> %LOG_FILE%
if NOT ["%FILE_LIST_CMD%"]==[""] (
    if ["%PROJECT_ROOT%"]==["."] (
        call %FILE_LIST_CMD% > %DB_FILE%.files
    ) else (
        rem Potentially useful:
        rem http://stackoverflow.com/questions/9749071/cmd-iterate-stdin-piped-from-another-command
        %FILE_LIST_CMD% | for /F "usebackq delims=" %%F in (`findstr "."`) do @echo %PROJECT_ROOT%\%%F > %DB_FILE%.files
    )
    set CSCOPE_ARGS=%CSCOPE_ARGS% -i %TAGS_FILE%.files
) ELSE (
    set CSCOPE_ARGS=%CSCOPE_ARGS% -R
)
"%CSCOPE_EXE%" %CSCOPE_ARGS% -b -k -f "%DB_FILE%"
if ERRORLEVEL 1 (
    echo ERROR: Cscope executable returned non-zero code. >> %LOG_FILE%
)

echo Unlocking db file >> %LOG_FILE%
del /F "%DB_FILE%.files" "%DB_FILE%.lock"
if ERRORLEVEL 1 (
    echo ERROR: Unable to remove file lock. >> %LOG_FILE%
)

echo Done. >> %LOG_FILE%

goto :EOF

rem ==========================================
rem                 USAGE
rem ==========================================

:Usage
echo Usage:
echo    %~n0 ^<options^>
echo.
echo    -e [exe=cscope]:     The cscope executable to run
echo    -f [file=scope.out]: The path to the database file to create
echo    -p [dir=]:           The path to the project root
echo    -L [cmd=]:           The file list command to run
echo    -l [log=]:           The log file to output to
echo.

@echo off
setlocal EnableExtensions EnableDelayedExpansion

rem ==========================================
rem            PARSE ARGUMENTS
rem ==========================================

set CSCOPE_EXE=cscope
set CSCOPE_ARGS=
set DB_FILE=cscope.out
set FILE_LIST_CMD=
set LOG_FILE=

:ParseArgs
if [%1]==[] goto :DoneParseArgs
if [%1]==[-e] (
    set CSCOPE_EXE=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-f] (
    set DB_FILE=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-p] (
    set PROJ_ROOT=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-L] (
    set FILE_LIST_CMD=%~2
    shift
    goto :LoopParseArgs
)
if [%1]==[-l] (
    set LOG_FILE=%~2
    shift
    goto :LoopParseArgs
)
echo Invalid Argument: %1
goto :Usage

:LoopParseArgs
shift
goto :ParseArgs

:DoneParseArgs

rem ==========================================
rem             GENERATE DATABASE
rem ==========================================

if [%LOG_FILE%]==[] set LOG_FILE=CON

echo Locking db file > %LOG_FILE%
echo locked > "%DB_FILE%.lock"

echo Running cscope >> %LOG_FILE%
if NOT ["%FILE_LIST_CMD%"]==[""] (
    if ["%PROJECT_ROOT%"]==["."] (
        call %FILE_LIST_CMD% > %DB_FILE%.files
    ) else (
        rem Potentially useful:
        rem http://stackoverflow.com/questions/9749071/cmd-iterate-stdin-piped-from-another-command
        for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo "%PROJECT_ROOT%\%%F">%DB_FILE%.files
    )
) ELSE (
    for /F "usebackq delims=" %%F in (`dir /S /B /A-D .`) do @echo "%%F">%DB_FILE%.files
)
set CSCOPE_ARGS=%CSCOPE_ARGS% -i %DB_FILE%.files
"%CSCOPE_EXE%" %CSCOPE_ARGS% -b -k -f "%DB_FILE%"
if ERRORLEVEL 1 (
    echo ERROR: Cscope executable returned non-zero code. >> %LOG_FILE%
)

echo Unlocking db file >> %LOG_FILE%
del /F "%DB_FILE%.files" "%DB_FILE%.lock"
if ERRORLEVEL 1 (
    echo ERROR: Unable to remove file lock. >> %LOG_FILE%
)

echo Done. >> %LOG_FILE%

goto :EOF

rem ==========================================
rem                 USAGE
rem ==========================================

:Usage
echo Usage:
echo    %~n0 ^<options^>
echo.
echo    -e [exe=cscope]:     The cscope executable to run
echo    -f [file=scope.out]: The path to the database file to create
echo    -p [dir=]:           The path to the project root
echo    -L [cmd=]:           The file list command to run
echo    -l [log=]:           The log file to output to
echo.

Fix file listing for cscope on Windows (#173)


@echo off
cd src
pip install -r requirements.txt
pause

@echo off
cd src
pip install -r requirements.txt
copy src\settings\local.py.example src\settings\local.py
pause

Add local.py to windows install

Add local.py to windows install


SETLOCAL

> wget.vbs (
echo.url = WScript.Arguments.Named^("url"^)
echo.path = WScript.Arguments.Named^("path"^)
echo.proxy = null
echo.Set objXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP"^)
echo.Set wshShell = CreateObject^( "WScript.Shell" ^)
echo.Set objUserVariables = wshShell.Environment^("USER"^)
echo.
echo.'http proxy is optional
echo.'attempt to read from HTTP_PROXY env var first
echo.On Error Resume Next
echo.
echo.If NOT ^(objUserVariables^("HTTP_PROXY"^) = ""^) Then
echo.proxy = objUserVariables^("HTTP_PROXY"^)
echo.
echo.'fall back to named arg
echo.ElseIf NOT ^(WScript.Arguments.Named^("proxy"^) = ""^) Then
echo.proxy = WScript.Arguments.Named^("proxy"^)
echo.End If
echo.
echo.If NOT isNull^(proxy^) Then
echo.'setProxy method is only available on ServerXMLHTTP 6.0+
echo.Set objXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP.6.0"^)
echo.objXMLHTTP.setProxy 2, proxy
echo.End If
echo.
echo.On Error Goto 0
echo.
echo.objXMLHTTP.open "GET", url, false
echo.objXMLHTTP.send^(^)
echo.If objXMLHTTP.Status = 200 Then
echo.Set objADOStream = CreateObject^("ADODB.Stream"^)
echo.objADOStream.Open
echo.objADOStream.Type = 1
echo.objADOStream.Write objXMLHTTP.ResponseBody
echo.objADOStream.Position = 0
echo.Set objFSO = Createobject^("Scripting.FileSystemObject"^)
echo.If objFSO.Fileexists^(path^) Then objFSO.DeleteFile path
echo.Set objFSO = Nothing
echo.objADOStream.SaveToFile path
echo.objADOStream.Close
echo.Set objADOStream = Nothing
echo.End if
echo.Set objXMLHTTP = Nothing
)

rem # XXX: uninstall any left over version, ignore errors
call msiexec /qb /x %TMP%\install.msi

rem # remove the chef package / clobber the files
rmdir /S /Q C:\opscode

rem # remove the old installer, if it exists, ignore errors
del /F /Q %TMP%\install.msi

rem # download the new chef installer
rem # right now we have one build, fake the platform resulution crap
cscript /nologo wget.vbs /url:"http://%OMNITRUCK_BASE_URL%/chef/download?p=windows&pv=2008r2&m=x86_64&v=%INSTALL_CHEF_VERSION%" /path:%TMP%\install.msi

call msiexec INSTALLLOCATION=C:\opscode /qb /i %TMP%\install.msi || GOTO :error

call C:\opscode\chef\bin\chef-client --version || GOTO :error

call msiexec /qb /x %TMP%\install.msi || GOTO :error

GOTO :EOF

:error

SET ERR_LEV=%errorlevel%

ECHO Failed with error level %ERR_LEV%

call msiexec /qb /x %TMP%\install.msi

EXIT /B %ERR_LEV%

ENDLOCAL

SETLOCAL

> wget.vbs (
echo.url = WScript.Arguments.Named^("url"^)
echo.path = WScript.Arguments.Named^("path"^)
echo.proxy = null
echo.Set objXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP"^)
echo.Set wshShell = CreateObject^( "WScript.Shell" ^)
echo.Set objUserVariables = wshShell.Environment^("USER"^)
echo.
echo.'http proxy is optional
echo.'attempt to read from HTTP_PROXY env var first
echo.On Error Resume Next
echo.
echo.If NOT ^(objUserVariables^("HTTP_PROXY"^) = ""^) Then
echo.proxy = objUserVariables^("HTTP_PROXY"^)
echo.
echo.'fall back to named arg
echo.ElseIf NOT ^(WScript.Arguments.Named^("proxy"^) = ""^) Then
echo.proxy = WScript.Arguments.Named^("proxy"^)
echo.End If
echo.
echo.If NOT isNull^(proxy^) Then
echo.'setProxy method is only available on ServerXMLHTTP 6.0+
echo.Set objXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP.6.0"^)
echo.objXMLHTTP.setProxy 2, proxy
echo.End If
echo.
echo.On Error Goto 0
echo.
echo.objXMLHTTP.open "GET", url, false
echo.objXMLHTTP.send^(^)
echo.If objXMLHTTP.Status = 200 Then
echo.Set objADOStream = CreateObject^("ADODB.Stream"^)
echo.objADOStream.Open
echo.objADOStream.Type = 1
echo.objADOStream.Write objXMLHTTP.ResponseBody
echo.objADOStream.Position = 0
echo.Set objFSO = Createobject^("Scripting.FileSystemObject"^)
echo.If objFSO.Fileexists^(path^) Then objFSO.DeleteFile path
echo.Set objFSO = Nothing
echo.objADOStream.SaveToFile path
echo.objADOStream.Close
echo.Set objADOStream = Nothing
echo.End if
echo.Set objXMLHTTP = Nothing
)

rem # XXX: uninstall any left over version, ignore errors
call msiexec /qb /x %TMP%\install.msi

rem # remove the chef package / clobber the files
rmdir /S /Q C:\opscode

rem # remove the old installer, if it exists, ignore errors
del /F /Q %TMP%\install.msi

rem # sleep until omnitruck has updated itself
powershell -command "start-sleep %SLEEP_TIME%"

rem # download the new chef installer
rem # right now we have one build, fake the platform resulution crap
cscript /nologo wget.vbs /url:"http://%OMNITRUCK_BASE_URL%/chef/download?p=windows&pv=2008r2&m=x86_64&v=%INSTALL_CHEF_VERSION%" /path:%TMP%\install.msi

call msiexec INSTALLLOCATION=C:\opscode /qb /i %TMP%\install.msi || GOTO :error

call C:\opscode\chef\bin\chef-client --version || GOTO :error

call msiexec /qb /x %TMP%\install.msi || GOTO :error

GOTO :EOF

:error

SET ERR_LEV=%errorlevel%

ECHO Failed with error level %ERR_LEV%

call msiexec /qb /x %TMP%\install.msi

EXIT /B %ERR_LEV%

ENDLOCAL

add sleep to install-test for windows

add sleep to install-test for windows

after releasing artifacts to preprod we need to sleep to wait for
the omnitruck cronjob to scrape s3 and offer the artifacts.  otherwise
the windows slaves always fail the first time through the release
pipeline.

using powershell because we seem to have that everywhere now.  this
whole stupid bat file now should be rewritten in powershell...


setlocal

if "%NUGET_KEY%"=="" SET NUGET_KEY=%1

echo "key: '%NUGET_KEY%'"

set BINROOT=%AGENT_BUILDDIRECTORY%\Release\NuGet
if not exist %BINROOT% echo "Error: '%BINROOT%' does not exist."&goto :eof

set NUGET=%BUILD_SOURCESDIRECTORY%\NuGet.exe
if not exist %NUGET% echo "Error: '%NUGET%' does not exist."&goto :eof

set NUGET_GALLERY=https://www.myget.org/F/applicationinsights/api/v2/package

for /r "%BINROOT%" %%P in (*.nupkg) do call :push %%P
goto :eof

:push
set PACKAGE=%1
if %PACKAGE:.symbols.=% == %PACKAGE% (
    %NUGET% push "%PACKAGE%" %NUGET_KEY% -source %NUGET_GALLERY%
)
goto :eof

endlocal

setlocal

if "%NUGET_KEY%"=="" SET NUGET_KEY=%1

echo "key: '%NUGET_KEY%'"

set BINROOT=%AGENT_BUILDDIRECTORY%\bin\Release\NuGet
if not exist %BINROOT% echo "Error: '%BINROOT%' does not exist."&goto :eof

set NUGET=%BUILD_SOURCESDIRECTORY%\NuGet.exe
if not exist %NUGET% echo "Error: '%NUGET%' does not exist."&goto :eof

set NUGET_GALLERY=https://www.myget.org/F/applicationinsights/api/v2/package

for /r "%BINROOT%" %%P in (*.nupkg) do call :push %%P
goto :eof

:push
set PACKAGE=%1
if %PACKAGE:.symbols.=% == %PACKAGE% (
    %NUGET% push "%PACKAGE%" %NUGET_KEY% -source %NUGET_GALLERY%
)
goto :eof

endlocal

Update nuget package path

Update nuget package path


echo off
set PATH=C:\Program Files\Git\mingw64_gcc\mingw64\bin;C:\Program Files\Git\bin;%PATH%
echo Posix on Windows
"C:\WINDOWS\system32\cmd.exe"

echo off
set PATH=C:\Program Files\Git\mingw64_gcc\mingw64\bin;C:\Program Files\Git\bin;%PATH%
echo Posix on Windows by www.owcsx.science
"C:\WINDOWS\system32\cmd.exe"

Update posix.bat

Update posix.bat


@setlocal enabledelayedexpansion

REM Parse Arguments.

set BuildConfiguration=Debug
: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
goto :Usage && exit /b 1
:DoneParsing

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

REM Build the compiler so we can self host it for the full build
src\.nuget\NuGet.exe restore src\Toolset.sln -packagesdirectory packages
msbuild /nologo /v:m /m src/Compilers/Core/VBCSCompiler/VBCSCompiler.csproj /p:Configuration=%BuildConfiguration%
msbuild /nologo /v:m /m src/Compilers/CSharp/csc2/csc2.csproj /p:Configuration=%BuildConfiguration%
msbuild /nologo /v:m /m src/Compilers/VisualBasic/vbc2/vbc2.csproj /p:Configuration=%BuildConfiguration%

mkdir Binaries\Bootstrap
move Binaries\%BuildConfiguration%\* Binaries\Bootstrap
msbuild /v:m /t:Clean src/Toolset.sln /p:Configuration=%BuildConfiguration%
taskkill /F /IM vbcscompiler.exe

msbuild /v:m /m /p:BootstrapBuildPath=%~dp0\Binaries\Bootstrap BuildAndTest.proj /p:CIBuild=true /p:Configuration=%BuildConfiguration%
if ERRORLEVEL 1 (
    taskkill /F /IM vbcscompiler.exe
    echo Build failed
    exit /b 1
)

REM Kill any instances of VBCSCompiler.exe to release locked files;
REM otherwise future CI runs may fail while trying to delete those files.
taskkill /F /IM vbcscompiler.exe

REM It is okay and expected for taskkill to fail (it's a cleanup routine).  Ensure
REM caller sees successful exit.
exit /b 0

:Usage
@echo Usage: cibuild.cmd [/debug^|/release]
@echo   /debug 	Perform debug build.  This is the default.
@echo   /release Perform release build
@goto :eof

@setlocal enabledelayedexpansion

REM Parse Arguments.

set BuildConfiguration=Debug
: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
goto :Usage && exit /b 1
:DoneParsing

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

REM Build the compiler so we can self host it for the full build
src\.nuget\NuGet.exe restore src\Toolset.sln -packagesdirectory packages
msbuild /nologo /v:m /m src/Compilers/Core/VBCSCompiler/VBCSCompiler.csproj /p:Configuration=%BuildConfiguration%
msbuild /nologo /v:m /m src/Compilers/CSharp/csc2/csc2.csproj /p:Configuration=%BuildConfiguration%
msbuild /nologo /v:m /m src/Compilers/VisualBasic/vbc2/vbc2.csproj /p:Configuration=%BuildConfiguration%

mkdir Binaries\Bootstrap
move Binaries\%BuildConfiguration%\* Binaries\Bootstrap
msbuild /v:m /t:Clean src/Toolset.sln /p:Configuration=%BuildConfiguration%
taskkill /F /IM vbcscompiler.exe

msbuild /v:m /m /p:BootstrapBuildPath=%~dp0\Binaries\Bootstrap BuildAndTest.proj /p:CIBuild=true /p:Configuration=%BuildConfiguration%
if ERRORLEVEL 1 (
    taskkill /F /IM vbcscompiler.exe
    echo Build failed
    exit /b 1
)

REM Kill any instances of VBCSCompiler.exe to release locked files;
REM otherwise future CI runs may fail while trying to delete those files.
taskkill /F /IM vbcscompiler.exe

REM It is okay and expected for taskkill to fail (it's a cleanup routine).  Ensure
REM caller sees successful exit.
exit /b 0

:Usage
@echo Usage: cibuild.cmd [/debug^|/release]
@echo   /debug 	Perform debug build.  This is the default.
@echo   /release Perform release build
@goto :eof

Remove spaces in section of if statement of cibuild

This was causing BuildConfiguration to become "Release " or "Debug " and thus the script failed later when copying bootstrap files


@echo off

setlocal enabledelayedexpansion
setlocal enableextensions

call "%~dp0elasticsearch-env.bat" || exit /b 1

set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x64.exe
set SERVICE_ID=elasticsearch-service-x64
set ARCH=64-bit

if EXIST "%EXECUTABLE%" goto okExe
echo elasticsearch-service-x64.exe was not found...
exit /B 1

:okExe
set ES_VERSION=${project.version}

if "%SERVICE_LOG_DIR%" == "" set SERVICE_LOG_DIR=%ES_HOME%\logs

if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
set SERVICE_ID=%1

:checkServiceCmd

if "%LOG_OPTS%" == "" set LOG_OPTS=--LogPath "%SERVICE_LOG_DIR%" --LogPrefix "%SERVICE_ID%" --StdError auto --StdOutput auto

if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == start goto doStart
if /i %SERVICE_CMD% == stop goto doStop
if /i %SERVICE_CMD% == manager goto doManagment
echo Unknown option "%SERVICE_CMD%"

:displayUsage
echo.
echo Usage: elasticsearch-service.bat install^|remove^|start^|stop^|manager [SERVICE_ID]
goto:eof

:doStart
"%EXECUTABLE%" //ES//%SERVICE_ID% %LOG_OPTS%
if not errorlevel 1 goto started
echo Failed starting '%SERVICE_ID%' service
goto:eof
:started
echo The service '%SERVICE_ID%' has been started
goto:eof

:doStop
"%EXECUTABLE%" //SS//%SERVICE_ID% %LOG_OPTS%
if not errorlevel 1 goto stopped
echo Failed stopping '%SERVICE_ID%' service
goto:eof
:stopped
echo The service '%SERVICE_ID%' has been stopped
goto:eof

:doManagment
set EXECUTABLE_MGR=%ES_HOME%\bin\elasticsearch-service-mgr.exe
"%EXECUTABLE_MGR%" //ES//%SERVICE_ID%
if not errorlevel 1 goto managed
echo Failed starting service manager for '%SERVICE_ID%'
goto:eof
:managed
echo Successfully started service manager for '%SERVICE_ID%'.
goto:eof

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

:doInstall
echo Installing service      :  "%SERVICE_ID%"
echo Using JAVA_HOME (%ARCH%):  "%JAVA_HOME%"

rem Check JVM server dll first
if exist "%JAVA_HOME%\jre\bin\server\jvm.dll" (
	set JVM_DLL=\jre\bin\server\jvm.dll
	goto foundJVM
)

rem Check 'server' JRE (JRE installed on Windows Server)
if exist "%JAVA_HOME%\bin\server\jvm.dll" (
	set JVM_DLL=\bin\server\jvm.dll
	goto foundJVM
) else (
  	echo JAVA_HOME points to an invalid Java installation (no jvm.dll found in "%JAVA_HOME%"^). Exiting...
  	goto:eof
)

:foundJVM
set ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options

if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;%

@setlocal
for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%" ^| findstr /b /v "\-server \-client"`) do set JVM_OPTIONS=!JVM_OPTIONS!%%a;
@endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS%%ES_JAVA_OPTS%

if "%ES_JAVA_OPTS:~-1%"==";" set ES_JAVA_OPTS=%ES_JAVA_OPTS:~0,-1%

@setlocal EnableDelayedExpansion
for %%a in ("%ES_JAVA_OPTS:;=","%") do (
  set var=%%a
  if "!var:~1,4!" == "-Xms" (
    if not "!JVM_MS!" == "" (
      echo duplicate min heap size settings found
      goto:eof
    )
    set XMS=!var:~5,-1!
    call:convertxm !XMS! JVM_MS
  )
  if "!var:~1,16!" == "-XX:MinHeapSize=" (
    if not "!JVM_MS!" == "" (
      echo duplicate min heap size settings found
      goto:eof
    )
    set XMS=!var:~17,-1!
    call:convertxm !XMS! JVM_MS
  )
  if "!var:~1,4!" == "-Xmx" (
    if not "!JVM_MX!" == "" (
      echo duplicate max heap size settings found
      goto:eof
    )
    set XMX=!var:~5,-1!
    call:convertxm !XMX! JVM_MX
  )
  if "!var:~1,16!" == "-XX:MaxHeapSize=" (
    if not "!JVM_MX!" == "" (
      echo duplicate max heap size settings found
      goto:eof
    )
    set XMX=!var:~17,-1!
    call:convertxm !XMX! JVM_MX
  )
  if "!var:~1,4!" == "-Xss" (
    if not "!JVM_SS!" == "" (
      echo duplicate thread stack size settings found
      exit 1
    )
    set XSS=!var:~5,-1!
    call:convertxk !XSS! JVM_SS
  )
  if "!var:~1,20!" == "-XX:ThreadStackSize=" (
    if not "!JVM_SS!" == "" (
      echo duplicate thread stack size settings found
      goto:eof
    )
    set XSS=!var:~21,-1!
    call:convertxk !XSS! JVM_SS
  )
)
@endlocal & set JVM_MS=%JVM_MS% & set JVM_MX=%JVM_MX% & set JVM_SS=%JVM_SS%

if "%JVM_MS%" == "" (
  echo minimum heap size not set; configure using -Xms via %ES_JVM_OPTIONS% or ES_JAVA_OPTS
  goto:eof
)
if "%JVM_MX%" == "" (
  echo maximum heap size not set; configure using -Xmx via %ES_JVM_OPTIONS% or ES_JAVA_OPTS
  goto:eof
)
if "%JVM_SS%" == "" (
  echo thread stack size not set; configure using -Xss via %ES_JVM_OPTIONS% or ES_JAVA_OPTS
  goto:eof
)

set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%"

if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0

if "%SERVICE_DISPLAY_NAME%" == "" set SERVICE_DISPLAY_NAME=Elasticsearch %ES_VERSION% (%SERVICE_ID%)
if "%SERVICE_DESCRIPTION%" == "" set SERVICE_DESCRIPTION=Elasticsearch %ES_VERSION% Windows Service - https://elastic.co

if not "%SERVICE_USERNAME%" == "" (
	if not "%SERVICE_PASSWORD%" == "" (
		set SERVICE_PARAMS=%SERVICE_PARAMS% --ServiceUser "%SERVICE_USERNAME%" --ServicePassword "%SERVICE_PASSWORD%"
	)
)

"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %ES_START_TYPE% --StopTimeout %ES_STOP_TIMEOUT% --StartClass org.elasticsearch.bootstrap.Elasticsearch --StopClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main --StopMethod close --Classpath "%ES_CLASSPATH%" --JvmMs %JVM_MS% --JvmMx %JVM_MX% --JvmSs %JVM_SS% --JvmOptions %ES_JAVA_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "%SERVICE_DISPLAY_NAME%" --Description "%SERVICE_DESCRIPTION%" --Jvm "%%JAVA_HOME%%%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" %SERVICE_PARAMS%

if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_ID%' service
goto:eof

:installed
echo The service '%SERVICE_ID%' has been installed.
goto:eof

:err
echo JAVA_HOME environment variable must be set!
pause
goto:eof

rem ---
rem Function for converting Xm[s|x] values into MB which Commons Daemon accepts
rem ---
:convertxm
set value=%~1
rem extract last char (unit)
set unit=%value:~-1%
rem assume the unit is specified
set conv=%value:~0,-1%

if "%unit%" == "k" goto kilo
if "%unit%" == "K" goto kilo
if "%unit%" == "m" goto mega
if "%unit%" == "M" goto mega
if "%unit%" == "g" goto giga
if "%unit%" == "G" goto giga

rem no unit found, must be bytes; consider the whole value
set conv=%value%
rem convert to KB
set /a conv=%conv% / 1024
:kilo
rem convert to MB
set /a conv=%conv% / 1024
goto mega
:giga
rem convert to MB
set /a conv=%conv% * 1024
:mega
set "%~2=%conv%"
goto:eof

:convertxk
set value=%~1
rem extract last char (unit)
set unit=%value:~-1%
rem assume the unit is specified
set conv=%value:~0,-1%

if "%unit%" == "k" goto kilo
if "%unit%" == "K" goto kilo
if "%unit%" == "m" goto mega
if "%unit%" == "M" goto mega
if "%unit%" == "g" goto giga
if "%unit%" == "G" goto giga

rem no unit found, must be bytes; consider the whole value
set conv=%value%
rem convert to KB
set /a conv=%conv% / 1024
goto kilo
:mega
rem convert to KB
set /a conv=%conv% * 1024
goto kilo
:giga
rem convert to KB
set /a conv=%conv% * 1024 * 1024
:kilo
set "%~2=%conv%"
goto:eof

endlocal
endlocal

@echo off

setlocal enabledelayedexpansion
setlocal enableextensions

call "%~dp0elasticsearch-env.bat" || exit /b 1

set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x64.exe
set SERVICE_ID=elasticsearch-service-x64
set ARCH=64-bit

if EXIST "%EXECUTABLE%" goto okExe
echo elasticsearch-service-x64.exe was not found...
exit /B 1

:okExe
set ES_VERSION=${project.version}

if "%SERVICE_LOG_DIR%" == "" set SERVICE_LOG_DIR=%ES_HOME%\logs

if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
set SERVICE_ID=%1

:checkServiceCmd

if "%LOG_OPTS%" == "" set LOG_OPTS=--LogPath "%SERVICE_LOG_DIR%" --LogPrefix "%SERVICE_ID%" --StdError auto --StdOutput auto

if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == start goto doStart
if /i %SERVICE_CMD% == stop goto doStop
if /i %SERVICE_CMD% == manager goto doManagment
echo Unknown option "%SERVICE_CMD%"

:displayUsage
echo.
echo Usage: elasticsearch-service.bat install^|remove^|start^|stop^|manager [SERVICE_ID]
goto:eof

:doStart
"%EXECUTABLE%" //ES//%SERVICE_ID% %LOG_OPTS%
if not errorlevel 1 goto started
echo Failed starting '%SERVICE_ID%' service
goto:eof
:started
echo The service '%SERVICE_ID%' has been started
goto:eof

:doStop
"%EXECUTABLE%" //SS//%SERVICE_ID% %LOG_OPTS%
if not errorlevel 1 goto stopped
echo Failed stopping '%SERVICE_ID%' service
goto:eof
:stopped
echo The service '%SERVICE_ID%' has been stopped
goto:eof

:doManagment
set EXECUTABLE_MGR=%ES_HOME%\bin\elasticsearch-service-mgr.exe
"%EXECUTABLE_MGR%" //ES//%SERVICE_ID%
if not errorlevel 1 goto managed
echo Failed starting service manager for '%SERVICE_ID%'
goto:eof
:managed
echo Successfully started service manager for '%SERVICE_ID%'.
goto:eof

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

:doInstall
echo Installing service      :  "%SERVICE_ID%"
echo Using JAVA_HOME (%ARCH%):  "%JAVA_HOME%"

rem Check JVM server dll first
if exist "%JAVA_HOME%\jre\bin\server\jvm.dll" (
	set JVM_DLL=\jre\bin\server\jvm.dll
	goto foundJVM
)

rem Check 'server' JRE (JRE installed on Windows Server)
if exist "%JAVA_HOME%\bin\server\jvm.dll" (
	set JVM_DLL=\bin\server\jvm.dll
	goto foundJVM
) else (
  	echo JAVA_HOME points to an invalid Java installation (no jvm.dll found in "%JAVA_HOME%"^). Exiting...
  	goto:eof
)

:foundJVM
set ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options

if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;%

@setlocal
for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%" ^| findstr /b /v "\-server \-client"`) do set JVM_OPTIONS=!JVM_OPTIONS!%%a;
@endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS%%ES_JAVA_OPTS%

if "%ES_JAVA_OPTS:~-1%"==";" set ES_JAVA_OPTS=%ES_JAVA_OPTS:~0,-1%

@setlocal EnableDelayedExpansion
for %%a in ("%ES_JAVA_OPTS:;=","%") do (
  set var=%%a
  if "!var:~1,4!" == "-Xms" (
    if not "!JVM_MS!" == "" (
      echo duplicate min heap size settings found
      goto:eof
    )
    set XMS=!var:~5,-1!
    call:convertxm !XMS! JVM_MS
  )
  if "!var:~1,16!" == "-XX:MinHeapSize=" (
    if not "!JVM_MS!" == "" (
      echo duplicate min heap size settings found
      goto:eof
    )
    set XMS=!var:~17,-1!
    call:convertxm !XMS! JVM_MS
  )
  if "!var:~1,4!" == "-Xmx" (
    if not "!JVM_MX!" == "" (
      echo duplicate max heap size settings found
      goto:eof
    )
    set XMX=!var:~5,-1!
    call:convertxm !XMX! JVM_MX
  )
  if "!var:~1,16!" == "-XX:MaxHeapSize=" (
    if not "!JVM_MX!" == "" (
      echo duplicate max heap size settings found
      goto:eof
    )
    set XMX=!var:~17,-1!
    call:convertxm !XMX! JVM_MX
  )
  if "!var:~1,4!" == "-Xss" (
    if not "!JVM_SS!" == "" (
      echo duplicate thread stack size settings found
      exit 1
    )
    set XSS=!var:~5,-1!
    call:convertxk !XSS! JVM_SS
  )
  if "!var:~1,20!" == "-XX:ThreadStackSize=" (
    if not "!JVM_SS!" == "" (
      echo duplicate thread stack size settings found
      goto:eof
    )
    set XSS=!var:~21,-1!
    call:convertxk !XSS! JVM_SS
  )
)
@endlocal & set JVM_MS=%JVM_MS% & set JVM_MX=%JVM_MX% & set JVM_SS=%JVM_SS%

if "%JVM_MS%" == "" (
  echo minimum heap size not set; configure using -Xms via "%ES_JVM_OPTIONS%" or ES_JAVA_OPTS
  goto:eof
)
if "%JVM_MX%" == "" (
  echo maximum heap size not set; configure using -Xmx via "%ES_JVM_OPTIONS%" or ES_JAVA_OPTS
  goto:eof
)
if "%JVM_SS%" == "" (
  echo thread stack size not set; configure using -Xss via "%ES_JVM_OPTIONS%" or ES_JAVA_OPTS
  goto:eof
)

set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%"

if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0

if "%SERVICE_DISPLAY_NAME%" == "" set SERVICE_DISPLAY_NAME=Elasticsearch %ES_VERSION% (%SERVICE_ID%)
if "%SERVICE_DESCRIPTION%" == "" set SERVICE_DESCRIPTION=Elasticsearch %ES_VERSION% Windows Service - https://elastic.co

if not "%SERVICE_USERNAME%" == "" (
	if not "%SERVICE_PASSWORD%" == "" (
		set SERVICE_PARAMS=%SERVICE_PARAMS% --ServiceUser "%SERVICE_USERNAME%" --ServicePassword "%SERVICE_PASSWORD%"
	)
)

"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %ES_START_TYPE% --StopTimeout %ES_STOP_TIMEOUT% --StartClass org.elasticsearch.bootstrap.Elasticsearch --StopClass org.elasticsearch.bootstrap.Elasticsearch --StartMethod main --StopMethod close --Classpath "%ES_CLASSPATH%" --JvmMs %JVM_MS% --JvmMx %JVM_MX% --JvmSs %JVM_SS% --JvmOptions %ES_JAVA_OPTS% ++JvmOptions %ES_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "%SERVICE_DISPLAY_NAME%" --Description "%SERVICE_DESCRIPTION%" --Jvm "%%JAVA_HOME%%%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%ES_HOME%" %SERVICE_PARAMS%

if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_ID%' service
goto:eof

:installed
echo The service '%SERVICE_ID%' has been installed.
goto:eof

:err
echo JAVA_HOME environment variable must be set!
pause
goto:eof

rem ---
rem Function for converting Xm[s|x] values into MB which Commons Daemon accepts
rem ---
:convertxm
set value=%~1
rem extract last char (unit)
set unit=%value:~-1%
rem assume the unit is specified
set conv=%value:~0,-1%

if "%unit%" == "k" goto kilo
if "%unit%" == "K" goto kilo
if "%unit%" == "m" goto mega
if "%unit%" == "M" goto mega
if "%unit%" == "g" goto giga
if "%unit%" == "G" goto giga

rem no unit found, must be bytes; consider the whole value
set conv=%value%
rem convert to KB
set /a conv=%conv% / 1024
:kilo
rem convert to MB
set /a conv=%conv% / 1024
goto mega
:giga
rem convert to MB
set /a conv=%conv% * 1024
:mega
set "%~2=%conv%"
goto:eof

:convertxk
set value=%~1
rem extract last char (unit)
set unit=%value:~-1%
rem assume the unit is specified
set conv=%value:~0,-1%

if "%unit%" == "k" goto kilo
if "%unit%" == "K" goto kilo
if "%unit%" == "m" goto mega
if "%unit%" == "M" goto mega
if "%unit%" == "g" goto giga
if "%unit%" == "G" goto giga

rem no unit found, must be bytes; consider the whole value
set conv=%value%
rem convert to KB
set /a conv=%conv% / 1024
goto kilo
:mega
rem convert to KB
set /a conv=%conv% * 1024
goto kilo
:giga
rem convert to KB
set /a conv=%conv% * 1024 * 1024
:kilo
set "%~2=%conv%"
goto:eof

endlocal
endlocal

Fix handling of paths containing parentheses

This commit fixes an issue with the handling of paths containing
parentheses on Windows. When such a path is used as a component of
Elasticsearch home, then a later echo statement that is guarded by an if
will fail because the parentheses in the path will be confused with the
parentheses defining the if block. This commit fixes the issue by
protecting this echo statement by wrapping the possibly offending path
in quotes.

Relates #26916


@ECHO OFF

setLocal EnableDelayedExpansion
set mainClasspath=
for %%i in (binaries\*.jar) do (set mainClasspath=!mainClasspath!;%%i)
set mainClass=org.drools.examples.DroolsExamplesApp

echo "Usage: runExamples.bat"
echo "For example: runExamples.bat"
echo "Some notes:"
echo "- Working dir should be the directory of this script."
echo "- Java is recommended to be JDK and java 6 for optimal performance"
echo "- The environment variable JAVA_HOME should be set to the JDK installation directory"
echo "  For example: set JAVA_HOME="C:\Program Files\Java\jdk1.6.0"
echo
echo "Starting examples app..."

rem You can use -Xmx128m or less too, but it might be slower
if exist %JAVA_HOME%\bin\java.exe (
    %JAVA_HOME%\bin\java -Xms256m -Xmx512m -server -cp %mainClasspath% %mainClass%
) else (
    java -Xms256m -Xmx512m -cp %mainClasspath% %mainClass%
)

@ECHO OFF
setLocal enableExtensions enableDelayedExpansion

rem You can use -Xmx128m or less too for most examples, but it might be slower
set "jvmOptions=-Xms256m -Xmx1024m"
set "mainClass=org.drools.examples.DroolsExamplesApp"
set "mainClasspath="
for %%i in (binaries\*.jar) do (set "mainClasspath=!mainClasspath!;%%i")

echo Usage: runExamples.bat
echo Notes:
echo - Java must be installed. Get the JRE ^(http://www.java.com^) or the JDK.
echo - For optimal performance, Java is recommended to be OpenJDK 7 or higher.
echo - For JDK, the environment variable JAVA_HOME should be set to the JDK installation directory
echo   For example: set "JAVA_HOME=C:\Program Files\Java\jdk1.6.0"
echo - The working dir should be the directory of this script.
echo.

if exist "%JAVA_HOME%\bin\java.exe" (
    echo Starting examples app with JDK from environment variable JAVA_HOME ^(%JAVA_HOME%^)...
    rem JDK supports -server mode
    "%JAVA_HOME%\bin\java" !jvmOptions! -server -cp !mainClasspath! !mainClass!
    goto endProcess
) else (
    rem Find JRE home in Windows Registry
    set "jreRegKey=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
    set "jreVersion="
    for /f "tokens=3" %%v in ('reg query "!jreRegKey!" /v "CurrentVersion" 2^>nul') do set "jreVersion=%%v"
    if not defined jreVersion (
        set "jreRegKey=HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment"
        for /f "tokens=3" %%v in ('reg query "!jreRegKey!" /v "CurrentVersion" 2^>nul') do set "jreVersion=%%v"
        if not defined jreVersion (
            echo ERROR: The JRE is not installed on this system.
            goto failure
        )
    )
    set "jreHome="
    for /f "tokens=2,*" %%d in ('reg query "!jreRegKey!\!jreVersion!" /v "JavaHome" 2^>nul') do set "jreHome=%%e"
    if not defined jreHome (
        echo ERROR: The JRE is not properly installed on this system, although jreVersion ^(!jreVersion!^) exists.
        goto failure
    )

    if not exist "!jreHome!\bin\java.exe" (
        echo ERROR: The JRE home ^(!jreHome!^) does not contain java ^(bin\java.exe^).
        goto failure
    )
    echo Starting examples app with JRE from JRE home ^(!jreHome!^)...
    "!jreHome!\bin\java" !jvmOptions! -cp !mainClasspath! !mainClass!
    goto endProcess
)

:failure
    echo.
    echo Please install Java from http://www.java.com first.
    rem Prevent the terminal window to disappear before the user has seen the error message
    echo Press any key to close this window.
    pause
    goto endProcess

:endProcess
    endLocal

make runExamples.bat work OOTB

[DROOLS-539] make runExamples.bat work OOTB

 * the "java" command is not on PATH when users
   have only JRE installed. The script now looks
   in other places as well before failing

 * thanks @geoffrey for the solution


@ECHO OFF

setLocal EnableDelayedExpansion
set mainClasspath=
for %%i in (binaries\*.jar) do (set mainClasspath=!mainClasspath!;%%i)
set mainClass=org.drools.examples.DroolsExamplesApp

echo "Usage: runExamples.bat"
echo "For example: runExamples.bat"
echo "Some notes:"
echo "- Working dir should be the directory of this script."
echo "- Java is recommended to be JDK and java 6 for optimal performance"
echo "- The environment variable JAVA_HOME should be set to the JDK installation directory"
echo "  For example: set JAVA_HOME="C:\Program Files\Java\jdk1.6.0"
echo
echo "Starting examples app..."

rem You can use -Xmx128m or less too, but it might be slower
if exist %JAVA_HOME%\bin\java.exe (
    %JAVA_HOME%\bin\java -Xms256m -Xmx512m -server -cp %mainClasspath% %mainClass%
) else (
    java -Xms256m -Xmx512m -cp %mainClasspath% %mainClass%
)

if %ERRORLEVEL% neq 0 (
    echo
    echo "Error occurred. Check if JAVA_HOME (%JAVA_HOME%) is correct."
    rem Prevent the terminal window to disappear before the user has seen the error message
    sleep 20
)

Revert "runExamples.bat: Prevent the terminal window to disappear before the user has seen the error message"

This reverts commit ed644e22fec2ff542fc54eba46698f68301b3cc2.