:: Terminal API
::
:: This file is called whenever a user enters a shell.
::
:: Dependencies:
::  - pyblish-base
::  - pyblish-maya
::  - pyblish-nuke
::  - pyblish-houdini
::  - pyblish-lite
::  - pyblish-qml
::  - pyblish-mindbender
::
:: Usage:
:: 	1. Create a local `mb.bat` file and set the required environment variables
::  2. Call your `mb.bat`
::
:: Example:
::   $ mb

@echo off

if "%1"=="" goto :usage

:: External Dependencies
if "%PYBLISH_BASE%"=="" goto :missing
if "%PYBLISH_MAYA%"=="" goto :missing
if "%PYBLISH_NUKE%"=="" goto :missing
if "%PYBLISH_LITE%"=="" goto :missing
if "%PYBLISH_QML%"=="" goto :missing
if "%MINDBENDER_CORE%"=="" goto :missing

:: Clear environment.
::
:: This is IMPORTANT, if one is to attempt at running
:: an application or task from the same shell more than once.
set PYTHONPATH=
set PYBLISHPLUGINPATH=

set PYTHONPATH=%PYBLISH_BASE%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_MAYA%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_NUKE%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_LITE%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_QML%;%PYTHONPATH%
set PYTHONPATH=%MINDBENDER_CORE%;%PYTHONPATH%

set PROJECTS=%1

:: Expose pipeline executables
set PATH=%MINDBENDER_CORE%\bin;%PATH%
set PYBLISHPLUGINPATH=%MINDBENDER_CORE%\mindbender\plugins;%PYBLISHPLUGINPATH%

:: --------------------
:: User interface
:: --------------------

:: Use $ as prefix to prompt commands
:: The default PROMPT is the current working directory,
:: which can make it look a little daunting due to its length.
set PROMPT=$$

:: Go to projects directory
pushd %PROJECTS%

:: Clear screen
title Mindbender Launcher
cls

:: Print intro
echo+
echo  MEINDBENDER START ---------------------------
echo+
echo+
echo                 _,--,
echo              .-'---./_    __
echo             /o \\     '-.' /
echo             \  //    _.-'._\
echo              `"\)--"`
echo+
echo+
echo   Welcome %USERNAME%!
echo+
echo   1. Type first characters of a project, e.g. "p999_"
echo   2. Press TAB to cycle through matching projects
echo+
echo  ---------------------------------------------
echo+

:: Clearing old Variables
SET PROJECTDIR=
SET ASSET=

:: Open a persistent shell
cmd.exe /K

goto :eof

:usage
	echo Not enough arguments
	echo Example: mb.bat c:\path\to\projects

:missing
	echo ERROR: Missing environment variables.
	if "%PYBLISH_BASE%"=="" echo   - %%PYBLISH_BASE%%
	if "%PYBLISH_MAYA%"=="" echo   - %%PYBLISH_MAYA%%
	if "%PYBLISH_NUKE%"=="" echo   - %%PYBLISH_NUKE%%
	if "%PYBLISH_LITE%"=="" echo   - %%PYBLISH_LITE%%
	if "%PYBLISH_QML%"=="" echo   - %%PYBLISH_QML%%
	if "%MINDBENDER_CORE%"=="" echo   - %%MINDBENDER_CORE%%

	exit /b

:: Terminal API
::
:: This file is called whenever a user enters a shell.
::
:: Dependencies:
::  - pyblish-base
::  - pyblish-maya
::  - pyblish-nuke
::  - pyblish-houdini
::  - pyblish-lite
::  - pyblish-qml
::  - pyblish-mindbender
::
:: Usage:
:: 	1. Create a local `mb.bat` file and set the required environment variables
::  2. Call your `mb.bat`
::
:: Example:
::   $ mb

@echo off

if "%1"=="" goto :usage

:: External Dependencies
if "%PYBLISH_BASE%"=="" goto :missing
if "%PYBLISH_MAYA%"=="" goto :missing
if "%PYBLISH_NUKE%"=="" goto :missing
if "%PYBLISH_LITE%"=="" goto :missing
if "%PYBLISH_QML%"=="" goto :missing
if "%MINDBENDER_CORE%"=="" goto :missing

:: Clear environment.
::
:: This is IMPORTANT, if one is to attempt at running
:: an application or task from the same shell more than once.
set PYTHONPATH=
set PYBLISHPLUGINPATH=

set PYTHONPATH=%PYBLISH_BASE%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_MAYA%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_NUKE%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_LITE%;%PYTHONPATH%
set PYTHONPATH=%PYBLISH_QML%;%PYTHONPATH%
set PYTHONPATH=%MINDBENDER_CORE%;%PYTHONPATH%

set PROJECTS=%1

:: Enable typing "back" funktion
set PATH=%_GIT%\mindbender-core\bin\back\;%PATH%

:: Expose pipeline executables
set PATH=%MINDBENDER_CORE%\bin;%PATH%
set PYBLISHPLUGINPATH=%MINDBENDER_CORE%\mindbender\plugins;%PYBLISHPLUGINPATH%

:: --------------------
:: User interface
:: --------------------

:: Use $ as prefix to prompt commands
:: The default PROMPT is the current working directory,
:: which can make it look a little daunting due to its length.
set PROMPT=$$

:: Go to projects directory
pushd %PROJECTS%

:: Clear screen
title Mindbender Launcher
cls

:: Print intro
echo+
echo  MEINDBENDER START ---------------------------
echo+
echo+
echo                 _,--,
echo              .-'---./_    __
echo             /o \\     '-.' /
echo             \  //    _.-'._\
echo              `"\)--"`
echo+
echo+
echo   Welcome %USERNAME%!
echo+
echo   1. Type first characters of a project, e.g. "p999_"
echo   2. Press TAB to cycle through matching projects
echo+
echo  ---------------------------------------------
echo+

:: Clearing old Variables
SET PROJECTDIR=
SET ASSET=

:: Open a persistent shell
cmd.exe /K

goto :eof

:usage
	echo Not enough arguments
	echo Example: mb.bat c:\path\to\projects

:missing
	echo ERROR: Missing environment variables.
	if "%PYBLISH_BASE%"=="" echo   - %%PYBLISH_BASE%%
	if "%PYBLISH_MAYA%"=="" echo   - %%PYBLISH_MAYA%%
	if "%PYBLISH_NUKE%"=="" echo   - %%PYBLISH_NUKE%%
	if "%PYBLISH_LITE%"=="" echo   - %%PYBLISH_LITE%%
	if "%PYBLISH_QML%"=="" echo   - %%PYBLISH_QML%%
	if "%MINDBENDER_CORE%"=="" echo   - %%MINDBENDER_CORE%%

	exit /b

add back.bat to %PATH% variable in this file


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

:: ----------------------
:: KUDU Deployment Script
:: 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
)
ECHO CALLING GET RUBY

call :ExecuteCmd "getruby.cmd"

ECHO WE MADE IT

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

echo Handling Basic Web Site deployment.

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

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
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.

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

:: ----------------------
:: KUDU Deployment Script
:: 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
)
ECHO CALLING GET RUBY

call :ExecuteCmd "scripts/getruby.cmd"

ECHO WE MADE IT

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

echo Handling Basic Web Site deployment.

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

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
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.

fix path

fix path


dir .\%1.sql /s/B >%tmp%\%0.txt
for /F "tokens=*" %%A in (%tmp%\%0.txt) do psql -h scuola247 -d scuola247 -U postgres -c "\encoding utf8" -f %%A
rem prova

Update runsql.bat

Update runsql.bat

Prova di cambiamento


if "%TYPE%" == "zpm" (
    cd test

    zpm install-package --allow-install --allow-module || exit /b 1
    zpm vs2015 --allow-install || exit /b 1

    msbuild zpm/CoreLib-ZPM.sln || exit /b 1

    test\bin\x86\core-zpm-test.exe || exit /b 1
) else (
    zpm install-package --allow-install --allow-module || exit /b 1
    zpm %VSTUD% --allow-install || exit /b 1

    msbuild core/CoreLib.sln /property:Configuration=Release /property:Platform=%PLAT% || exit /b 1

    if %TYPE% == "debug" (
        bin\%ARCH%\core-testd
    ) else (
        bin\%ARCH%\core-test
    )
)

if "%TYPE%" == "zpm" (
    cd test

    zpm install-package --allow-install --allow-module || exit /b 1
    zpm vs2015 --allow-install || exit /b 1

    msbuild zpm/CoreLib-ZPM.sln || exit /b 1

    bin\x86\core-zpm-test.exe || exit /b 1
) else (
    zpm install-package --allow-install --allow-module || exit /b 1
    zpm %VSTUD% --allow-install || exit /b 1

    msbuild core/CoreLib.sln /property:Configuration=Release /property:Platform=%PLAT% || exit /b 1

    if %TYPE% == "debug" (
        bin\%ARCH%\core-testd
    ) else (
        bin\%ARCH%\core-test
    )
)

Fix test path

Fix test path


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

if "%1"=="" goto default_value:
set pythonexe="%1"
%pythonexe% setup.py write_version
goto custom_python:

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

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

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

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

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

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

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

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

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

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

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

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

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

if "%1"=="" goto default_value:
set pythonexe="%1"
%pythonexe% setup.py write_version
goto custom_python:

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

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

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

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

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

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

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

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

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

%pythonexe% setup.py clean_pyd
%pythonexe% setup.py sdist --formats=gztar,zip --verbose
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_wininst --plat-name=win-amd64
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_msi
if %errorlevel% neq 0 exit /b %errorlevel%
%pythonexe% setup.py bdist_wheel
if %errorlevel% neq 0 exit /b %errorlevel%
echo #######################################################

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

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

change build_setup_help_on_windows to run unit test on anaconda


@ECHO OFF
REM Usage: [buildbase.bat ..\vs2013\mysolution.sln 12]

SET solution=%1
SET version=%2
SET log=build_%version%.log
SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat
SET environment="%programfiles(x86)%\%tools%"
IF NOT EXIST %environment% SET environment="%programfiles%\%tools%"
IF NOT EXIST %environment% GOTO no_tools

ECHO Building: %solution%

CALL %environment% x86 > nul
ECHO Platform=x86

ECHO Configuration=LtcgDebug
msbuild /m /v:n /p:Configuration=LtcgDebug /p:Platform=Win32 %solution% > %log%
IF errorlevel 1 GOTO error
ECHO Configuration=LtcgRelease
msbuild /m /v:n /p:Configuration=LtcgRelease /p:Platform=Win32 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticDebug
msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=Win32 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticRelease
msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=Win32 %solution% >> %log%
IF errorlevel 1 GOTO error

CALL %environment% x86_amd64 > nul
ECHO Platform=x64

ECHO Configuration=LtcgDebug
msbuild /m /v:n /p:Configuration=LtcgDebug /p:Platform=x64 %solution% > %log%
IF errorlevel 1 GOTO error
ECHO Configuration=LtcgRelease
msbuild /m /v:n /p:Configuration=LtcgRelease /p:Platform=x64 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticDebug
msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=x64 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticRelease
msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=x64 %solution% >> %log%
IF errorlevel 1 GOTO error

ECHO Complete: %solution%
GOTO end

:error
ECHO *** ERROR, build terminated early, see: %log%
GOTO end

:no_tools
ECHO *** ERROR, build tools not found: %tools%

:end

@ECHO OFF
REM Usage: [buildbase.bat ..\vs2013\mysolution.sln 12]

SET solution=%1
SET version=%2
SET log=build_%version%.log
SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat
SET environment="%programfiles(x86)%\%tools%"
IF NOT EXIST %environment% SET environment="%programfiles%\%tools%"
IF NOT EXIST %environment% GOTO no_tools

ECHO Building: %solution%

CALL %environment% x86 > nul
ECHO Platform=x86

ECHO Configuration=LtcgDebug
msbuild /m /v:n /p:Configuration=LtcgDebug /p:Platform=Win32 %solution% > %log%
IF errorlevel 1 GOTO error
ECHO Configuration=LtcgRelease
msbuild /m /v:n /p:Configuration=LtcgRelease /p:Platform=Win32 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticDebug
msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=Win32 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticRelease
msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=Win32 %solution% >> %log%
IF errorlevel 1 GOTO error

CALL %environment% x86_amd64 > nul
ECHO Platform=x64

ECHO Configuration=LtcgDebug
msbuild /m /v:n /p:Configuration=LtcgDebug /p:Platform=x64 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=LtcgRelease
msbuild /m /v:n /p:Configuration=LtcgRelease /p:Platform=x64 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticDebug
msbuild /m /v:n /p:Configuration=StaticDebug /p:Platform=x64 %solution% >> %log%
IF errorlevel 1 GOTO error
ECHO Configuration=StaticRelease
msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=x64 %solution% >> %log%
IF errorlevel 1 GOTO error

ECHO Complete: %solution%
GOTO end

:error
ECHO *** ERROR, build terminated early, see: %log%
GOTO end

:no_tools
ECHO *** ERROR, build tools not found: %tools%

:end

Fix VS build log truncation.

Fix VS build log truncation.


@echo off
if "%1"=="" echo Usage: %~nx0 SourceFile.cs && goto :eof

rem Windows 7+
set csc=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\csc.exe
if exist %csc% goto compile

rem Windows 2003
set csc=%SystemRoot%\Microsoft.NET\Framework\v3.5\csc.exe
if exist %csc% goto compile

rem Windows XP
set csc=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\csc.exe
if exist %csc% goto compile

echo No Microsoft .NET ?!!
goto :eof

:compile
%csc% %1
goto :eof

Add a simple compiler.

Add a simple compiler.


@ECHO OFF
REM
REM This script generates headers for use with Visual C++ only
REM
REM Usage:
REM .\autogen.bat
REM nmake -f makefile.vc
REM
REM NOTE: DO NOT include this script in GEOS sources distribution
REM

set GEOS_HEADERS=include\geos

COPY %GEOS_HEADERS%\version.h.vc %GEOS_HEADERS%\version.h
COPY %GEOS_HEADERS%\platform.h.vc %GEOS_HEADERS%\platform.h
COPY capi\geos_c.h.in capi\geos_c.h
@ECHO #define GEOS_SVN_REVISION 0 > geos_svn_revision.h

Add step generating geos_svn_revision.h template with revision 0

Simplifies CI build steps.

[ci skip]

git-svn-id: 6c2b1bd10c324c49ea9d9e6e31006a80e70507cb@4364 5242fede-7e19-0410-aef8-94bd7d2200fb


@ECHO OFF

REM This script builds and signs the Windows packages on Gitlab

ECHO "Start Time"
TIME /T

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

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

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

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

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

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

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

IF "%WINDOWS%" == "enabled_all_addons" (
  SET EXTRA_ADDONS=^
    -addon=bignums ^
    -addon=equations ^
    -addon=ltac2 ^
    -addon=mtac2 ^
    -addon=mathcomp ^
    -addon=menhir ^
    -addon=menhirlib ^
    -addon=compcert ^
    -addon=extlib ^
    -addon=quickchick ^
    -addon=coquelicot
  REM addons with build issues
  REM -addon=vst ^
  REM -addon=aactactics ^
) ELSE (
  SET "EXTRA_ADDONS= "
)

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

ECHO "Start Artifact Creation"
TIME /T

mkdir artifacts

CALL :CopyLogFiles

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

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

ECHO "Finished Artifact Creation"
TIME /T

CALL :CleanupFolders

ECHO "Finished Cleanup"
TIME /T

GOTO :EOF

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

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

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

:ErrorCopyLogFilesAndExit
  CALL :CopyLogFiles
  REM fall through

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

@ECHO OFF

REM This script builds and signs the Windows packages on Gitlab

ECHO "Start Time"
TIME /T

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

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

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

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

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

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

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

IF "%WINDOWS%" == "enabled_all_addons" (
  SET EXTRA_ADDONS=^
    -addon=bignums ^
    -addon=equations ^
    -addon=ltac2 ^
    -addon=mtac2 ^
    -addon=mathcomp ^
    -addon=menhir ^
    -addon=menhirlib ^
    -addon=compcert ^
    -addon=extlib ^
    -addon=quickchick ^
    -addon=coquelicot
  REM addons with build issues
  REM -addon=vst ^
  REM -addon=aactactics ^
) ELSE (
  SET "EXTRA_ADDONS= "
)

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

ECHO "Start Artifact Creation"
TIME /T

mkdir artifacts

CALL :CopyLogFiles

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

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

ECHO "Finished Artifact Creation"
TIME /T

CALL :CleanupFolders

ECHO "Finished Cleanup"
TIME /T

GOTO :EOF

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

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

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

:ErrorCopyLogFilesAndExit
  CALL :CopyLogFiles
  REM fall through

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

Fix issue: Windows CI: cygwin install cache is not reused #9212


@ECHO off
:: Check command line parameters
IF (%3)==() GOTO usage
IF (%2)==() GOTO usage
IF (%1)==() GOTO usage
IF (%1)==(?) GOTO usage
IF (%1)==(/?) GOTO usage
IF (%1)==(-?) GOTO usage
IF (%1)==(--?) GOTO usage
IF (%1)==(/help) GOTO usage
IF (%1)==(-help) GOTO usage
IF (%1)==(--help) GOTO usage

java -Xmx512M -cp commons-lang-2.4.jar;bliki-3.0.3.jar;LanguageTool.jar org.languagetool.dev.wikipedia.CheckWikipediaDump - disabled_rules.txt %1 %2 %3 %4
GOTO eof

:usage
ECHO Usage: %0 lang wikipediaXmlDump ruleIds [maxNumArticles]
ECHO Where:
ECHO - lang is a language code such as 'en' or 'de'
ECHO - wikipediaXmlDump is the path to an unpacked Wikipedia XML dump
ECHO - ruleIds is a comma-separated list of rules to be activated, or '-' for the default rules
ECHO - maxNumArticles is the maximum number of articles to check (optional)
ECHO Examples:
ECHO - %0 de dewiki-20111012-pages-articles-partly.xml -
ECHO - %0 de dewiki-20111012-pages-articles-partly.xml GROSSER_STIEL 50

:eof

@ECHO off
:: Check command line parameters
IF (%3)==() GOTO usage
IF (%2)==() GOTO usage
IF (%1)==() GOTO usage
IF (%1)==(?) GOTO usage
IF (%1)==(/?) GOTO usage
IF (%1)==(-?) GOTO usage
IF (%1)==(--?) GOTO usage
IF (%1)==(/help) GOTO usage
IF (%1)==(-help) GOTO usage
IF (%1)==(--help) GOTO usage

IF (%1)==(de) CHCP 1252
java -Xmx512M -cp commons-lang-2.4.jar;bliki-3.0.3.jar;LanguageTool.jar org.languagetool.dev.wikipedia.CheckWikipediaDump - disabled_rules.txt %1 %2 %3 %4
GOTO eof

:usage
ECHO Usage: %0 lang wikipediaXmlDump ruleIds [maxNumArticles]
ECHO Where:
ECHO - lang is a language code such as 'en' or 'de'
ECHO - wikipediaXmlDump is the path to an unpacked Wikipedia XML dump
ECHO - ruleIds is a comma-separated list of rules to be activated, or '-' for the default rules
ECHO - maxNumArticles is the maximum number of articles to check (optional)
ECHO Examples:
ECHO - %0 de dewiki-20111012-pages-articles-partly.xml -
ECHO - %0 de dewiki-20111012-pages-articles-partly.xml GROSSER_STIEL 50
ECHO - %0 de dewiki-20111012-pages-articles-partly.xml "GROSSER_STIEL,BISSTRICH"

:eof

testwikipedia.bat: switch to appropriate codepage for German, one more example


@ECHO OFF

%~dp0..\..\startvs.cmd %~dp0JSInterop.slnf

Add startvs for each solution (dotnet/extensions#2630)

\n\nCommit migrated from https://github.com/dotnet/extensions/commit/e41d90f66109f3387063f412a0ec61c85f8ecbdb


mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE:STRING=Release ^
      -D CMAKE_PREFIX_PATH:FILEPATH=%LIBRARY_PREFIX% ^
      -D CMAKE_INSTALL_PREFIX:FILEPATH=%LIBRARY_PREFIX% ^
      ..

make install

cd ..

%PYTHON% setup.py build_ext
%PYTHON% setup.py install

mkdir build
cd build

cmake -G "MinGW Makefiles" ^
      -D CMAKE_BUILD_TYPE:STRING=Release ^
      -D CMAKE_PREFIX_PATH:FILEPATH=%LIBRARY_PREFIX% ^
      -D CMAKE_INSTALL_PREFIX:FILEPATH=%LIBRARY_PREFIX% ^
      ..

mingw32-make VERBOSE=1
mingw32-make install

cd ..

%PYTHON% setup.py build_ext
%PYTHON% setup.py install

Update bld.bat

Update bld.bat


cd wincon

nmake -f Makefile.vc WIDE=Y DLL=Y UTF8=Y
if errorlevel 1 exit 1

REM install header files
mkdir %LIBRARY_PREFIX%\include\
cp %SRC_DIR%\curses.h %LIBRARY_PREFIX%\include\
cp %SRC_DIR%\curspriv.h %LIBRARY_PREFIX%\include\
cp %SRC_DIR%\panel.h %LIBRARY_PREFIX%\include\

REM install dll
mkdir %LIBRARY_PREFIX%\bin\
cp pdcurses.dll %LIBRARY_PREFIX%\bin\

REM install lib
mkdir %LIBRARY_PREFIX%\lib\
cp pdcurses.lib %LIBRARY_PREFIX%\lib\

cd wincon

nmake -f Makefile.vc WIDE=Y DLL=Y UTF8=Y
if errorlevel 1 exit 1

REM install header files
mkdir %LIBRARY_PREFIX%\include\
copy %SRC_DIR%\curses.h %LIBRARY_PREFIX%\include\
copy %SRC_DIR%\curspriv.h %LIBRARY_PREFIX%\include\
copy %SRC_DIR%\panel.h %LIBRARY_PREFIX%\include\

REM install dll
mkdir %LIBRARY_PREFIX%\bin\
copy pdcurses.dll %LIBRARY_PREFIX%\bin\

REM install lib
mkdir %LIBRARY_PREFIX%\lib\
copy pdcurses.lib %LIBRARY_PREFIX%\lib\

fix copy

fix copy


@echo off
REM src/tools/msvc/clean.bat

set DIST=0
if "%1"=="dist" set DIST=1

set D=%CD%
if exist ..\msvc if exist ..\..\..\src cd ..\..\..

if exist debug rd /s /q debug
if exist release rd /s /q release
for %%f in (*.vcproj) do del %%f
for %%f in (*.vcxproj) do del %%f
for %%f in (*.vcxproj.user) do del %%f
if exist pgsql.sln del /q pgsql.sln
if exist pgsql.sln.cache del /q pgsql.sln.cache
if exist pgsql.sdf del /q pgsql.sdf
if exist pgsql.suo del /q /a:H pgsql.suo
del /s /q src\bin\win32ver.rc 2> NUL
del /s /q src\interfaces\win32ver.rc 2> NUL
if exist src\backend\win32ver.rc del /q src\backend\win32ver.rc

REM Delete files created with GenerateFiles() in Solution.pm
if exist src\include\pg_config.h del /q src\include\pg_config.h
if exist src\include\pg_config_ext.h del /q src\include\pg_config_ext.h
if exist src\include\pg_config_os.h del /q src\include\pg_config_os.h
if exist src\include\dynloader.h del /q src\include\dynloader.h
if %DIST%==1 if exist src\backend\parser\gram.h del /q src\backend\parser\gram.h
if exist src\include\utils\errcodes.h del /q src\include\utils\errcodes.h
if exist src\include\utils\fmgroids.h del /q src\include\utils\fmgroids.h
if exist src\include\utils\probes.h del /q src\include\utils\probes.h

if %DIST%==1 if exist src\backend\utils\fmgroids.h del /q src\backend\utils\fmgroids.h
if %DIST%==1 if exist src\backend\utils\fmgrtab.c del /q src\backend\utils\fmgrtab.c
if %DIST%==1 if exist src\backend\catalog\postgres.bki del /q src\backend\catalog\postgres.bki
if %DIST%==1 if exist src\backend\catalog\postgres.description del /q src\backend\catalog\postgres.description
if %DIST%==1 if exist src\backend\catalog\postgres.shdescription del /q src\backend\catalog\postgres.shdescription
if %DIST%==1 if exist src\backend\catalog\schemapg.h del /q src\backend\catalog\schemapg.h
if %DIST%==1 if exist src\backend\parser\scan.c del /q src\backend\parser\scan.c
if %DIST%==1 if exist src\backend\parser\gram.c del /q src\backend\parser\gram.c
if %DIST%==1 if exist src\backend\bootstrap\bootscanner.c del /q src\backend\bootstrap\bootscanner.c
if %DIST%==1 if exist src\backend\bootstrap\bootparse.c del /q src\backend\bootstrap\bootparse.c
if %DIST%==1 if exist src\backend\utils\misc\guc-file.c del /q src\backend\utils\misc\guc-file.c

if exist src\bin\psql\sql_help.h del /q src\bin\psql\sql_help.h

if exist src\interfaces\libpq\libpq.rc del /q src\interfaces\libpq\libpq.rc
if exist src\interfaces\libpq\libpqdll.def del /q src\interfaces\libpq\libpqdll.def
if exist src\interfaces\ecpg\compatlib\compatlib.def del /q src\interfaces\ecpg\compatlib\compatlib.def
if exist src\interfaces\ecpg\ecpglib\ecpglib.def del /q src\interfaces\ecpg\ecpglib\ecpglib.def
if exist src\interfaces\ecpg\include\ecpg_config.h del /q src\interfaces\ecpg\include\ecpg_config.h
if exist src\interfaces\ecpg\pgtypeslib\pgtypeslib.def del /q src\interfaces\ecpg\pgtypeslib\pgtypeslib.def
if %DIST%==1 if exist src\interfaces\ecpg\preproc\pgc.c del /q src\interfaces\ecpg\preproc\pgc.c
if %DIST%==1 if exist src\interfaces\ecpg\preproc\preproc.c del /q src\interfaces\ecpg\preproc\preproc.c
if %DIST%==1 if exist src\interfaces\ecpg\preproc\preproc.h del /q src\interfaces\ecpg\preproc\preproc.h

if exist src\port\pg_config_paths.h del /q src\port\pg_config_paths.h

if exist src\pl\plperl\spi.c del /q src\pl\plperl\spi.c
if %DIST%==1 if exist src\pl\plpgsql\src\pl_gram.c del /q src\pl\plpgsql\src\pl_gram.c
if %DIST%==1 if exist src\pl\plpgsql\src\pl_gram.h del /q src\pl\plpgsql\src\pl_gram.h

if %DIST%==1 if exist src\bin\psql\psqlscan.c del /q src\bin\psql\psqlscan.c

if %DIST%==1 if exist contrib\cube\cubescan.c del /q contrib\cube\cubescan.c
if %DIST%==1 if exist contrib\cube\cubeparse.c del /q contrib\cube\cubeparse.c
if %DIST%==1 if exist contrib\seg\segscan.c del /q contrib\seg\segscan.c
if %DIST%==1 if exist contrib\seg\segparse.c del /q contrib\seg\segparse.c

if exist src\test\regress\tmp_check rd /s /q src\test\regress\tmp_check
if exist contrib\spi\refint.dll del /q contrib\spi\refint.dll
if exist contrib\spi\autoinc.dll del /q contrib\spi\autoinc.dll
if exist src\test\regress\regress.dll del /q src\test\regress\regress.dll
if exist src\test\regress\refint.dll del /q src\test\regress\refint.dll
if exist src\test\regress\autoinc.dll del /q src\test\regress\autoinc.dll

if exist src\bin\initdb\tmp_check rd /s /q src\bin\initdb\tmp_check
if exist src\bin\pg_basebackup\tmp_check rd /s /q src\bin\pg_basebackup\tmp_check
if exist src\bin\pg_config\tmp_check rd /s /q src\bin\pg_config\tmp_check
if exist src\bin\pg_ctl\tmp_check rd /s /q src\bin\pg_ctl\tmp_check
if exist src\bin\scripts\tmp_check rd /s /q src\bin\scripts\tmp_check

REM Clean up datafiles built with contrib
REM cd contrib
REM for /r %%f in (*.sql) do if exist %%f.in del %%f

REM clean up files copied into contrib\pg_xlogdump
if exist contrib\pg_xlogdump\xlogreader.c del /q contrib\pg_xlogdump\xlogreader.c
for %%f in (contrib\pg_xlogdump\*desc.c) do if not %%f==contrib\pg_xlogdump\rmgrdesc.c del /q %%f

cd %D%

REM Clean up ecpg regression test files
msbuild /NoLogo ecpg_regression.proj /t:clean /v:q

goto :eof

@echo off
REM src/tools/msvc/clean.bat

set DIST=0
if "%1"=="dist" set DIST=1

set D=%CD%
if exist ..\msvc if exist ..\..\..\src cd ..\..\..

if exist debug rd /s /q debug
if exist release rd /s /q release
for %%f in (*.vcproj) do del %%f
for %%f in (*.vcxproj) do del %%f
for %%f in (*.vcxproj.user) do del %%f
if exist pgsql.sln del /q pgsql.sln
if exist pgsql.sln.cache del /q pgsql.sln.cache
if exist pgsql.sdf del /q pgsql.sdf
if exist pgsql.suo del /q /a:H pgsql.suo
del /s /q src\bin\win32ver.rc 2> NUL
del /s /q src\interfaces\win32ver.rc 2> NUL
if exist src\backend\win32ver.rc del /q src\backend\win32ver.rc

REM Delete files created with GenerateFiles() in Solution.pm
if exist src\include\pg_config.h del /q src\include\pg_config.h
if exist src\include\pg_config_ext.h del /q src\include\pg_config_ext.h
if exist src\include\pg_config_os.h del /q src\include\pg_config_os.h
if exist src\include\dynloader.h del /q src\include\dynloader.h
if %DIST%==1 if exist src\backend\parser\gram.h del /q src\backend\parser\gram.h
if exist src\include\utils\errcodes.h del /q src\include\utils\errcodes.h
if exist src\include\utils\fmgroids.h del /q src\include\utils\fmgroids.h
if exist src\include\utils\probes.h del /q src\include\utils\probes.h

if %DIST%==1 if exist src\backend\utils\fmgroids.h del /q src\backend\utils\fmgroids.h
if %DIST%==1 if exist src\backend\utils\fmgrtab.c del /q src\backend\utils\fmgrtab.c
if %DIST%==1 if exist src\backend\catalog\postgres.bki del /q src\backend\catalog\postgres.bki
if %DIST%==1 if exist src\backend\catalog\postgres.description del /q src\backend\catalog\postgres.description
if %DIST%==1 if exist src\backend\catalog\postgres.shdescription del /q src\backend\catalog\postgres.shdescription
if %DIST%==1 if exist src\backend\catalog\schemapg.h del /q src\backend\catalog\schemapg.h
if %DIST%==1 if exist src\backend\parser\scan.c del /q src\backend\parser\scan.c
if %DIST%==1 if exist src\backend\parser\gram.c del /q src\backend\parser\gram.c
if %DIST%==1 if exist src\backend\bootstrap\bootscanner.c del /q src\backend\bootstrap\bootscanner.c
if %DIST%==1 if exist src\backend\bootstrap\bootparse.c del /q src\backend\bootstrap\bootparse.c
if %DIST%==1 if exist src\backend\utils\misc\guc-file.c del /q src\backend\utils\misc\guc-file.c

if exist src\bin\psql\sql_help.h del /q src\bin\psql\sql_help.h

if exist src\interfaces\libpq\libpq.rc del /q src\interfaces\libpq\libpq.rc
if exist src\interfaces\libpq\libpqdll.def del /q src\interfaces\libpq\libpqdll.def
if exist src\interfaces\ecpg\compatlib\compatlib.def del /q src\interfaces\ecpg\compatlib\compatlib.def
if exist src\interfaces\ecpg\ecpglib\ecpglib.def del /q src\interfaces\ecpg\ecpglib\ecpglib.def
if exist src\interfaces\ecpg\include\ecpg_config.h del /q src\interfaces\ecpg\include\ecpg_config.h
if exist src\interfaces\ecpg\pgtypeslib\pgtypeslib.def del /q src\interfaces\ecpg\pgtypeslib\pgtypeslib.def
if %DIST%==1 if exist src\interfaces\ecpg\preproc\pgc.c del /q src\interfaces\ecpg\preproc\pgc.c
if %DIST%==1 if exist src\interfaces\ecpg\preproc\preproc.c del /q src\interfaces\ecpg\preproc\preproc.c
if %DIST%==1 if exist src\interfaces\ecpg\preproc\preproc.h del /q src\interfaces\ecpg\preproc\preproc.h

if exist src\port\pg_config_paths.h del /q src\port\pg_config_paths.h

if exist src\pl\plperl\spi.c del /q src\pl\plperl\spi.c
if %DIST%==1 if exist src\pl\plpgsql\src\pl_gram.c del /q src\pl\plpgsql\src\pl_gram.c
if %DIST%==1 if exist src\pl\plpgsql\src\pl_gram.h del /q src\pl\plpgsql\src\pl_gram.h

if %DIST%==1 if exist src\bin\psql\psqlscan.c del /q src\bin\psql\psqlscan.c

if %DIST%==1 if exist contrib\cube\cubescan.c del /q contrib\cube\cubescan.c
if %DIST%==1 if exist contrib\cube\cubeparse.c del /q contrib\cube\cubeparse.c
if %DIST%==1 if exist contrib\seg\segscan.c del /q contrib\seg\segscan.c
if %DIST%==1 if exist contrib\seg\segparse.c del /q contrib\seg\segparse.c

if exist src\test\regress\tmp_check rd /s /q src\test\regress\tmp_check
if exist contrib\spi\refint.dll del /q contrib\spi\refint.dll
if exist contrib\spi\autoinc.dll del /q contrib\spi\autoinc.dll
if exist src\test\regress\regress.dll del /q src\test\regress\regress.dll
if exist src\test\regress\refint.dll del /q src\test\regress\refint.dll
if exist src\test\regress\autoinc.dll del /q src\test\regress\autoinc.dll

if exist src\bin\initdb\tmp_check rd /s /q src\bin\initdb\tmp_check
if exist src\bin\pg_basebackup\tmp_check rd /s /q src\bin\pg_basebackup\tmp_check
if exist src\bin\pg_config\tmp_check rd /s /q src\bin\pg_config\tmp_check
if exist src\bin\pg_controldata\tmp_check rd /s /q src\bin\pg_controldata\tmp_check
if exist src\bin\pg_ctl\tmp_check rd /s /q src\bin\pg_ctl\tmp_check
if exist src\bin\scripts\tmp_check rd /s /q src\bin\scripts\tmp_check

REM Clean up datafiles built with contrib
REM cd contrib
REM for /r %%f in (*.sql) do if exist %%f.in del %%f

REM clean up files copied into contrib\pg_xlogdump
if exist contrib\pg_xlogdump\xlogreader.c del /q contrib\pg_xlogdump\xlogreader.c
for %%f in (contrib\pg_xlogdump\*desc.c) do if not %%f==contrib\pg_xlogdump\rmgrdesc.c del /q %%f

cd %D%

REM Clean up ecpg regression test files
msbuild /NoLogo ecpg_regression.proj /t:clean /v:q

goto :eof

MSVC: Clean tmp_check directory of pg_controldata test suite.

Back-patch to 9.4, where the suite was introduced.


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

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

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Xmx1024M
set GRADLE_OPTS='-Dorg.gradle.daemon=false'

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

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

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

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

goto fail

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

if exist "%JAVA_EXE%" goto init

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

goto fail

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

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

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

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

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

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

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

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

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

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

:omega

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

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

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Xmx1024M
set GRADLE_OPTS="-Dorg.gradle.daemon=false"

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

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

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

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

goto fail

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

if exist "%JAVA_EXE%" goto init

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

goto fail

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

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

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

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

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

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

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

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

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

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

:omega

Update GRADLE_OPTS to use " instead of '


@echo off
cd build-support
call set-nant-config-per-processor-architecture.cmd
cd ..
@echo .
@echo ..
@echo ...
@echo Running full Build Script, capturing output to buildlog.txt file...
@echo Start Time: %time%
build-support\tools\nant\bin\nant clean package -f:spring.build -D:project.build.sign=true -D:build-ems=true -D:test.integration.ems=false -D:test.integration.data=true -D:mstest.exe="c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\mstest.exe" -D:package.version=2.0.0 -D:nuget.version.suffix=RC1 -D:vs-net.mstest.bin.dir="c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" -D:skipmstestrun=true > buildlog.txt
@echo .
@echo ..
@echo ...
@echo Launching text file viewer to display buildlog.txt contents...
start "ignored but required placeholder window title argument" buildlog.txt
@echo .
@echo ..
@echo ...
@echo ************************
@echo Build Complete!
@echo ************************
@echo End Time: %time%
@echo

@echo off
cd build-support
call set-nant-config-per-processor-architecture.cmd
cd ..
@echo .
@echo ..
@echo ...
@echo Running full Build Script, capturing output to buildlog.txt file...
@echo Start Time: %time%
build-support\tools\nant\bin\nant clean package -f:spring.build -D:project.build.sign=true -D:build-ems=true -D:test.integration.ems=false -D:test.integration.data=true -D:mstest.exe="c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\mstest.exe" -D:package.version=2.0.0 -D:nuget.version.suffix=RC2 -D:vs-net.mstest.bin.dir="c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" -D:skipmstestrun=true > buildlog.txt
@echo .
@echo ..
@echo ...
@echo Launching text file viewer to display buildlog.txt contents...
start "ignored but required placeholder window title argument" buildlog.txt
@echo .
@echo ..
@echo ...
@echo ************************
@echo Build Complete!
@echo ************************
@echo End Time: %time%
@echo

update version suffix to reflect RC2

update version suffix to reflect RC2


call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
msbuild /v:m /m BuildAndTest.proj /p:CIBuild=true

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

Add a CI build script

Add a CI build script

Instances of vbcscompiler.exe may hang around for a few minutes after a
Jenkins run, locking files and causing new runs on the same system to
fail. To address this, we add a script to setup the environment, run the
build and test, and then kill any instances of vbcscompiler.exe that are
left around.


@echo off
title Dotfiles installation script

rem Start program ---------------------------------------------------------
:init
  set dotfiles=%~dp0
  set home=%USERPROFILE%\
  goto check_permissions

rem Check administrator permissions ---------------------------------------
:check_permissions
  echo Administrative permissions required. Detecting permissions...
  net session >nul 2>&1

  if %errorLevel% == 0 (
    echo Success: Administrative permissions confirmed.
    echo.

    goto link_vimp
  ) else (
    echo Requesting administrative privileges...
    goto UAC_prompt
  )

rem Show admin prompt -----------------------------------------------------
:UAC_prompt
  echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  set params=%~1
  echo UAC.ShellExecute "%~s0", "%params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

  "%temp%\getadmin.vbs" >nul
  if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
  exit /B

rem Link vimperator files -------------------------------------------------
:link_vimp
  echo Linking vimperator files...
  echo.

  if exist %home%vimperator (
    echo vimperator folder already exists. Skipping to next file.
  ) else (
    mklink /D %home%vimperator %dotfiles%vimperator
  )
  if exist %home%_vimperatorrc (
    echo _vimperatorrc file already exists. Skipping to next file.
  ) else (
    mklink %home%_vimperatorrc %dotfiles%vimperator\vimperatorrc
  )

rem Link vim files --------------------------------------------------------
:link_vim
  echo Linking vim files...
  echo.

  if exist %home%vimfiles (
    echo vimfiles folder already exists. Skipping to next file.
  ) else (
    mklink /D %home%vimfiles %dotfiles%vim
  )

rem Install vim bundles ---------------------------------------------------
:install_bundles
  if not exist %dotfiles%vim\bundle\vundle (
    git clone http://github.com/gmarik/vundle.git "%dotfiles%vim\bundle\vundle"
  )
  gvim +BundleInstall +qall

rem End script ------------------------------------------------------------
:end
  echo.
  echo Setup complete.

rem vim: foldmethod=indent

@echo off
title Dotfiles installation script

rem Check admin {{{
  net session >nul 2>&1
  if %errorlevel% == 0 (
    goto continue
  ) else (
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params=%~1
    echo UAC.ShellExecute "%~s0", "%params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs" >nul
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    exit /B
  )

:continue
rem Set variables
  set home=%userprofile%
  set dotfiles=%home%\dotfiles

rem Clone/update repository
  if not exist %dotfiles% (
    git clone http://github.com/Tunous/dotfiles.git "%dotfiles%"
  ) else (
    cd "%dotfiles%"
    git pull
  )

rem Link files
  mklink /d "%home%\vimperator"    "%dotfiles%\vimperator"
  mklink    "%home%\_vimperatorrc" "%dotfiles%\vimperator\vimperatorrc"
  mklink /d "%home%\vimfiles"      "%dotfiles%\vim"

rem Clone vundle repository
  if not exist "%dotfiles%\vim\bundle" (
    mkdir "%dotfiles%\vim\bundle"
  )
  if not exist "%dotfiles%\vim\bundle\vundle" (
    git clone http://github.com/gmarik/vundle.git "%dotfiles%\bundle\vundle"
  )

rem Update vim bundles
  gvim +BundleInstall! +BundleClean +qall

rem vim: foldmethod=indent

Simplify installation script

Simplify installation script

Removed some useless stuff and added repository/bundles updating.


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

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

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

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

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

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

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

goto fail

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

if exist "%JAVA_EXE%" goto init

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

goto fail

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

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

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

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

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

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

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

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

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

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

:omega

add gradlew

add gradlew


@echo off

SET MSBUILD=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
SET OUTPUT=..\Binaries
SET PARAMS=/consoleloggerparameters:ErrorsOnly /m

dotnet restore AM.Core\project.json
dotnet restore ManagedClient\project.json

"%MSBUILD%" AM.Core\AM.Core.NetCore.xproj /target:ReBuild /property:Configuration=Debug   /property:OutputPath=%OUTPUT%\DebugCore  /p:DefineConstants="NETCORE"
rem "%MSBUILD%" ManagedIrbis\ManagedIrbis.NetCore.xproj /target:ReBuild /property:Configuration=Debug   /property:OutputPath=%OUTPUT%\DebugCore /p:DefineConstants="NETCORE"

"%MSBUILD%" AM.Core\AM.Core.NetCore.xproj /target:ReBuild /property:Configuration=Release /property:OutputPath=%OUTPUT%\ReleaseCore /p:DefineConstants="NETCORE"
rem "%MSBUILD%" ManagedIrbis\ManagedIrbis.NetCore.xproj /target:ReBuild /property:Configuration=Release /property:OutputPath=%OUTPUT%\ReleaseCore /p:DefineConstants="NETCORE"

@echo off

SET MSBUILD=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
SET OUTPUT=..\Binaries
SET PARAMS=/consoleloggerparameters:ErrorsOnly /m

dotnet restore AM.Core\project.json
dotnet restore ManagedIrbis\project.json

"%MSBUILD%" AM.Core\AM.Core.NetCore.xproj /target:ReBuild /property:Configuration=Debug   /property:OutputPath=%OUTPUT%\DebugCore  /p:DefineConstants="NETCORE"
rem "%MSBUILD%" ManagedIrbis\ManagedIrbis.NetCore.xproj /target:ReBuild /property:Configuration=Debug   /property:OutputPath=%OUTPUT%\DebugCore /p:DefineConstants="NETCORE"

"%MSBUILD%" AM.Core\AM.Core.NetCore.xproj /target:ReBuild /property:Configuration=Release /property:OutputPath=%OUTPUT%\ReleaseCore /p:DefineConstants="NETCORE"
rem "%MSBUILD%" ManagedIrbis\ManagedIrbis.NetCore.xproj /target:ReBuild /property:Configuration=Release /property:OutputPath=%OUTPUT%\ReleaseCore /p:DefineConstants="NETCORE"

Fix compilecore.cmd

Fix compilecore.cmd


@echo off

cd %APPVEYOR_BUILD_FOLDER%

:: =========================================================
:: Set some defaults. Infer some variables.
::
:: These are set globally
if "%LUA_VER%" NEQ "" (
	set LUA=lua
	set LUA_SHORTV=%LUA_VER:~0,3%
) else (
	set LUA=luajit
	set LJ_SHORTV=%LJ_VER:~0,3%
	set LUA_SHORTV=5.1
)

:: defines LUA_DIR so Cmake can find this Lua install
if "%LUA%"=="luajit" (
	set LUA_DIR=c:\lua\%platform%\lj%LJ_SHORTV%
) else (
	set LUA_DIR=c:\lua\%platform%\%LUA_VER%
)

:: Now we declare a scope
Setlocal EnableDelayedExpansion EnableExtensions

set LUAROCKS_SHORTV=%LUAROCKS_VER:~0,3%

if not defined LUAROCKS_URL set LUAROCKS_URL=http://keplerproject.github.io/luarocks/releases
if not defined LUAROCKS_REPO set LUAROCKS_REPO=http://rocks.moonscript.org
if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp
if defined NOCOMPAT (
	set COMPATFLAG=--nocompat
) else (
	set COMPATFLAG=
)
if not defined LUAJIT_GIT_REPO set LUAJIT_GIT_REPO=http://luajit.org/git/luajit-2.0.git
if not defined LUAJIT_URL set LUAJIT_URL=http://luajit.org/download

if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external
if not defined LUAROCKS_INSTALL set LUAROCKS_INSTALL=%LUA_DIR%\LuaRocks
if not defined LR_ROOT set LR_ROOT=%LUAROCKS_INSTALL%\%LUAROCKS_SHORTV%
if not defined LR_SYSTREE set LR_SYSTREE=%LUAROCKS_INSTALL%\systree

if not defined SEVENZIP set SEVENZIP=7z
::
:: =========================================================

:: first create some necessary directories:
mkdir downloads 2>NUL

:: Download and compile Lua (or LuaJIT)
if "%LUA%"=="luajit" (
	if not exist %LUA_DIR% (
		if "%LJ_SHORTV%"=="2.1" (
			:: Clone repository and checkout 2.1 branch
			set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
			if not exist !lj_source_folder! (
				echo Cloning git repo %LUAJIT_GIT_REPO% !lj_source_folder!
				git clone %LUAJIT_GIT_REPO% !lj_source_folder! || call :die "Failed to clone repository"
			)
			cd !lj_source_folder!\src
			git checkout v2.1 || call :die
		) else (
			set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
			if not exist !lj_source_folder! (
				echo Downloading... %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz
				curl --silent --fail --max-time 120 --connect-timeout 30 %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
			)
			cd !lj_source_folder!\src
		)
		:: Compiles LuaJIT
		call msvcbuild.bat

		mkdir %LUA_DIR% 2> NUL
		for %%a in (bin bin\lua bin\lua\jit include lib) do ( mkdir "%LUA_DIR%\%%a" )

		for %%a in (luajit.exe lua51.dll) do ( move "!lj_source_folder!\src\%%a" "%LUA_DIR%\bin" )
		copy "%LUA_DIR%\bin\luajit.exe" "%LUA_DIR%\bin\lua.exe"

		move "!lj_source_folder!\src\lua51.lib" "%LUA_DIR%\lib"
		for %%a in (lauxlib.h lua.h lua.hpp luaconf.h lualib.h luajit.h) do (
			copy "!lj_source_folder!\src\%%a" "%LUA_DIR%\include"
		)

		copy "!lj_source_folder!\src\jit\*.lua" "%LUA_DIR%\bin\lua\jit"

	) else (
		echo LuaJIT %LJ_VER% already installed at %LUA_DIR%
	)
) else (
	if not exist %LUA_DIR% (
		:: Download and compile Lua
		if not exist downloads\lua-%LUA_VER% (
			curl --silent --fail --max-time 120 --connect-timeout 30 %LUA_URL%/lua-%LUA_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
		)

		mkdir downloads\lua-%LUA_VER%\etc 2> NUL
		if not exist downloads\lua-%LUA_VER%\etc\winmake.bat (
			curl --silent --location --insecure --fail --max-time 120 --connect-timeout 30 https://github.com/Tieske/luawinmake/archive/master.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% e -si -ttar -aoa -odownloads\lua-%LUA_VER%\etc luawinmake-master\etc\winmake.bat
		)

		cd downloads\lua-%LUA_VER%
		call etc\winmake %COMPATFLAG%
		call etc\winmake install %LUA_DIR%
	) else (
		echo Lua %LUA_VER% already installed at %LUA_DIR%
	)
)

if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_DIR%\bin\%LUA%.exe"

set PATH=%LUA_DIR%\bin;%PATH%
call !LUA! -v

:: =========================================================
:: LuaRocks
:: =========================================================

if not exist "%LR_ROOT%" (
	:: Downloads and installs LuaRocks
	cd %APPVEYOR_BUILD_FOLDER%

	if not exist downloads\luarocks-%LUAROCKS_VER%-win32.zip (
		echo Downloading LuaRocks...
		curl --silent --fail --max-time 120 --connect-timeout 30 --output downloads\luarocks-%LUAROCKS_VER%-win32.zip %LUAROCKS_URL%/luarocks-%LUAROCKS_VER%-win32.zip
		%SEVENZIP% x -aoa -odownloads downloads\luarocks-%LUAROCKS_VER%-win32.zip
	)

	cd downloads\luarocks-%LUAROCKS_VER%-win32
	call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LUAROCKS_INSTALL%" /TREE "%LR_SYSTREE%"
)

if not exist "%LR_ROOT%" call :die "LuaRocks not found at %LR_ROOT%"

set PATH=%LR_ROOT%;%LR_SYSTREE%\bin;%PATH%

:: Lua will use just the system rocks
set LUA_PATH=%LR_ROOT%\lua\?.lua;%LR_ROOT%\lua\?\init.lua
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?.lua
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?\init.lua
set LUA_CPATH=%LR_SYSTREE%\lib\lua\%LUA_SHORTV%\?.dll

call luarocks --version || call :die "Error with LuaRocks installation"
call luarocks list

if not exist "%LR_EXTERNAL%" (
	mkdir "%LR_EXTERNAL%"
	mkdir "%LR_EXTERNAL%\lib"
	mkdir "%LR_EXTERNAL%\include"
)

set PATH=%LR_EXTERNAL%;%PATH%

:: Exports the following variables:
:: (beware of whitespace between & and ^ below)
endlocal & set PATH=%PATH%&^
set LR_SYSTREE=%LR_SYSTREE%&^
set LUA_PATH=%LUA_PATH%&^
set LUA_CPATH=%LUA_CPATH%&^
set LR_EXTERNAL=%LR_EXTERNAL%

echo.
echo ======================================================
if "%LUA%"=="luajit" (
	echo Installation of LuaJIT %LJ_VER% and LuaRocks %LUAROCKS_VER% done.
) else (
	echo Installation of Lua %LUA_VER% and LuaRocks %LUAROCKS_VER% done.
	if defined NOCOMPAT echo Lua was built with compatibility flags disabled.
)
echo Platform         - %platform%
echo LUA              - %LUA%
echo LUA_SHORTV       - %LUA_SHORTV%
echo LJ_SHORTV        - %LJ_SHORTV%
echo LUA_PATH         - %LUA_PATH%
echo LUA_CPATH        - %LUA_CPATH%
echo.
echo LR_EXTERNAL      - %LR_EXTERNAL%
echo ======================================================
echo.

goto :eof

:: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'"
:: then try adding or removing blank lines lines above.
:: Yes, really.
:: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e

:: helper functions:

:: for bailing out when an error occurred
:die %1
echo %1
exit /B 1
goto :eof

remove trailing whitespaces and tabs

remove trailing whitespaces and tabs


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

:: Accepts one argument, the system's architecture (amd64 or i386).

@echo off

set DEVICE_NAME=outline-tap0

:: Check whether the device already exists.
netsh interface show interface name=%DEVICE_NAME% >nul
if %errorlevel% equ 0 (
  echo %DEVICE_NAME% already exists.
  exit /b
)

:: Add the device, recording the names of devices before and after to help
:: us find the name of the new device.
::
:: Note:
::  - While we could limit the search to devices having ServiceName=tap0901,
::    that will cause wmic to output just "no instances available" when there
::    are no other TAP devices present, messing up the diff.
::  - We do not use findstr, etc., to strip blank lines because those ancient tools
::    typically don't understand/output non-Latin characters (wmic *does*, even on
::    Windows 7).
set BEFORE_DEVICES=%tmp%\outlineinstaller-tap-devices-before.txt
set AFTER_DEVICES=%tmp%\outlineinstaller-tap-devices-after.txt

echo Storing current network device list...
wmic nic get netconnectionid /format:list > %BEFORE_DEVICES%
type %BEFORE_DEVICES%

echo Creating TAP network device...
tap-windows6\%1\tapinstall install tap-windows6\%1\OemVista.inf tap0901
if %errorlevel% neq 0 (
  echo Could not create TAP network device. >&2
  exit /b 1
)
echo Storing new network device list...
wmic nic get netconnectionid /format:list > %AFTER_DEVICES%
type %AFTER_DEVICES%

:: Find the name of the new device and rename it.
::
:: Obviously, this command is a beast; roughly what it does, in this order, is:
::  - perform a diff on the before and after text files
::  - split the left column, InputObject, on the equals (=) sign
::  - remove leading/trailing space and blank lines with trim()
::  - store the result in NEW_DEVICE
::  - print NEW_DEVICE, for debugging (though non-Latin characters may appear as ?)
::  - invoke netsh
::
:: Running all this in one go helps reduce the need to deal with temporary
:: files and the character encoding headaches that follow.
::
:: Note that we pipe input from /dev/null to prevent Powershell hanging forever
:: waiting on EOF.
echo Searching for new TAP network device name...
powershell "(compare-object (cat %BEFORE_DEVICES%) (cat %AFTER_DEVICES%) | format-wide -autosize InputObject | out-string).split(\"=\")[1].trim() | set-variable NEW_DEVICE; write-host \"New TAP device name: ${NEW_DEVICE}\"; netsh interface set interface name = \"${NEW_DEVICE}\" newname = \"%DEVICE_NAME%\"" <nul
if %errorlevel% neq 0 (
  echo Could not rename find or rename new TAP network device. >&2
  exit /b 1
)

echo Configuring new TAP network device...

:: Give the device an IP address.
:: 10.0.85.x is a guess which we hope will work for most users (Docker for
:: Windows uses 10.0.75.x by default): if the address is already in use the
:: script will fail and the installer will show an error message to the user.
:: TODO: Actually search the system for an unused subnet or make the subnet
::       configurable in the Outline client.
netsh interface ip set address %DEVICE_NAME% static 10.0.85.2 255.255.255.0
if %errorlevel% neq 0 (
  echo Could not set TAP network device subnet. >&2
  exit /b 1
)

:: Windows has no system-wide DNS server; each network device can have its
:: "own" set of DNS servers. Windows seems to use the DNS server(s) of the
:: network device associated with the default gateway. This is good for us
:: as it means we do not have to modify the DNS settings of any other network
:: device in the system. Configure with OpenDNS and Dyn resolvers.
netsh interface ip set dnsservers %DEVICE_NAME% static address=208.67.222.222
if %errorlevel% neq 0 (
  echo Could not configure TAP device primary DNS. >&2
  exit /b 1
)
netsh interface ip add dnsservers %DEVICE_NAME% 216.146.35.35 index=2
if %errorlevel% neq 0 (
  echo Could not configure TAP device secondary DNS. >&2
  exit /b 1
)

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

:: Accepts one argument, the system's architecture (amd64 or i386).

@echo off

set DEVICE_NAME=outline-tap0

:: Check whether the device already exists.
netsh interface show interface name=%DEVICE_NAME% >nul
if %errorlevel% equ 0 (
  echo %DEVICE_NAME% already exists.
  exit /b
)

:: Add the device, recording the names of devices before and after to help
:: us find the name of the new device.
::
:: Note:
::  - While we could limit the search to devices having ServiceName=tap0901,
::    that will cause wmic to output just "no instances available" when there
::    are no other TAP devices present, messing up the diff.
::  - We do not use findstr, etc., to strip blank lines because those ancient tools
::    typically don't understand/output non-Latin characters (wmic *does*, even on
::    Windows 7).
set BEFORE_DEVICES=%tmp%\outlineinstaller-tap-devices-before.txt
set AFTER_DEVICES=%tmp%\outlineinstaller-tap-devices-after.txt

echo Storing current network device list...
wmic nic where "netconnectionid like '%%'" get netconnectionid /format:list > %BEFORE_DEVICES%
type %BEFORE_DEVICES%

echo Creating TAP network device...
tap-windows6\%1\tapinstall install tap-windows6\%1\OemVista.inf tap0901
if %errorlevel% neq 0 (
  echo Could not create TAP network device. >&2
  exit /b 1
)
echo Storing new network device list...
wmic nic where "netconnectionid like '%%'" get netconnectionid /format:list > %AFTER_DEVICES%
type %AFTER_DEVICES%

:: Find the name of the new device and rename it.
::
:: Obviously, this command is a beast; roughly what it does, in this order, is:
::  - perform a diff on the before and after text files
::  - split the left column, InputObject, on the equals (=) sign
::  - remove leading/trailing space and blank lines with trim()
::  - store the result in NEW_DEVICE
::  - print NEW_DEVICE, for debugging (though non-Latin characters may appear as ?)
::  - invoke netsh
::
:: Running all this in one go helps reduce the need to deal with temporary
:: files and the character encoding headaches that follow.
::
:: Note that we pipe input from /dev/null to prevent Powershell hanging forever
:: waiting on EOF.
echo Searching for new TAP network device name...
powershell "(compare-object (cat %BEFORE_DEVICES%) (cat %AFTER_DEVICES%) | format-wide -autosize InputObject | out-string).split(\"=\")[1].trim() | set-variable NEW_DEVICE; write-host \"New TAP device name: ${NEW_DEVICE}\"; netsh interface set interface name = \"${NEW_DEVICE}\" newname = \"%DEVICE_NAME%\"" <nul
if %errorlevel% neq 0 (
  echo Could not rename find or rename new TAP network device. >&2
  exit /b 1
)

echo Configuring new TAP network device...

:: Give the device an IP address.
:: 10.0.85.x is a guess which we hope will work for most users (Docker for
:: Windows uses 10.0.75.x by default): if the address is already in use the
:: script will fail and the installer will show an error message to the user.
:: TODO: Actually search the system for an unused subnet or make the subnet
::       configurable in the Outline client.
netsh interface ip set address %DEVICE_NAME% static 10.0.85.2 255.255.255.0
if %errorlevel% neq 0 (
  echo Could not set TAP network device subnet. >&2
  exit /b 1
)

:: Windows has no system-wide DNS server; each network device can have its
:: "own" set of DNS servers. Windows seems to use the DNS server(s) of the
:: network device associated with the default gateway. This is good for us
:: as it means we do not have to modify the DNS settings of any other network
:: device in the system. Configure with OpenDNS and Dyn resolvers.
netsh interface ip set dnsservers %DEVICE_NAME% static address=208.67.222.222
if %errorlevel% neq 0 (
  echo Could not configure TAP device primary DNS. >&2
  exit /b 1
)
netsh interface ip add dnsservers %DEVICE_NAME% 216.146.35.35 index=2
if %errorlevel% neq 0 (
  echo Could not configure TAP device secondary DNS. >&2
  exit /b 1
)

remove empty NetConnectionID

remove empty NetConnectionID


::THIS FILE IS BEING UNTRACKED FROM GIT with the command: git update-index --skip-worktree <file>
::To resume the tracking of changes to this file use the command: git update-index --no-skip-worktree <file>

::Set the path below as you need and then run this bat to copy the files and make them debuggeable
SET KSPPATH=C:\work\builds\Kerbal Space Program
::Set another path in case you run two KSP instances otherwise leave empty
SET KSPPATH2=C:\work\builds\Kerbal Space Program2

Check in the directories that I need to use.


@echo off
hid_bootloader_loader.exe atmega32u4 ..\compiled\board\opendeck\v1.2.1\fw_opendeck.hex

add windows script for easier dfu for hid btldr


:: Copyright (c) 2011 The Native Client Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.

setlocal
set "PATH=c:\cygwin\bin;%PATH%"
bash -c "buildbot/buildbot_toolchain_arm_untrusted.sh %*"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
endlocal

:: Copyright (c) 2012 The Native Client Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.

setlocal
set "PATH=c:\cygwin\bin;%PATH%"
bash -c "buildbot/buildbot_pnacl.sh %*"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
endlocal

Fix pnacl's windows tc builder script invocation.
Review URL: https://chromiumcodereview.appspot.com/10443126

git-svn-id: 721b910a23eff8a86f00c8fd261a7587cddf18f8@8779 fcba33aa-ac0c-11dd-b9e7-8d5594d729c2


REM see README.txt
REM SET UP ENVIRONMENT VARIABLES

set KDBCODE=%cd%\code
set KDBCONFIG=%cd%\config
set KDBLOG=%cd%\logs
set KDBHTML=%cd%\html
set KDBLIB=%cd%\lib

set KDBBASEPORT=6000

set PATH=%PATH%;%KDBLIB%\w32

REM to kill it, run this:
start "kill" q torq.q -load code/processes/kill.q -proctype kill -procname killtick -.servers.CONNECTIONS rdb wdb tickerplant chainedtp hdb gateway housekeeping monitor discovery sort reporter compression feed

REM see README.txt
REM SET UP ENVIRONMENT VARIABLES

set TORQHOME=%cd%
set KDBCODE=%TORQHOME%\code
set KDBCONFIG=%TORQHOME%\config
set KDBLOG=%TORQHOME%\logs
set KDBHTML=%TORQHOME%\html
set KDBLIB=%TORQHOME%\lib
set KDBBASEPORT=6000
set KDBHDB=%TORQHOME%/hdb/database

REM App specific configuration directory
set KDBAPPCONFIG=%TORQHOME%\appconfig

set KDBBASEPORT=6000

set PATH=%PATH%;%KDBLIB%\w32

REM to kill it, run this:
start "kill" q torq.q -load code/processes/kill.q -proctype kill -procname killtick -.servers.CONNECTIONS rdb wdb tickerplant chainedtp hdb gateway housekeeping monitor discovery sort reporter compression feed

Change environment variables in stop.bat file.


:: Purpose:       DHCP server Watchdog & Failover script. Read notes below
:: Requirements:  1. Domain administrator credentials & "Logon as a batch job" rights
::                2. Proper firewall configuration to allow connection
::                3. Proper permissions on the DHCP backup directory
:: Author:        vocatus on reddit.com/r/sysadmin ( vocatus.gate@gmail.com ) // PGP key ID: 0x82A211A2
:: Version:       1.3a * Minor header update; Variables now above prep and checks
::                1.3  * Overhauled Date/Time conversion so we can handle ALL versions of Windows using ANY local date-time format
::                1.2c * Reworked CUR_DATE variable to handle more than one Date/Time format
::                1.2b + Added comment block explaining syntax rules for variables
::                1.2  + Added functionality to recover the DHCP database BACK to the primary server after a failure. Now when the backup server detects that
::                       the primary server has come back online after an outage, it will export its current copy of the DHCP database, upload it back to the
::                       primary server, import it, and spin it back up using the most recent copy. This addresses the issue of new leases being passed out during
::                       an outage of the primary server and it not being aware of those leases when it comes back online.
::                     + Added "REMOTE_OPERATIING_PATH" variable that lets us specify where the remote server keeps its DHCP working files during operation
::                     + Added "UPDATED" variable to note when the script was last updated
::                1.1c + Added quotes around all variables that could contain paths
::                     + Added full path to SC.exe to prevent failure in the event %PATH% gets corrupted or mangled (this happened in testing)
::                     * Fixed a glitch that could occur when pinging an assumed-down primary server that would incorrectly think it was back up
::                     - Removed almost every entry of "2>&1" since it's really not needed
::                1.1b - Changed DATE to CUR_DATE format to be consistent with all other scripts
::                1.1  - Comments improvement
::                     / Tuned some parameters (ping count on checking)
::                     / Some logging tweaks
::                     / Renamed FAILOVER_DELAY to FAILOVER_RECHECK_DELAY for clarity
::                1.0d * Some logging tweaks
::                1.0c * Some logging tweaks
::                1.0 Initial write
:: Notes:         I wrote this script after failing to find a satisfactory method of performing
::                watchdog/failover between two Windows Server 2008 R2 DHCP servers.
::
:: Use:           This script has two modes: "Watchdog" and "Failover."
::                - Watchdog checks the status of the remote DHCP service, logs it, and then grabs the remote DHCP db backup file and imports it.
::                - Failover mode is activated when the script cannot determine the status of the remote DHCP server. The script then activates
::                  the local DHCP server with the latest backup copy it successfully retrieved from the primary server.
::
:: Instructions:  1. Tune the variables in this script to your desired backup location and frequency
::                2. On the primary server: set the DHCP backup interval to your desired backup frequency. The value is in minutes; I recommend 5 minutes.
::                   You do this by modifying this registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DHCPServer\Parameters\BackupInterval
::                3. On the backup server:  set this script to run as a scheduled task. I recommend every 10 minutes.
:: Notice:
::               !! Make sure to set it only to run if it isn't already running! If there is a failover you could have
::                  Task Scheduler spawn a new instance of the script every n minutes and end up with hundreds of copies
::                  of this script running.
SETLOCAL

:::::::::::::::
:: VARIABLES :: -------------- These are the defaults. Change them if you so desire. --------- ::
:::::::::::::::
:: Rules for variables:
::  * NO quotes!                       (bad:  "c:\directory\path"       )
::  * NO trailing slashes on the path! (bad:   c:\directory\            )
::  * Spaces are okay                  (okay:  c:\my folder\with spaces )
::  * Network paths are okay           (okay:  \\server\share name      )
::                                     (       \\172.16.1.5\share name  )
:: Remote server is the PRIMARY DHCP server we're watching. Use a hostname or IP address.
set REMOTE_SERVER=SERVER-NAME

:: Location of the automatic DHCP backup file on the primary server. Windows generates this automatically.
:: Best practice is to leave this alone, unless you have a custom backup location.
:: The script builds the backup line like this: \\%REMOTE_SERVER%\c$\%REMOTE_BACKUP_PATH%
set REMOTE_BACKUP_PATH=Windows\system32\dhcp\backup

:: Location of the operational DHCP database files on the remote (primary) server.
:: Best practice is to leave this alone, unless you have a custom location. Changing this will break the
:: function that re-uploads the most current db back to the primary server after a failure. This doesn't
:: ruin the script, but if the backup server passed out any IP's while the primary server was down, the
:: primary server won't know about them when it comes back up.
set REMOTE_OPERATING_PATH=Windows\system32\dhcp

:: Location of your backup/standby file. I normally copy directly to my backup server's DHCP directory.
:: The script builds the local backup line like this: c:\windows\system32\dhcp\[backup folders]
set LOCAL_BACKUP_PATH=%SystemRoot%\system32\dhcp

:: When a failover is triggered, how many seconds should we wait in between each attempt to contact the primary server again?
set FAILOVER_RECHECK_DELAY=10

:: Log options. Don't put an extension on the log file name. (Important!) The script sets this later on.
set LOGPATH=%SystemDrive%\Logs
set LOGFILE=%COMPUTERNAME%_DHCP_watchdog

:: Max log file size allowed (in bytes) before rotation and archive. I recommend setting this to 2 MB (2097152).
:: Example: 524288 is half a megabyte (~500KB)
set LOG_MAX_SIZE=10485760

:: --------------------------- Don't edit anything below this line --------------------------- ::

:::::::::::::::::::::
:: PREP AND CHECKS ::
:::::::::::::::::::::
@echo off
cls
set VERSION=1.3a
set UPDATED=2014-09-08
:: Get the date into ISO 8601 standard date format (yyyy-mm-dd) so we can use it
FOR /f %%a in ('WMIC OS GET LocalDateTime ^| find "."') DO set DTS=%%a
set CUR_DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%
title [DHCP Server Watchdog v%VERSION%]

:::::::::::::::::::::::
:: LOG FILE HANDLING :: - This section handles the log file
:::::::::::::::::::::::
:: Make the logfile if it doesn't exist
if not exist %LOGPATH% mkdir %LOGPATH%
if not exist %LOGPATH%\%LOGFILE%.log goto new_log

:: Check log size. If it hasn't exceeded our size limit, jump straight to Watchdog mode
for %%R in (%LOGPATH%\%LOGFILE%.log) do if %%~zR LSS %LOG_MAX_SIZE% goto newrun

:: However, if the log was too big, go ahead and rotate it.
pushd %LOGPATH%
del %LOGFILE%.ancient 2>NUL
rename %LOGFILE%.oldest %LOGFILE%.ancient 2>NUL
rename %LOGFILE%.older %LOGFILE%.oldest 2>NUL
rename %LOGFILE%.old %LOGFILE%.older 2>NUL
rename %LOGFILE%.log %LOGFILE%.old 2>NUL
popd

:: And then create the header for the new log file
:new_log
echo ------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%.log
echo  Initializing new DHCP Server Watchdog log on %CUR_DATE% at %TIME%, max log size %LOG_MAX_SIZE% bytes>> %LOGPATH%\%LOGFILE%.log
echo ------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%.log
echo.>> %LOGPATH%\%LOGFILE%.log

:: New run section - if we just launched the script, write a header for this run
:newrun
echo ------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%.log
echo  DHCP Server Watchdog v%VERSION%, %CUR_DATE%>> %LOGPATH%\%LOGFILE%.log
echo   Running as %USERDOMAIN%\%USERNAME% on %COMPUTERNAME%>> %LOGPATH%\%LOGFILE%.log
echo.>> %LOGPATH%\%LOGFILE%.log
echo  Job Options>> %LOGPATH%\%LOGFILE%.log
echo   Log location:            %LOGPATH%\%LOGFILE%.log>> %LOGPATH%\%LOGFILE%.log
echo   Log max size:            %LOG_MAX_SIZE% bytes>> %LOGPATH%\%LOGFILE%.log
echo   Watching primary server: %REMOTE_SERVER%>> %LOGPATH%\%LOGFILE%.log
echo   Mirroring this DHCP db:  %REMOTE_BACKUP_PATH%>> %LOGPATH%\%LOGFILE%.log
echo   Local backup location:   %LOCAL_BACKUP_PATH%>> %LOGPATH%\%LOGFILE%.log
echo ------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Starting Watchdog mode.>> %LOGPATH%\%LOGFILE%.log
echo.
echo  DHCP Server Watchdog v%VERSION%
echo   Running as: %USERDOMAIN%\%USERNAME% on %COMPUTERNAME%
echo   Log:        %LOGPATH%\%LOGFILE%.log

:::::::::::::::::::
:: WATCHDOG MODE ::
:::::::::::::::::::
:watchdog

:: Ping the server to see if it's up
echo.
echo   Verifying proper operation of DHCP server on %REMOTE_SERVER%, please wait...
echo.
echo %CUR_DATE% %TIME%         Pinging %REMOTE_SERVER%...>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Pinging %REMOTE_SERVER%...
ping %REMOTE_SERVER% -n %FAILOVER_RECHECK_DELAY% >NUL
if %ERRORLEVEL%==1 echo %CUR_DATE% %TIME% WARNING %REMOTE_SERVER% failed to respond to ping. && echo %CUR_DATE% %TIME% WARNING %REMOTE_SERVER% failed to respond to ping.>> %LOGPATH%\%LOGFILE%.log
if not %ERRORLEVEL%==1 echo %CUR_DATE% %TIME% SUCCESS %REMOTE_SERVER% responded to ping. && echo %CUR_DATE% %TIME% SUCCESS %REMOTE_SERVER% responded to ping.>> %LOGPATH%\%LOGFILE%.log

:: Check & Log
echo %CUR_DATE% %TIME%         Checking DHCP server status on %REMOTE_SERVER%...>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Checking DHCP server status on %REMOTE_SERVER%...

:: Reset ERRORLEVEL back to 0
ver > NUL

:: Use "SC" to check the status of "Dhcpserver" service, find the "RUNNING" state, and act accordingly based on the return code
%WINDIR%\System32\sc.exe \\%REMOTE_SERVER% query Dhcpserver | find "RUNNING" >NUL
if %ERRORLEVEL%==0 echo %CUR_DATE% %TIME% SUCCESS The DHCP service is running on %REMOTE_SERVER%.>> %LOGPATH%\%LOGFILE%.log
if %ERRORLEVEL%==0 echo %CUR_DATE% %TIME% SUCCESS The DHCP service is running on %REMOTE_SERVER%.

:: This section only executes if the test failed.
if not %ERRORLEVEL%==0 (
	echo %CUR_DATE% %TIME% FAILURE The DHCP service is not running on %REMOTE_SERVER%.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME%         Activating failover procedure. Local DHCP server will be initialized using most recent successful backup.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME% FAILURE The DHCP service is not running on %REMOTE_SERVER%.
	echo %CUR_DATE% %TIME%         Activating failover procedure. Local DHCP server will be initialized using most recent successful backup.
	goto failover
	)

:: Reset ERRORLEVEL back to 0
ver > NUL

:: Fetch
echo %CUR_DATE% %TIME%         Fetching DHCP database backup from %REMOTE_SERVER%...>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Fetching DHCP database backup from %REMOTE_SERVER%...
xcopy "\\%REMOTE_SERVER%\c$\%REMOTE_BACKUP_PATH%\*" "%LOCAL_BACKUP_PATH%\backup_new_pending\" /E /Y /Q >NUL

:: If the copy SUCCEEDED, this executes
if %ERRORLEVEL%==0 (
	echo %CUR_DATE% %TIME% SUCCESS Backup fetched from %REMOTE_SERVER%.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME% SUCCESS Backup fetched from %REMOTE_SERVER%.
	echo %CUR_DATE% %TIME%         Rotating database backups...>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME%         Rotating database backups...
	:: Rotate backups and use newest copy
	rmdir /S /Q %LOCAL_BACKUP_PATH%\backup5
	if exist "%LOCAL_BACKUP_PATH%\backup4" move /Y "%LOCAL_BACKUP_PATH%\backup4" "%LOCAL_BACKUP_PATH%\backup5"
	if exist "%LOCAL_BACKUP_PATH%\backup3" move /Y "%LOCAL_BACKUP_PATH%\backup3" "%LOCAL_BACKUP_PATH%\backup4"
	if exist "%LOCAL_BACKUP_PATH%\backup2" move /Y "%LOCAL_BACKUP_PATH%\backup2" "%LOCAL_BACKUP_PATH%\backup3"
	if exist "%LOCAL_BACKUP_PATH%\backup" move /Y "%LOCAL_BACKUP_PATH%\backup" "%LOCAL_BACKUP_PATH%\backup2"
	move /Y "%LOCAL_BACKUP_PATH%\backup_new_pending" "%LOCAL_BACKUP_PATH%\backup" >NUL
	echo %CUR_DATE% %TIME%         Database backups rotated.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME%         Database backups rotated.
	)

:: If the copy FAILED, this executes:
if not %ERRORLEVEL%==0 (
	echo %CUR_DATE% %TIME% WARNING There was an error copying the backup from %REMOTE_SERVER%.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME%         You may want to look into this since we were able to check the DHCPserver service status but the file copy failed.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME%         Skipping new database import due to copy failure.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME%         Job complete with errors.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME% WARNING There was an error copying the backup from %REMOTE_SERVER%.
	echo %CUR_DATE% %TIME%         You may want to look into this since we were able to check the DHCPserver service status but the file copy failed.
	echo %CUR_DATE% %TIME%         Skipping new database import due to copy failure.
	echo %CUR_DATE% %TIME%         Job complete with errors.
	)

:: Import database
echo %CUR_DATE% %TIME%         Starting local DHCP server to import new database...>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Starting local DHCP server to import new database...
	net start Dhcpserver
echo %CUR_DATE% %TIME%         Local DHCP server running. Performing import...>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Local DHCP server running. Performing import...
	netsh dhcp server restore "%LOCAL_BACKUP_PATH%\backup"
echo %CUR_DATE% %TIME%         Import complete.>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Import complete.
echo %CUR_DATE% %TIME%         Stopping local DHCP server...>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Stopping local DHCP server...
	sc stop Dhcpserver
echo %CUR_DATE% %TIME%         Local DHCP server stopped.>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Local DHCP server stopped.
echo %CUR_DATE% %TIME% SUCCESS Job complete, DHCP database backed up and ready for use. Exiting.>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME% SUCCESS Job complete, DHCP database backed up and ready for use. Exiting.
goto EOF

:::::::::::::::::::
:: FAILOVER MODE ::
:::::::::::::::::::

:failover
:: Log this AND display to console
echo %CUR_DATE% %TIME% WARNING Failover activated.>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Starting local DHCP server using most recent successful backup...>> %LOGPATH%\%LOGFILE%.log
echo.
echo %CUR_DATE% %TIME% WARNING Could not contact primary DHCP server %REMOTE_SERVER%. Failover activated.
echo %CUR_DATE% %TIME%         Starting local DHCP server using most recent successful backup...
echo.
	net start Dhcpserver
echo %CUR_DATE% %TIME%         Local DHCP server started.>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Entering monitoring loop. Checking if %REMOTE_SERVER% is back up every %FAILOVER_RECHECK_DELAY% seconds...>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME%         Local DHCP server started.
echo %CUR_DATE% %TIME%         Entering monitoring loop. Checking if %REMOTE_SERVER% is back up every %FAILOVER_RECHECK_DELAY% seconds...

:failover_loop
:: First we ping the server
ping %REMOTE_SERVER% -n 5 >NUL
:: If no ping response, this section executes
IF NOT %ERRORLEVEL%==0 (
	echo %CUR_DATE% %TIME% FAILURE No ping response from %REMOTE_SERVER%. Waiting %FAILOVER_RECHECK_DELAY% seconds to check again.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME% FAILURE No ping response from %REMOTE_SERVER%. Waiting %FAILOVER_RECHECK_DELAY% seconds to check again.
	ping localhost -n %FAILOVER_RECHECK_DELAY% >NUL
	goto failover_loop
	)

:: If yes ping response, this section executes
:: This declaration is required to get the nested IF ERRORLEVEL test to function correctly
SETLOCAL ENABLEDELAYEDEXPANSION
if not %ERRORLEVEL%==1 (
	echo %CUR_DATE% %TIME% NOTICE  %REMOTE_SERVER% is responding to pings.>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME% NOTICE  %REMOTE_SERVER% is responding to pings.
	echo %CUR_DATE% %TIME%         Checking DHCP server status on %REMOTE_SERVER%...>> %LOGPATH%\%LOGFILE%.log
	echo %CUR_DATE% %TIME%         Checking DHCP server status on %REMOTE_SERVER%...

	:: This section checks to see if the Dhcpserver service is back up and acts accordingly
	%WINDIR%\System32\sc.exe \\%REMOTE_SERVER% query Dhcpserver | find "RUNNING" >NUL
		:: The exclamation points around ERRORLEVEL here prevent it from incorrectly being expanded using the external ERRORLEVEL results from the first IF statement
		if !ERRORLEVEL!==0 (
				echo %CUR_DATE% %TIME% SUCCESS The DHCP service is running on %REMOTE_SERVER%.>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME% SUCCESS The DHCP service is running on %REMOTE_SERVER%.
				echo %CUR_DATE% %TIME%         Primary DHCP server %REMOTE_SERVER% is back up. Beginning recovery procedures...>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME%         Primary DHCP server %REMOTE_SERVER% is back up. Beginning recovery procedures...

				:: Back up the database that we've been running temporarily while the primary server was down
				echo %CUR_DATE% %TIME%         Exporting the current DHCP database...>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME%         Exporting the current DHCP database...
				netsh dhcp server backup %TEMP%\DHCP-RECOVERY

				:: Stop our local server since we're done performing DHCP server duties
				echo %CUR_DATE% %TIME%         Stopping local DHCP server...>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME%         Stopping local DHCP server...
				sc stop Dhcpserver

				:: Send the database back to the primary server
				echo %CUR_DATE% %TIME%         Uploading current DHCP database to %REMOTE_SERVER%...>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME%         Uploading current DHCP database to %REMOTE_SERVER%...
				xcopy "%TEMP%\DHCP-RECOVERY\*" "\\%REMOTE_SERVER%\c$\%REMOTE_OPERATING_PATH%\DHCP-RECOVERY\" /S /Y /Q 2>NUL

				:: Import the current database on the primary server
				echo %CUR_DATE% %TIME%         Importing current DHCP database on %REMOTE_SERVER%...>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME%         Importing current DHCP database on %REMOTE_SERVER%...
				netsh dhcp server \\%REMOTE_SERVER% restore "\\%REMOTE_SERVER%\c$\%REMOTE_OPERATING_PATH%\DHCP-RECOVERY"
				:: force a delay to let it stop
				ping -n 4 localhost >NUL

				:: Spin the primary server back up. For some reason we have to run the command twice for it to actually start. Don't ask.
				echo %CUR_DATE% %TIME%         Restarting DHCP server on %REMOTE_SERVER%...>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME%         Restarting DHCP server on %REMOTE_SERVER%...
				sc \\%REMOTE_SERVER% stop Dhcpserver
				ping localhost -n 8 >NUL
				sc \\%REMOTE_SERVER% start Dhcpserver
				ping localhost -n 5 >NUL
				sc \\%REMOTE_SERVER% query Dhcpserver
				ping localhost -n 8 >NUL
				sc \\%REMOTE_SERVER% start Dhcpserver

				REM :: Check to make sure it's working
				REM echo %CUR_DATE% %TIME%         Verifying functionality on primary server...>> %LOGPATH%\%LOGFILE%.log
				REM echo %CUR_DATE% %TIME%         Verifying functionality on primary server...
				REM sc \\%REMOTE_SERVER% query Dhcpserver | find "RUNNING"
				REM if not %ERRORLEVEL%==0 echo %CUR_DATE% %TIME% FAILURE DHCP server on %REMOTE_SERVER% is not running. You should investigate this manually.>> %LOGPATH%\%LOGFILE%.log
				REM if %ERRORLEVEL%==0 echo %CUR_DATE% %TIME% SUCCESS DHCP server on %REMOTE_SERVER% is up and running. Recovery complete.>> %LOGPATH%\%LOGFILE%.log

				:: Clean up
				rmdir /S /Q %TEMP%\DHCP-RECOVERY

				:: Done.
				echo %CUR_DATE% %TIME%         Exiting.>> %LOGPATH%\%LOGFILE%.log
				echo %CUR_DATE% %TIME%         Exiting.
				goto EOF
				)
	)
ENDLOCAL

:: If the host responds to pings but the DHCP service isn't running, this executes
echo %CUR_DATE% %TIME% FAILURE %REMOTE_SERVER% is responding to pings, but DHCP isn't responding (yet?). Will try again in %FAILOVER_RECHECK_DELAY% seconds.>> %LOGPATH%\%LOGFILE%.log
echo %CUR_DATE% %TIME% FAILURE %REMOTE_SERVER% is responding to pings, but DHCP isn't responding (yet?). Will try again in %FAILOVER_RECHECK_DELAY% seconds.
ver >NUL
goto failover_loop

ENDLOCAL
echo.>> %LOGPATH%\%LOGFILE%.log
:EOF

Create dhcp_server_watchdog.bat

Create dhcp_server_watchdog.bat