@echo off

setlocal

set v=3.2
set repo=-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2 -DrepositoryId=sonatype-nexus-staging -DgeneratePom=false
set repo_jodd=%repo% -DpomFile=mvn\jodd.pom.xml
set repo_jodd_wot=%repo% -DpomFile=mvn\jodd-wot.pom.xml

echo.
echo --==[ Signing ]==--
echo.

rm -f dist/*.asc
rm -f mvn/*.asc

gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-%v%.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-%v%-sources.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-%v%-javadoc.jar
gpg --batch --passphrase-file .pass --armor --detach-sign mvn/jodd.pom.xml

gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-wot-%v%.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-wot-%v%-sources.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-wot-%v%-javadoc.jar
gpg --batch --passphrase-file .pass --armor --detach-sign mvn/jodd-wot.pom.xml

pause.

echo.
echo --==[ Deploy Jodd %v% ]==--
echo.

call mvn deploy:deploy-file %repo_jodd%											 -Dfile=dist\jodd-%v%.jar
call mvn deploy:deploy-file %repo_jodd% 	 				 -Dpackaging=jar.asc -Dfile=dist\jodd-%v%.jar.asc

call mvn deploy:deploy-file %repo_jodd% -Dclassifier=sources -Dpackaging=jar     -Dfile=dist\jodd-%v%-sources.jar
call mvn deploy:deploy-file %repo_jodd% -Dclassifier=sources -Dpackaging=jar.asc -Dfile=dist\jodd-%v%-sources.jar.asc

call mvn deploy:deploy-file %repo_jodd% -Dclassifier=javadoc -Dpackaging=jar     -Dfile=dist\jodd-%v%-javadoc.jar
call mvn deploy:deploy-file %repo_jodd% -Dclassifier=javadoc -Dpackaging=jar.asc -Dfile=dist\jodd-%v%-javadoc.jar.asc

call mvn deploy:deploy-file %repo_jodd%						 -Dpackaging=pom	 -Dfile=mvn\jodd.pom.xml
call mvn deploy:deploy-file %repo_jodd% 	 				 -Dpackaging=pom.asc -Dfile=mvn\jodd.pom.xml.asc

echo.
echo --==[ Deploy Jodd WOT %v% ]==--
echo.

call mvn deploy:deploy-file %repo_jodd_wot%      			                         -Dfile=dist\jodd-wot-%v%.jar
call mvn deploy:deploy-file %repo_jodd_wot%                      -Dpackaging=jar.asc -Dfile=dist\jodd-wot-%v%.jar.asc

call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=sources -Dpackaging=jar     -Dfile=dist\jodd-wot-%v%-sources.jar
call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=sources -Dpackaging=jar.asc -Dfile=dist\jodd-wot-%v%-sources.jar.asc

call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=javadoc -Dpackaging=jar     -Dfile=dist\jodd-wot-%v%-javadoc.jar
call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=javadoc -Dpackaging=jar.asc -Dfile=dist\jodd-wot-%v%-javadoc.jar.asc

call mvn deploy:deploy-file %repo_jodd_wot%					 	 -Dpackaging=pom	 -Dfile=mvn\jodd-wot.pom.xml
call mvn deploy:deploy-file %repo_jodd_wot%  				 	 -Dpackaging=pom.asc -Dfile=mvn\jodd-wot.pom.xml.asc

endlocal

echo.
echo Done!
echo.

@echo off

setlocal

set v=3.2.5
set repo=-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2 -DrepositoryId=sonatype-nexus-staging -DgeneratePom=false
set repo_jodd=%repo% -DpomFile=mvn\jodd.pom.xml
set repo_jodd_wot=%repo% -DpomFile=mvn\jodd-wot.pom.xml

echo.
echo --==[ Signing ]==--
echo.

rm -f dist/*.asc
rm -f mvn/*.asc

gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-%v%.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-%v%-sources.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-%v%-javadoc.jar
gpg --batch --passphrase-file .pass --armor --detach-sign mvn/jodd.pom.xml

gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-wot-%v%.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-wot-%v%-sources.jar
gpg --batch --passphrase-file .pass --armor --detach-sign dist/jodd-wot-%v%-javadoc.jar
gpg --batch --passphrase-file .pass --armor --detach-sign mvn/jodd-wot.pom.xml

pause.

echo.
echo --==[ Deploy Jodd %v% ]==--
echo.

call mvn deploy:deploy-file %repo_jodd%											 -Dfile=dist\jodd-%v%.jar
call mvn deploy:deploy-file %repo_jodd% 	 				 -Dpackaging=jar.asc -Dfile=dist\jodd-%v%.jar.asc

call mvn deploy:deploy-file %repo_jodd% -Dclassifier=sources -Dpackaging=jar     -Dfile=dist\jodd-%v%-sources.jar
call mvn deploy:deploy-file %repo_jodd% -Dclassifier=sources -Dpackaging=jar.asc -Dfile=dist\jodd-%v%-sources.jar.asc

call mvn deploy:deploy-file %repo_jodd% -Dclassifier=javadoc -Dpackaging=jar     -Dfile=dist\jodd-%v%-javadoc.jar
call mvn deploy:deploy-file %repo_jodd% -Dclassifier=javadoc -Dpackaging=jar.asc -Dfile=dist\jodd-%v%-javadoc.jar.asc

call mvn deploy:deploy-file %repo_jodd%						 -Dpackaging=pom	 -Dfile=mvn\jodd.pom.xml
call mvn deploy:deploy-file %repo_jodd% 	 				 -Dpackaging=pom.asc -Dfile=mvn\jodd.pom.xml.asc

echo.
echo --==[ Deploy Jodd WOT %v% ]==--
echo.

call mvn deploy:deploy-file %repo_jodd_wot%      			                         -Dfile=dist\jodd-wot-%v%.jar
call mvn deploy:deploy-file %repo_jodd_wot%                      -Dpackaging=jar.asc -Dfile=dist\jodd-wot-%v%.jar.asc

call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=sources -Dpackaging=jar     -Dfile=dist\jodd-wot-%v%-sources.jar
call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=sources -Dpackaging=jar.asc -Dfile=dist\jodd-wot-%v%-sources.jar.asc

call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=javadoc -Dpackaging=jar     -Dfile=dist\jodd-wot-%v%-javadoc.jar
call mvn deploy:deploy-file %repo_jodd_wot% -Dclassifier=javadoc -Dpackaging=jar.asc -Dfile=dist\jodd-wot-%v%-javadoc.jar.asc

call mvn deploy:deploy-file %repo_jodd_wot%					 	 -Dpackaging=pom	 -Dfile=mvn\jodd-wot.pom.xml
call mvn deploy:deploy-file %repo_jodd_wot%  				 	 -Dpackaging=pom.asc -Dfile=mvn\jodd-wot.pom.xml.asc

endlocal

echo.
echo Done!
echo.

prepare for 3.2.5

prepare for 3.2.5


@echo off

echo ===========================================================================
echo  1. Create bower.json, package.json
echo  2. Download gulpfile.js and skeleton
echo  3. Make directories
echo.

pause && npm init && bower init && ^
npm install gulp gulp-sass gulp-jade gulp-shell gulp-coffee && ^
curl -O https://raw.githubusercontent.com/PixxxeL/regular-gulpfile/master/gulpfile.js && ^
mkdir jade html coffee js sass css img && ^
cd coffee && ^
curl -O https://raw.githubusercontent.com/PixxxeL/regular-gulpfile/master/coffee/main.coffee && ^
cd ..\jade && ^
curl -O https://raw.githubusercontent.com/PixxxeL/regular-gulpfile/master/jade/base.jade && ^
curl -O https://raw.githubusercontent.com/PixxxeL/regular-gulpfile/master/jade/index.jade && ^
cd ..\sass && ^
curl -O https://raw.githubusercontent.com/PixxxeL/regular-gulpfile/master/sass/_definitions.sass && ^
curl -O https://raw.githubusercontent.com/PixxxeL/regular-gulpfile/master/sass/main.sass && ^
cd .. && ^
echo. && echo Job finish!

exit 0

@echo off

set REPO_URL=https://raw.githubusercontent.com/PixxxeL/regular-gulpfile/master/

echo ===========================================================================
echo  1. Create bower.json, package.json
echo  2. Download gulpfile.js and skeleton
echo  3. Make directories
echo.

pause && npm init && bower init && ^
npm install gulp gulp-sass gulp-jade gulp-shell gulp-coffee && ^
curl -O %REPO_URL%gulpfile.js && ^
mkdir jade html coffee js sass css img && ^
cd coffee && ^
curl -O %REPO_URL%coffee/main.coffee && ^
cd ..\jade && ^
curl -O %REPO_URL%jade/base.jade && ^
curl -O %REPO_URL%jade/index.jade && ^
cd ..\sass && ^
curl -O %REPO_URL%sass/_definitions.sass && ^
curl -O %REPO_URL%sass/main.sass && ^
cd .. && ^
echo. && echo Job finish!

exit 0

Change new-client.bat

Change new-client.bat


@echo OFF

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

SET ORIGPATH=%cd%
SET CDAP_HOME=%~dp0
SET CDAP_HOME=%CDAP_HOME:~0,-5%
SET JAVACMD=%JAVA_HOME%\bin\java.exe

REM Specifies Web App Path
SET WEB_APP_PATH=%CDAP_HOME%\web-app\local\server\main.js

REM %CDAP_HOME%
SET CLASSPATH=%CDAP_HOME%\lib\*;%CDAP_HOME%\conf\
SET PATH=%PATH%;%CDAP_HOME%\libexec\bin

cd %CDAP_HOME%

REM Process command line
IF "%1" == "start" GOTO START
IF "%1" == "stop" GOTO STOP
IF "%1" == "restart" GOTO RESTART
IF "%1" == "status" GOTO STATUS
IF "%1" == "reset" GOTO RESET
GOTO USAGE

:USAGE
echo Usage: %0 {start^|stop^|restart^|status^|reset}
echo Additional options with start, restart:
echo --enable-debug [ ^<port^> ] to connect to a debug port for Standalone CDAP (default port is 5005)
GOTO :FINALLY

:RESET
REM checks if there exists a PID that is already running. Alert user but still return success
attrib -h %~dsp0MyProg.pid >NUL
if exist %~dsp0MyProg.pid (
  for /F %%i in (%~dsp0MyProg.pid) do (
    for /F "TOKENS=2" %%b in ('TASKLIST /FI "PID eq %%i"') DO (
      set lastPid=%%b
    )
    if "%lastPid%" == "%%i" (
      echo %0 running as process %%i. Stop it first.
      GOTO :FINALLY
    ) else (
      REM If process not running but pid file exists, delete pid file.
      del %~dsp0MyProg.pid
    )
  )
)
attrib +h %~dsp0MyProg.pid >NUL

REM ask for confirmation from user
set /P answer="This deletes all apps, data and logs. Are you sure you want to proceed? (y/n) " %=%
if NOT "%answer%" == "y" (
  GOTO :FINALLY
)

REM delete logs and data directories
echo Resetting Standalone CDAP...
rmdir /S /Q %CDAP_HOME%\logs %CDAP_HOME%\data > NUL 2>&1
echo CDAP reset successfully.
GOTO :FINALLY

:START
REM Check for 64-bit version of OS. Currently not supporting 32-bit Windows
IF NOT EXIST "%PROGRAMFILES(X86)%" (
  echo 32-bit Windows operating system is currently not supported
  GOTO :FINALLY
)

REM Check for correct setting for JAVA_HOME path
if [%JAVA_HOME%] == [] (
  echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  echo Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
  GOTO :FINALLY
)

REM Check for Java version
setlocal ENABLEDELAYEDEXPANSION
set /a counter=0
for /f "tokens=* delims= " %%f in ('%JAVACMD% -version 2^>^&1') do @(
  if "!counter!"=="0" set line=%%f
  set /a counter+=1
)
set line=%line:java version "1.=!!%
set line=%line:~0,1%
if NOT "%line%" == "6" (
  if NOT "%line%" == "7" (
    echo ERROR: Java version not supported. Please install Java 6 or 7 - other versions of Java are not yet supported.
    GOTO :FINALLY
  )
)
endlocal

REM Check if Node.js is installed
for %%x in (node.exe) do if [%%~$PATH:x]==[] (
  echo Node.js Standalone CDAP requires Node.js but it's either not installed or not in path. Exiting. 1>&2
  GOTO :FINALLY
)

REM Check for Node.js version
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=* delims= " %%f in ('node -v') do @(
  set line=%%f
)
set line=%line:v=!!%
set line=0.10.1

for /F "delims=. tokens=1,2,3" %%a in ('echo %line%') do (
  if %%a LSS 1 (
    if %%b LSS 9 (
      if %%c LSS 16 (
        echo Node.js version is not supported. The minimum version suported is v0.8.16.
        GOTO :FINALLY
      )
    )
  )
)
endlocal

REM checks if there exists a PID that is already running. Alert user but still return success
attrib -h %~dsp0MyProg.pid >NUL
if exist %~dsp0MyProg.pid (
  for /F %%i in (%~dsp0MyProg.pid) do (
    setlocal ENABLEDELAYEDEXPANSION
    for /F "TOKENS=2" %%b in ('TASKLIST /FI "PID eq %%i"') DO (
      set lastPid=%%b
    )
    if "!lastPid!" == "%%i" (
      echo %0 running as process %%i. Stop it first or use the restart function.
      GOTO :FINALLY
    ) else (
      REM If process not running but pid file exists, delete pid file.
      del %~dsp0MyProg.pid
    )
    endlocal
  )
)
attrib +h %~dsp0MyProg.pid >NUL

REM Check for new version of CDAP
bitsadmin /Transfer NAME http://s3.amazonaws.com/cdap-docs/VERSION %~f0_version.txt > NUL 2>&1
if exist %~f0_version.txt (
  for /f "tokens=* delims= " %%f in (%~f0_version.txt) do (
    SET new_version = %%f
  )
  for /f "tokens=* delims= " %%g in (%~f0\..\..\VERSION) do (
    SET current_version = %%g
  )
  del %~f0_version.txt > NUL 2>&1

  if not "%current_version%" == "%new_version%" (
    echo UPDATE: There is a newer version of the CDAP SDK available.
    echo         Download it from http://cask.co/downloads
  )
)

mkdir %CDAP_HOME%\logs > NUL 2>&1

REM Log rotation
call:LOG_ROTATE cdap
call:LOG_ROTATE cdap-process
call:LOG_ROTATE cdap-debug

REM check if debugging is enabled
SET DEBUG_OPTIONS=
setlocal ENABLEDELAYEDEXPANSION
IF "%2" == "--enable-debug" (
  IF "%3" == "" (
    set port=5005
  ) ELSE (
    REM check if port is a number
    SET "check="&FOR /f "delims=0123456789" %%i IN ("%3") DO SET check="x"
    IF DEFINED check (
      echo port number must be an integer.
      ENDLOCAL
      GOTO :FINALLY
    )
    REM check if the number is in range
    set port=%3
    IF !port! LSS 1024 (
      echo port number must be between 1024 and 65535.
      ENDLOCAL
      GOTO :FINALLY
    )
    IF !port! GTR 65535 (
      echo port number must be between 1024 and 65535.
      ENDLOCAL
      GOTO :FINALLY
    )
  )
  set DEBUG_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=localhost:!port!,server=y,suspend=n"
)

start /B %JAVACMD% !DEBUG_OPTIONS! -Dhadoop.security.group.mapping=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback -Dhadoop.home.dir=%CDAP_HOME%\libexec -classpath %CLASSPATH% co.cask.cdap.StandaloneMain --web-app-path %WEB_APP_PATH% >> %CDAP_HOME%\logs\cdap-process.log 2>&1 < NUL
echo Starting Standalone CDAP...

for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq java.exe"') DO SET MyPID=%%b
echo %MyPID% > %~dsp0MyProg.pid
SET lastPid=%MyPID%
attrib +h %~dsp0MyProg.pid >NUL

:SearchLogs
findstr /R /C:".*Failed to start server.*" %CDAP_HOME%\logs\cdap-process.log >NUL 2>&1
if %errorlevel% == 0 GOTO :ServerError

findstr /R /C:"..* started successfully.*" %CDAP_HOME%\logs\cdap-process.log >NUL 2>&1
if not %errorlevel% == 0 GOTO :SearchLogs
if %errorlevel% == 0 GOTO :ServerSuccess
:EndSearchLogs

:ServerError
echo Failed to start, please check logs for more information
GOTO :STOP

:ServerSuccess
echo Standalone CDAP started succesfully.

IF NOT "!DEBUG_OPTIONS!" == "" (
  echo Remote debugger agent started on port !port!.
)
ENDLOCAL

REM Sleep for 5 seconds to wait for Node.js startup
PING 127.0.0.1 -n 6 > NUL 2>&1

for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq node.exe"') DO SET MyNodePID=%%b
echo %MyNodePID% > %~dsp0MyProgNode.pid
attrib +h %~dsp0MyProgNode.pid >NUL

# Disable NUX
# TODO: Enable NUX with new app, see CDAP-22
# CALL :NUX
GOTO :FINALLY

:NUX
REM New user experience, enable if it is not enabled already
if not exist %CDAP_HOME%\.nux_dashboard (

  REM Deploy app
  FOR /F %%i IN ('curl -X POST -sL -w %%{http_code} -H "X-Archive-Name: LogAnalytics.jar" --data-binary @"%JAR_PATH%" http://127.0.0.1:10000/v2/apps') DO SET RESPONSE=%%i
  REM IF  NOT %RESPONSE% == 200  (GOTO :EOF)
  REM Start flow
  curl -sL -X POST http://127.0.0.1:10000/v2/apps/ResponseCodeAnalytics/flows/LogAnalyticsFlow/start
  REM Start procedure
  curl -sL -X POST http://127.0.0.1:10000/v2/apps/ResponseCodeAnalytics/procedures/StatusCodeProcedure/start
)
GOTO :EOF

:STOP
echo Stopping Standalone CDAP ...
attrib -h %~dsp0MyProg.pid >NUL
if exist %~dsp0MyProg.pid (
  for /F %%i in (%~dsp0MyProg.pid) do (
    taskkill /F /PID %%i >NUL 2>&1
    del %~dsp0MyProg.pid 1>NUL 2>&1
  )
)

REM Sleep for 5 seconds
PING 127.0.0.1 -n 6 > NUL 2>&1

attrib -h %~dsp0MyProgNode.pid >NUL
if exist %~dsp0MyProgNode.pid (
  for /F %%i in (%~dsp0MyProgNode.pid) do (
    taskkill /F /PID %%i >NUL 2>&1
    del %~dsp0MyProgNode.pid 1>NUL 2>&1
  )
)
GOTO :FINALLY

:STATUS
attrib -h %~dsp0MyProg.pid >NUL
if NOT exist %~dsp0MyProg.pid (
  echo %0 is not running
) else (
for /F %%i in (%~dsp0MyProg.pid) do (
  setlocal ENABLEDELAYEDEXPANSION
  for /F "TOKENS=2" %%b in ('TASKLIST /FI "PID eq %%i"') DO (
    set lastPid=%%b
  )
  if "!lastPid!" == "%%i" (
    echo %0 running as process !lastPid!
  ) else (
    echo pidfile exists but process does not appear to be running
  )
  endlocal
 )
)
attrib +h %~dsp0MyProg.pid >NUL
GOTO :FINALLY

:RESTART
CALL :STOP
GOTO :START

:FINALLY
cd %ORIGPATH%
GOTO:EOF

:LOG_ROTATE
setlocal ENABLEDELAYEDEXPANSION
set extension=%1.log
for /F "TOKENS=*" %%b in ('dir  /a-d %CDAP_HOME%\logs 2^>NUL ^| find /c "%extension%" 2^>NUL') DO (
  set /a num=%%b
  FOR /L %%i IN (!num!,-1,1) DO (
    set /a prev_num=%%i+1
    rename %CDAP_HOME%\logs\%extension%.%%i %extension%.!prev_num! >NUL 2>NUL
  )
  rename %CDAP_HOME%\logs\%extension% %extension%.1 >NUL 2>NUL
)
endlocal

@echo OFF

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

SET ORIGPATH=%cd%
SET CDAP_HOME=%~dp0
SET CDAP_HOME=%CDAP_HOME:~0,-5%
SET JAVACMD=%JAVA_HOME%\bin\java.exe

REM Specifies Web App Path
SET WEB_APP_PATH=%CDAP_HOME%\web-app\local\server\main.js

REM %CDAP_HOME%
SET CLASSPATH=%CDAP_HOME%\lib\*;%CDAP_HOME%\conf\
SET PATH=%PATH%;%CDAP_HOME%\libexec\bin

cd %CDAP_HOME%

REM Process command line
IF "%1" == "start" GOTO START
IF "%1" == "stop" GOTO STOP
IF "%1" == "restart" GOTO RESTART
IF "%1" == "status" GOTO STATUS
IF "%1" == "reset" GOTO RESET
GOTO USAGE

:USAGE
echo Usage: %0 {start^|stop^|restart^|status^|reset}
echo Additional options with start, restart:
echo --enable-debug [ ^<port^> ] to connect to a debug port for Standalone CDAP (default port is 5005)
GOTO :FINALLY

:RESET
REM checks if there exists a PID that is already running. Alert user but still return success
attrib -h %~dsp0MyProg.pid >NUL
if exist %~dsp0MyProg.pid (
  for /F %%i in (%~dsp0MyProg.pid) do (
    for /F "TOKENS=2" %%b in ('TASKLIST /FI "PID eq %%i"') DO (
      set lastPid=%%b
    )
    if "%lastPid%" == "%%i" (
      echo %0 running as process %%i. Stop it first.
      GOTO :FINALLY
    ) else (
      REM If process not running but pid file exists, delete pid file.
      del %~dsp0MyProg.pid
    )
  )
)
attrib +h %~dsp0MyProg.pid >NUL

REM ask for confirmation from user
set /P answer="This deletes all apps, data and logs. Are you sure you want to proceed? (y/n) " %=%
if NOT "%answer%" == "y" (
  GOTO :FINALLY
)

REM delete logs and data directories
echo Resetting Standalone CDAP...
rmdir /S /Q %CDAP_HOME%\logs %CDAP_HOME%\data > NUL 2>&1
echo CDAP reset successfully.
GOTO :FINALLY

:START
REM Check for 64-bit version of OS. Currently not supporting 32-bit Windows
IF NOT EXIST "%PROGRAMFILES(X86)%" (
  echo 32-bit Windows operating system is currently not supported
  GOTO :FINALLY
)

REM Check for correct setting for JAVA_HOME path
if [%JAVA_HOME%] == [] (
  echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  echo Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
  GOTO :FINALLY
)

REM Check for Java version
setlocal ENABLEDELAYEDEXPANSION
set /a counter=0
for /f "tokens=* delims= " %%f in ('%JAVACMD% -version 2^>^&1') do @(
  if "!counter!"=="0" set line=%%f
  set /a counter+=1
)
set line=%line:java version "1.=!!%
set line=%line:~0,1%
if NOT "%line%" == "6" (
  if NOT "%line%" == "7" (
    echo ERROR: Java version not supported. Please install Java 6 or 7 - other versions of Java are not yet supported.
    GOTO :FINALLY
  )
)
endlocal

REM Check if Node.js is installed
for %%x in (node.exe) do if [%%~$PATH:x]==[] (
  echo Node.js Standalone CDAP requires Node.js but it's either not installed or not in path. Exiting. 1>&2
  GOTO :FINALLY
)

REM Check for Node.js version
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=* delims= " %%f in ('node -v') do @(
  set line=%%f
)
set line=%line:v=!!%
set line=0.10.1

for /F "delims=. tokens=1,2,3" %%a in ('echo %line%') do (
  if %%a LSS 1 (
    if %%b LSS 9 (
      if %%c LSS 16 (
        echo Node.js version is not supported. The minimum version suported is v0.8.16.
        GOTO :FINALLY
      )
    )
  )
)
endlocal

REM checks if there exists a PID that is already running. Alert user but still return success
attrib -h %~dsp0MyProg.pid >NUL
if exist %~dsp0MyProg.pid (
  for /F %%i in (%~dsp0MyProg.pid) do (
    setlocal ENABLEDELAYEDEXPANSION
    for /F "TOKENS=2" %%b in ('TASKLIST /FI "PID eq %%i"') DO (
      set lastPid=%%b
    )
    if "!lastPid!" == "%%i" (
      echo %0 running as process %%i. Stop it first or use the restart function.
      GOTO :FINALLY
    ) else (
      REM If process not running but pid file exists, delete pid file.
      del %~dsp0MyProg.pid
    )
    endlocal
  )
)
attrib +h %~dsp0MyProg.pid >NUL

REM Check for new version of CDAP
bitsadmin /Transfer NAME http://s3.amazonaws.com/cdap-docs/VERSION %~f0_version.txt > NUL 2>&1
if exist %~f0_version.txt (
  for /f "tokens=* delims= " %%f in (%~f0_version.txt) do (
    SET new_version = %%f
  )
  for /f "tokens=* delims= " %%g in (%~f0\..\..\VERSION) do (
    SET current_version = %%g
  )
  del %~f0_version.txt > NUL 2>&1

  if not "%current_version%" == "%new_version%" (
    echo UPDATE: There is a newer version of the CDAP SDK available.
    echo         Download it from http://cask.co/downloads
  )
)

mkdir %CDAP_HOME%\logs > NUL 2>&1

REM Log rotation
call:LOG_ROTATE cdap
call:LOG_ROTATE cdap-process
call:LOG_ROTATE cdap-debug

REM check if debugging is enabled
SET DEBUG_OPTIONS=
setlocal ENABLEDELAYEDEXPANSION
IF "%2" == "--enable-debug" (
  IF "%3" == "" (
    set port=5005
  ) ELSE (
    REM check if port is a number
    SET "check="&FOR /f "delims=0123456789" %%i IN ("%3") DO SET check="x"
    IF DEFINED check (
      echo port number must be an integer.
      ENDLOCAL
      GOTO :FINALLY
    )
    REM check if the number is in range
    set port=%3
    IF !port! LSS 1024 (
      echo port number must be between 1024 and 65535.
      ENDLOCAL
      GOTO :FINALLY
    )
    IF !port! GTR 65535 (
      echo port number must be between 1024 and 65535.
      ENDLOCAL
      GOTO :FINALLY
    )
  )
  set DEBUG_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=localhost:!port!,server=y,suspend=n"
)

start /B %JAVACMD% !DEBUG_OPTIONS! -Dhadoop.security.group.mapping=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback -Dhadoop.home.dir=%CDAP_HOME%\libexec -classpath %CLASSPATH% co.cask.cdap.StandaloneMain --web-app-path %WEB_APP_PATH% >> %CDAP_HOME%\logs\cdap-process.log 2>&1 < NUL
echo Starting Standalone CDAP...

for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq java.exe"') DO SET MyPID=%%b
echo %MyPID% > %~dsp0MyProg.pid
SET lastPid=%MyPID%
attrib +h %~dsp0MyProg.pid >NUL

:SearchLogs
findstr /R /C:".*Failed to start server.*" %CDAP_HOME%\logs\cdap-process.log >NUL 2>&1
if %errorlevel% == 0 GOTO :ServerError

findstr /R /C:"..* started successfully.*" %CDAP_HOME%\logs\cdap-process.log >NUL 2>&1
if not %errorlevel% == 0 GOTO :SearchLogs
if %errorlevel% == 0 GOTO :ServerSuccess
:EndSearchLogs

:ServerError
echo Failed to start, please check logs for more information
GOTO :STOP

:ServerSuccess
echo Standalone CDAP started succesfully.

IF NOT "!DEBUG_OPTIONS!" == "" (
  echo Remote debugger agent started on port !port!.
)
ENDLOCAL

REM Sleep for 5 seconds to wait for Node.js startup
PING 127.0.0.1 -n 6 > NUL 2>&1

for /F "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq node.exe"') DO SET MyNodePID=%%b
echo %MyNodePID% > %~dsp0MyProgNode.pid
attrib +h %~dsp0MyProgNode.pid >NUL

REM Disable NUX
REM TODO: Enable NUX with new app, see CDAP-22
REM CALL :NUX
GOTO :FINALLY

:NUX
REM New user experience, enable if it is not enabled already
if not exist %CDAP_HOME%\.nux_dashboard (

  REM Deploy app
  FOR /F %%i IN ('curl -X POST -sL -w %%{http_code} -H "X-Archive-Name: LogAnalytics.jar" --data-binary @"%JAR_PATH%" http://127.0.0.1:10000/v2/apps') DO SET RESPONSE=%%i
  REM IF  NOT %RESPONSE% == 200  (GOTO :EOF)
  REM Start flow
  curl -sL -X POST http://127.0.0.1:10000/v2/apps/ResponseCodeAnalytics/flows/LogAnalyticsFlow/start
  REM Start procedure
  curl -sL -X POST http://127.0.0.1:10000/v2/apps/ResponseCodeAnalytics/procedures/StatusCodeProcedure/start
)
GOTO :EOF

:STOP
echo Stopping Standalone CDAP ...
attrib -h %~dsp0MyProg.pid >NUL
if exist %~dsp0MyProg.pid (
  for /F %%i in (%~dsp0MyProg.pid) do (
    taskkill /F /PID %%i >NUL 2>&1
    del %~dsp0MyProg.pid 1>NUL 2>&1
  )
)

REM Sleep for 5 seconds
PING 127.0.0.1 -n 6 > NUL 2>&1

attrib -h %~dsp0MyProgNode.pid >NUL
if exist %~dsp0MyProgNode.pid (
  for /F %%i in (%~dsp0MyProgNode.pid) do (
    taskkill /F /PID %%i >NUL 2>&1
    del %~dsp0MyProgNode.pid 1>NUL 2>&1
  )
)
GOTO :FINALLY

:STATUS
attrib -h %~dsp0MyProg.pid >NUL
if NOT exist %~dsp0MyProg.pid (
  echo %0 is not running
) else (
for /F %%i in (%~dsp0MyProg.pid) do (
  setlocal ENABLEDELAYEDEXPANSION
  for /F "TOKENS=2" %%b in ('TASKLIST /FI "PID eq %%i"') DO (
    set lastPid=%%b
  )
  if "!lastPid!" == "%%i" (
    echo %0 running as process !lastPid!
  ) else (
    echo pidfile exists but process does not appear to be running
  )
  endlocal
 )
)
attrib +h %~dsp0MyProg.pid >NUL
GOTO :FINALLY

:RESTART
CALL :STOP
GOTO :START

:FINALLY
cd %ORIGPATH%
GOTO:EOF

:LOG_ROTATE
setlocal ENABLEDELAYEDEXPANSION
set extension=%1.log
for /F "TOKENS=*" %%b in ('dir  /a-d %CDAP_HOME%\logs 2^>NUL ^| find /c "%extension%" 2^>NUL') DO (
  set /a num=%%b
  FOR /L %%i IN (!num!,-1,1) DO (
    set /a prev_num=%%i+1
    rename %CDAP_HOME%\logs\%extension%.%%i %extension%.!prev_num! >NUL 2>NUL
  )
  rename %CDAP_HOME%\logs\%extension% %extension%.1 >NUL 2>NUL
)
endlocal

Fix cdap.bat comments

Fix cdap.bat comments


setlocal
call settings.bat

rem git clone https://github.com/systemed/tilemaker.git
git clone https://github.com/alex85k/tilemaker.git

cd tilemaker
mkdir build
cd build
cmake .. %GENERATOR% -DCMAKE_BUILD_TYPE=%VARIANT% -DCMAKE_INSTALL_PREFIX=%PREFIX1% -DBOOST_ROOT=%BOOST_ROOT% -DBoost_USE_STATIC_LIBS=ON -DBoost_ADDITIONAL_VERSIONS=1.58;1.59
%ER%
%MSBUILDINSTALL%
%ER%

cd ..
mkdir dist
copy build\%VARIANT%\*.exe dist
copy resources\*.rb dist
copy *.json dist
copy *.lua dist
copy %PREFIX%\bin\lua.dll dist

echo FOR %%%%G IN (*.osm.pbf) DO tilemaker %%%%G --output tiles/  > dist\convert.bat

cd ..\..

setlocal
call settings.bat

rem git clone https://github.com/systemed/tilemaker.git
git clone https://github.com/alex85k/tilemaker.git

cd tilemaker
mkdir build
cd build
cmake .. %GENERATOR% -DCMAKE_BUILD_TYPE=%VARIANT% -DCMAKE_INSTALL_PREFIX=%PREFIX1% -DBOOST_ROOT=%BOOST_ROOT% -DBoost_USE_STATIC_LIBS=ON -DBoost_ADDITIONAL_VERSIONS=1.58;1.59
%ER%
%MSBUILDINSTALL%
%ER%

cd ..
mkdir dist
copy build\%VARIANT%\*.exe dist
copy resources\*.rb dist
copy *.json dist
copy *.lua dist
copy %PREFIX%\bin\lua.dll dist

echo FOR %%%%G IN (*.osm.pbf) DO tilemaker %%%%G --output tiles/  > dist\convert.bat
echo FOR %%%%G IN (*.osm.pbf) DO tilemaker %%%%G --output tiles.mbtiles  > dist\convert_mbtiles.bat
"%SEDC%" -i dist/config.json -e "s@\"minzoom\":[^,]*,@\"minzoom\": 1,@"
"%SEDC%" -i dist/config.json -e "s@\"gzip\"@\"none\"@"

cd ..\..

update tilemaker distro

update tilemaker distro


:: Copyright 2012 The Go Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style
:: license that can be found in the LICENSE file.
@echo off

:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal

set GOBUILDFAIL=0

rem TODO avoid rebuild if possible

if x%1==x--no-rebuild goto norebuild
echo # Building packages and commands.
go install -a -v std
if errorlevel 1 goto fail
echo.
:norebuild

echo # Testing packages.
go test std -short -timeout=120s
if errorlevel 1 goto fail
echo.

echo # runtime -cpu=1,2,4
go test runtime -short -timeout=120s -cpu=1,2,4
if errorlevel 1 goto fail
echo.

echo # sync -cpu=10
go test sync -short -timeout=120s -cpu=10
if errorlevel 1 goto fail
echo.

echo # ..\misc\dashboard\builder ..\misc\goplay
go build ..\misc\dashboard\builder ..\misc\goplay
if errorlevel 1 goto fail
echo.

echo # ..\test\bench\go1
go test ..\test\bench\go1
if errorlevel 1 goto fail
echo.

:: TODO: The other tests in run.bash.

echo # test
cd ..\test
set FAIL=0
go run run.go
if errorlevel 1 set FAIL=1
cd ..\src
echo.
if %FAIL%==1 goto fail

echo # Checking API compatibility.
go tool api -c ..\api\go1.txt
if errorlevel 1 goto fail
echo.

echo ALL TESTS PASSED
goto end

:fail
set GOBUILDFAIL=1

:end

:: Copyright 2012 The Go Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style
:: license that can be found in the LICENSE file.
@echo off

:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal

set GOBUILDFAIL=0

rem TODO avoid rebuild if possible

if x%1==x--no-rebuild goto norebuild
echo # Building packages and commands.
go install -a -v std
if errorlevel 1 goto fail
echo.
:norebuild

echo # Testing packages.
go test std -short -timeout=120s
if errorlevel 1 goto fail
echo.

echo # runtime -cpu=1,2,4
go test runtime -short -timeout=120s -cpu=1,2,4
if errorlevel 1 goto fail
echo.

echo # sync -cpu=10
go test sync -short -timeout=120s -cpu=10
if errorlevel 1 goto fail
echo.

echo # ..\misc\dashboard\builder ..\misc\goplay
go build ..\misc\dashboard\builder ..\misc\goplay
if errorlevel 1 goto fail
echo.

:: TODO(brainman): disabled, because it fails with: mkdir C:\Users\ADMINI~1\AppData\Local\Temp\2.....\test\bench\: The filename or extension is too long.
::echo # ..\test\bench\go1
::go test ..\test\bench\go1
::if errorlevel 1 goto fail
::echo.

:: TODO: The other tests in run.bash.

echo # test
cd ..\test
set FAIL=0
go run run.go
if errorlevel 1 set FAIL=1
cd ..\src
echo.
if %FAIL%==1 goto fail

echo # Checking API compatibility.
go tool api -c ..\api\go1.txt
if errorlevel 1 goto fail
echo.

echo ALL TESTS PASSED
goto end

:fail
set GOBUILDFAIL=1

:end

run.bat: disable test in test\bench\go1 to fix build

R=golang-dev, r
CC=golang-dev
http://codereview.appspot.com/5848066


REM install db
call C:\funda_components\system_user\system_user_database\system_user_test_db\install_system_user_test_db.bat

"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f C:\funda_components\system_user\system_user_database\utility_functions\util_inaction_logout.sql 1> test_util_inaction_logout.log 2>&1

"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

REM install db
call C:\funda_components\system_user\system_user_database\system_user_test_db\install_system_user_test_db.bat

"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f C:\funda_components\system_user\system_user_database\utility_functions\util_inaction_logout.sql 1> test_util_inaction_logout.log 2>&1

"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_data_for_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 30 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 60 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 60 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 60 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 60 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 60 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 60 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

timeout /t 60 /nobreak
"C:\Program Files\PostgreSQL\9.6\bin\psql.exe" -h localhost -U postgres -d system_user_test_db  -p 5432 -f test_util_inaction_logout.sql  1>> test_util_inaction_logout.log 2>>&1

Add tests

Add tests


@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
SET PATH=%PROJECT_PATH%\3rdparty\bin;%MYSQL_CONNECTOR_PATH%\lib;%MYSQL_PATH%\bin;%PYTHON_PATH%\Scripts;%PATH%

cp "%MYSQL_CONNECTOR_PATH%\lib\libmysql.dll" "%PROJECT_PATH%\build\bin\%CONFIGURATION%
cp "%MYSQL_CONNECTOR_PATH%\lib\libmysql.dll" "%PROJECT_PATH%\build\bin\

cmake -GNinja -D%CONFIGURATION%=TRUE -DCMAKE_BUILD_TYPE=%CONFIGURATION% ..
cmake --build . --config %CONFIGURATION%

@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
SET PATH=%PROJECT_PATH%\3rdparty\bin;%MYSQL_CONNECTOR_PATH%\lib;%MYSQL_PATH%\bin;%PYTHON_PATH%\Scripts;%PATH%

REM cp "%MYSQL_CONNECTOR_PATH%\lib\libmysql.dll" "%PROJECT_PATH%\build\bin\%CONFIGURATION%
cp "%MYSQL_CONNECTOR_PATH%\lib\libmysql.dll" "%PROJECT_PATH%\build\bin\"
%PROJECT_PATH%\cmake\scripts\robocopy.bat "%PROJECT_PATH%\scripts" "%PROJECT_PATH%\build\bin\scripts" "*.lua"

cmake -GNinja -D%CONFIGURATION%=TRUE -DCMAKE_BUILD_TYPE=%CONFIGURATION% ..
cmake --build . --config %CONFIGURATION%

Update uploaded artifact on appveyor to include the scripts dir


Add updateversions.bat

Chore(build): Add updateversions.bat


@ECHO OFF
REM Copyright 2015 Ben Vanik. All Rights Reserved.

SET DIR=%~dp0

REM ============================================================================
REM Environment Validation
REM ============================================================================

CALL :check_python
IF %_RESULT% NEQ 0 (
  ECHO.
  ECHO Python 3.4+ must be installed and on PATH:
  ECHO https://www.python.org/
  GOTO :exit_error
)

REM ============================================================================
REM Trampoline into xenia-build
REM ============================================================================

%PYTHON_EXE% xenia-build %*
EXIT /b %ERRORLEVEL%

REM ============================================================================
REM Utilities
REM ============================================================================

:check_python
SETLOCAL
SET FOUND_PYTHON_EXE=""
1>NUL 2>NUL CMD /c where python3
IF NOT ERRORLEVEL 1 (
  ECHO FOUND PYTHON 2
  SET FOUND_PYTHON_EXE=python3
)
IF %FOUND_PYTHON_EXE% EQU "" (
  IF EXIST c:\\python34\\python.exe SET FOUND_PYTHON_EXE=C:\\python34\\python.exe
)
IF %FOUND_PYTHON_EXE% EQU "" (
  IF EXIST c:\\python35\\python.exe SET FOUND_PYTHON_EXE=C:\\python35\\python.exe
)
IF %FOUND_PYTHON_EXE% EQU "" (
  IF EXIST c:\\python36\\python.exe SET FOUND_PYTHON_EXE=C:\\python36\\python.exe
)
IF %FOUND_PYTHON_EXE% EQU "" (
  1>NUL 2>NUL CMD /c where python
  IF NOT ERRORLEVEL 1 (
    SET FOUND_PYTHON_EXE=python
  )
)
IF %FOUND_PYTHON_EXE% EQU "" (
  ECHO ERROR: no Python executable found on PATH.
  ECHO Make sure you can run 'python' or 'python3' in a Command Prompt.
  ENDLOCAL & SET _RESULT=1
  GOTO :eof
)
CMD /C %FOUND_PYTHON_EXE% -c "import sys; sys.exit(1 if not sys.version_info[:2] >= (3, 4) else 0)"
IF %ERRORLEVEL% NEQ 0 (
  ECHO ERROR: Python version mismatch - not 3.4+
  ENDLOCAL & SET _RESULT=1
  GOTO :eof
)
ENDLOCAL & (
  SET _RESULT=0
  SET PYTHON_EXE=%FOUND_PYTHON_EXE%
)
GOTO :eof

@ECHO OFF
REM Copyright 2015 Ben Vanik. All Rights Reserved.

SET DIR=%~dp0

REM ============================================================================
REM Environment Validation
REM ============================================================================

CALL :check_python
IF %_RESULT% NEQ 0 (
  ECHO.
  ECHO Python 3.4+ must be installed and on PATH:
  ECHO https://www.python.org/
  GOTO :exit_error
)

REM ============================================================================
REM Trampoline into xenia-build
REM ============================================================================

%PYTHON_EXE% xenia-build %*
EXIT /b %ERRORLEVEL%

REM ============================================================================
REM Utilities
REM ============================================================================

:check_python
SETLOCAL
SET FOUND_PYTHON_EXE=""
1>NUL 2>NUL CMD /c where python3
IF NOT ERRORLEVEL 1 (
  SET FOUND_PYTHON_EXE=python3
)
IF %FOUND_PYTHON_EXE% EQU "" (
  IF EXIST c:\\python34\\python.exe SET FOUND_PYTHON_EXE=C:\\python34\\python.exe
)
IF %FOUND_PYTHON_EXE% EQU "" (
  IF EXIST c:\\python35\\python.exe SET FOUND_PYTHON_EXE=C:\\python35\\python.exe
)
IF %FOUND_PYTHON_EXE% EQU "" (
  IF EXIST c:\\python36\\python.exe SET FOUND_PYTHON_EXE=C:\\python36\\python.exe
)
IF %FOUND_PYTHON_EXE% EQU "" (
  1>NUL 2>NUL CMD /c where python
  IF NOT ERRORLEVEL 1 (
    SET FOUND_PYTHON_EXE=python
  )
)
IF %FOUND_PYTHON_EXE% EQU "" (
  ECHO ERROR: no Python executable found on PATH.
  ECHO Make sure you can run 'python' or 'python3' in a Command Prompt.
  ENDLOCAL & SET _RESULT=1
  GOTO :eof
)
CMD /C %FOUND_PYTHON_EXE% -c "import sys; sys.exit(1 if not sys.version_info[:2] >= (3, 4) else 0)"
IF %ERRORLEVEL% NEQ 0 (
  ECHO ERROR: Python version mismatch - not 3.4+
  ENDLOCAL & SET _RESULT=1
  GOTO :eof
)
ENDLOCAL & (
  SET _RESULT=0
  SET PYTHON_EXE=%FOUND_PYTHON_EXE%
)
GOTO :eof

Remove "FOUND PYTHON 2" debug message

Remove "FOUND PYTHON 2" debug message


@cmd.exe /k call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

@echo off
cmd.exe /k call "%VS140COMNTOOLS:~0,-14%VC\vcvarsall.bat" amd64

Use VS140COMNTOOLS environment variable in cmd.bat to find VS2015 installation


@ECHO OFF
TITLE ghacks user.js updater

REM ### ghacks-user.js updater for Windows
REM ## author: @claustromaniac
REM ## version: 3.0

SET _myname=%~n0
SET _myparams=%*
SETLOCAL EnableDelayedExpansion
:parse
IF "%~1"=="" (
	GOTO endparse
)
IF /I "%~1"=="-unattended" (
	SET _ua=1
)
IF /I "%~1"=="-log" (
	SET _log=1
)
IF /I "%~1"=="-logp" (
	SET _log=1
	SET _logp=1
)
IF /I "%~1"=="-multioverrides" (
	SET _multi=1
)
IF /I "%~1"=="-merge" (
	SET _merge=1
)
IF /I "%~1"=="-updatebatch" (
	SET _updateb=1
)
SHIFT
GOTO parse
:endparse
ECHO.
IF DEFINED _updateb (
	IF NOT "!_myname:~0,9!"=="[updated]" (
		ECHO Checking updater version...
		ECHO.
		IF EXIST "[updated]!_myname!.bat" ( DEL /F "[updated]!_myname!.bat" )
		REM Uncomment the next line and comment the powershell call for testing.
		REM COPY /B /V /Y "!_myname!.bat" "[updated]!_myname!.bat"
		(
			powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/updater.bat', '[updated]!_myname!.bat')"
		) >nul 2>&1
		IF EXIST "[updated]!_myname!.bat" (
			START CMD /C "[updated]!_myname!.bat" !_myparams!
			EXIT /B
		) ELSE (
			ECHO Failed. Make sure PowerShell is allowed internet access.
			ECHO.
			PING -n 301 127.0.0.1>nul
			EXIT /B
		)
	) ELSE (
		IF EXIST "!_myname:~9!.bat" (
			DEL /F "!_myname:~9!.bat"
			CALL :begin
			REN "!_myname!.bat" "!_myname:~9!.bat"
			EXIT /B
		) ELSE (
			ECHO.
			ECHO The [updated] label is reserved. Do not run an [updated] script directly, or rename it to something else before you run it.
			PING -n 301 127.0.0.1>nul
			EXIT /B
		)
	)
)
:begin
SET /A "_line=0"
IF NOT EXIST user.js (
	ECHO user.js not detected in the current directory.
) ELSE (
	FOR /F "skip=1 tokens=1,2 delims=:" %%G IN (user.js) DO (
		SET /A "_line+=1"
		IF !_line! GEQ 4 (
			GOTO exitloop
		)
		IF !_line! EQU 1 (
			SET _name=%%H
		)
		IF !_line! EQU 2 (
			SET _date=%%H
		)
		IF !_line! EQU 3 (
			SET _version=%%G
		)
	)
	:exitloop
	IF !_line! GEQ 4 (
		IF /I NOT "!_name!"=="!_name:ghacks=X!" (
			ECHO ghacks user.js !_version:~2!,!_date!
		) ELSE (
			ECHO Current user.js version not recognised.
		)
	) ELSE (
		ECHO Current user.js version not recognised.
	)
)
ECHO.
IF NOT DEFINED _ua (
	ECHO.
	ECHO This batch should be run from your Firefox profile directory. It will download the latest version of ghacks user.js from github and then append any of your own changes from user-overrides.js to it.
	ECHO.
	REM ECHO Visit the wiki for more detailed information.
	REM ECHO.
	CHOICE /M "Continue"
	IF ERRORLEVEL 2 EXIT /B
)
CLS
ECHO.
IF DEFINED _log (
	CALL :log >>user.js-update-log.txt 2>&1
	IF DEFINED _logp (
		START user.js-update-log.txt
	)
	EXIT /B
	:log
	ECHO ##################################################################
	ECHO.
	ECHO %date%, %time%
	ECHO.
)
IF EXIST user.js (
	IF EXIST user.js.bak REN user.js.bak user.js.old.bak
	REN user.js user.js.bak
	ECHO Current user.js file backed up.
	ECHO.
)
ECHO Retrieving latest user.js file from github repository...
(
	powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/user.js', 'user.js')"
) >nul 2>&1
ECHO.
IF EXIST user.js (
	IF DEFINED _multi (
		ECHO Multiple overrides enabled. List of files found:
		FORFILES /P user.js-overrides /M *.js
		IF %ERRORLEVEL% EQU 0 (
			IF DEFINED _merge (
				ECHO.
				ECHO Merging...
				ECHO.
				COPY /B /V /Y user.js-overrides\*.js user-overrides
				CALL :merge user-overrides user-overrides-merged.js
				COPY /B /V /Y user.js+user-overrides-merged.js updatertempfile
				CALL :merge updatertempfile user.js
			) ELSE (
				ECHO.
				ECHO Appending...
				ECHO.
				COPY /B /V /Y user.js+"user.js-overrides\*.js" user.js
			)
		)
		ECHO.
	) ELSE (
		IF EXIST "user-overrides.js" (
			IF DEFINED _merge (
				ECHO Merging user-overrides.js...
				COPY /B /V /Y user.js+user-overrides.js updatertempfile
				CALL :merge updatertempfile user.js
			) ELSE (
				ECHO Appending user-overrides.js...
				ECHO.
				COPY /B /V /Y user.js+"user-overrides.js" "user.js"
			)
		) ELSE (
			ECHO user-overrides.js not found.
		)
		ECHO.
	)
	ECHO Handling backups...
	SET "changed="
	IF EXIST user.js.bak (
		FC user.js.bak user.js >nul && SET "changed=false" || SET "changed=true"
	)
	ECHO.
	ECHO.
	IF "!changed!"=="true" (
		IF EXIST user.js.old.bak DEL /F user.js.old.bak
		ECHO Update complete.
	) ELSE (
		IF "!changed!"=="false" (
			DEL /F user.js.bak
			IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
			ECHO Update completed without changes.
		) ELSE (
			ECHO Update complete.
		)
	)
	ECHO.
) ELSE (
	IF EXIST user.js.bak REN user.js.bak user.js
	IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
	ECHO.
	ECHO Update failed. Make sure PowerShell is allowed internet access.
	ECHO.
	ECHO No changes were made.
	ECHO.
)
IF NOT DEFINED _log (
	IF NOT DEFINED _ua PAUSE
)
EXIT /B

REM ###### Merge function ######
:merge
SETLOCAL disabledelayedexpansion
(
	FOR /F "tokens=1,* delims=]" %%G IN ('find /n /v "" ^< "%~1"') DO (
		SET "_pref=%%H"
		SETLOCAL enabledelayedexpansion
		SET "_temp=!_pref: =!"
		IF /I "user_pref"=="!_temp:~0,9!" (
			IF /I NOT "user.js.parrot"=="!_temp:~12,14!" (
				FOR /F "delims=," %%S IN ("!_pref!") DO (
					SET "_pref=%%S"
				)
				SET _pref=!_pref:"=""!
				FIND /I "!_pref!" %~2 >nul 2>&1
				IF ERRORLEVEL 1 (
					FOR /F "tokens=* delims=" %%X IN ('FIND /I "!_pref!" %~1') DO (
						SET "_temp=%%X"
						SET "_temp=!_temp: =!"
						IF /I "user_pref"=="!_temp:~0,9!" (
							SET "_pref=%%X"
						)
					)
					ECHO(!_pref!
				)
			) ELSE (
				ECHO(!_pref!
			)
		) ELSE (
			ECHO(!_pref!
		)
		ENDLOCAL
	)
)>%~2
ENDLOCAL
DEL /F %1 >nul
GOTO :EOF
REM ############################

@ECHO OFF
TITLE ghacks user.js updater

REM ### ghacks-user.js updater for Windows
REM ## author: @claustromaniac
REM ## version: 3.0

SET _myname=%~n0
SET _myparams=%*
SETLOCAL EnableDelayedExpansion
:parse
IF "%~1"=="" (
	GOTO endparse
)
IF /I "%~1"=="-unattended" (
	SET _ua=1
)
IF /I "%~1"=="-log" (
	SET _log=1
)
IF /I "%~1"=="-logp" (
	SET _log=1
	SET _logp=1
)
IF /I "%~1"=="-multioverrides" (
	SET _multi=1
)
IF /I "%~1"=="-merge" (
	SET _merge=1
)
IF /I "%~1"=="-updatebatch" (
	SET _updateb=1
)
SHIFT
GOTO parse
:endparse
ECHO.
IF DEFINED _updateb (
	IF NOT "!_myname:~0,9!"=="[updated]" (
		ECHO Checking updater version...
		ECHO.
		DEL /F "[updated]!_myname!.bat" 2>nul
		REM Uncomment the next line and comment the powershell call for testing.
		REM COPY /B /V /Y "!_myname!.bat" "[updated]!_myname!.bat"
		(
			powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/updater.bat', '[updated]!_myname!.bat')"
		) >nul 2>&1
		IF EXIST "[updated]!_myname!.bat" (
			START CMD /C "[updated]!_myname!.bat" !_myparams!
			EXIT /B
		) ELSE (
			ECHO Failed. Make sure PowerShell is allowed internet access.
			ECHO.
			PING -n 301 127.0.0.1>nul
			EXIT /B
		)
	) ELSE (
		IF EXIST "!_myname:~9!.bat" (
			DEL /F "!_myname:~9!.bat"
			CALL :begin
			REN "!_myname!.bat" "!_myname:~9!.bat"
			EXIT /B
		) ELSE (
			ECHO.
			ECHO The [updated] label is reserved. Do not run an [updated] script directly, or rename it to something else before you run it.
			PING -n 301 127.0.0.1>nul
			EXIT /B
		)
	)
)
:begin
SET /A "_line=0"
IF NOT EXIST user.js (
	ECHO user.js not detected in the current directory.
) ELSE (
	FOR /F "skip=1 tokens=1,2 delims=:" %%G IN (user.js) DO (
		SET /A "_line+=1"
		IF !_line! GEQ 4 (
			GOTO exitloop
		)
		IF !_line! EQU 1 (
			SET _name=%%H
		)
		IF !_line! EQU 2 (
			SET _date=%%H
		)
		IF !_line! EQU 3 (
			SET _version=%%G
		)
	)
	:exitloop
	IF !_line! GEQ 4 (
		IF /I NOT "!_name!"=="!_name:ghacks=X!" (
			ECHO ghacks user.js !_version:~2!,!_date!
		) ELSE (
			ECHO Current user.js version not recognised.
		)
	) ELSE (
		ECHO Current user.js version not recognised.
	)
)
ECHO.
IF NOT DEFINED _ua (
	ECHO.
	ECHO This batch should be run from your Firefox profile directory. It will download the latest version of ghacks user.js from github and then append any of your own changes from user-overrides.js to it.
	ECHO.
	REM ECHO Visit the wiki for more detailed information.
	REM ECHO.
	CHOICE /M "Continue"
	IF ERRORLEVEL 2 EXIT /B
)
CLS
ECHO.
IF DEFINED _log (
	CALL :log >>user.js-update-log.txt 2>&1
	IF DEFINED _logp (
		START user.js-update-log.txt
	)
	EXIT /B
	:log
	ECHO ##################################################################
	ECHO.
	ECHO %date%, %time%
	ECHO.
)
IF EXIST user.js (
	IF EXIST user.js.bak REN user.js.bak user.js.old.bak
	REN user.js user.js.bak
	ECHO Current user.js file backed up.
	ECHO.
)
ECHO Retrieving latest user.js file from github repository...
(
	powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/user.js', 'user.js')"
) >nul 2>&1
ECHO.
IF EXIST user.js (
	IF DEFINED _multi (
		ECHO Multiple overrides enabled. List of files found:
		FORFILES /P user.js-overrides /M *.js
		IF %ERRORLEVEL% EQU 0 (
			IF DEFINED _merge (
				ECHO.
				ECHO Merging...
				ECHO.
				COPY /B /V /Y user.js-overrides\*.js user-overrides
				CALL :merge user-overrides user-overrides-merged.js
				COPY /B /V /Y user.js+user-overrides-merged.js updatertempfile
				CALL :merge updatertempfile user.js
			) ELSE (
				ECHO.
				ECHO Appending...
				ECHO.
				COPY /B /V /Y user.js+"user.js-overrides\*.js" user.js
			)
		)
		ECHO.
	) ELSE (
		IF EXIST "user-overrides.js" (
			IF DEFINED _merge (
				ECHO Merging user-overrides.js...
				COPY /B /V /Y user.js+user-overrides.js updatertempfile
				CALL :merge updatertempfile user.js
			) ELSE (
				ECHO Appending user-overrides.js...
				ECHO.
				COPY /B /V /Y user.js+"user-overrides.js" "user.js"
			)
		) ELSE (
			ECHO user-overrides.js not found.
		)
		ECHO.
	)
	ECHO Handling backups...
	SET "changed="
	IF EXIST user.js.bak (
		FC user.js.bak user.js >nul && SET "changed=false" || SET "changed=true"
	)
	ECHO.
	ECHO.
	IF "!changed!"=="true" (
		IF EXIST user.js.old.bak DEL /F user.js.old.bak
		ECHO Update complete.
	) ELSE (
		IF "!changed!"=="false" (
			DEL /F user.js.bak
			IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
			ECHO Update completed without changes.
		) ELSE (
			ECHO Update complete.
		)
	)
	ECHO.
) ELSE (
	IF EXIST user.js.bak REN user.js.bak user.js
	IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
	ECHO.
	ECHO Update failed. Make sure PowerShell is allowed internet access.
	ECHO.
	ECHO No changes were made.
	ECHO.
)
IF NOT DEFINED _log (
	IF NOT DEFINED _ua PAUSE
)
EXIT /B

REM ###### Merge function ######
:merge
DEL /F %2 2>nul
SETLOCAL disabledelayedexpansion
FOR /F "tokens=1,* delims=]" %%G IN ('find /n /v "" ^< "%~1"') DO (
	SET "_pref=%%H"
	SETLOCAL enabledelayedexpansion
	SET "_temp=!_pref: =!"
	IF /I "user_pref"=="!_temp:~0,9!" (
		IF /I NOT "user.js.parrot"=="!_temp:~12,14!" (
			FOR /F "delims=," %%S IN ("!_pref!") DO (
				SET "_pref=%%S"
			)
			SET _pref=!_pref:"=""!
			FIND /I "!_pref!" %~2 >nul 2>&1
			IF ERRORLEVEL 1 (
				FOR /F "tokens=* delims=" %%X IN ('FIND /I "!_pref!" %~1') DO (
					SET "_temp=%%X"
					SET "_temp=!_temp: =!"
					IF /I "user_pref"=="!_temp:~0,9!" (
						SET "_pref=%%X"
					)
				)
				ECHO(!_pref!>>%~2
			)
		) ELSE (
			ECHO(!_pref!>>%~2
		)
	) ELSE (
		ECHO(!_pref!>>%~2
	)
	ENDLOCAL
)
ENDLOCAL
DEL /F %1 >nul
GOTO :EOF
REM ############################

Revert "2nd merge optimisation"

Revert "2nd merge optimisation"

This reverts commit c9e7f1ccfa6ff028151a5b7cf0dc2f60303dd831.


@echo off

cd %~dp0

if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help

@rem Process arguments.
set config=
set target=Build
set noprojgen=
set nobuild=
set run=
set target_arch=ia32
set vs_toolset=x86
set platform=WIN32

:next-arg
if "%1"=="" goto args-done
if /i "%1"=="debug"        set config=Debug&goto arg-ok
if /i "%1"=="release"      set config=Release&goto arg-ok
if /i "%1"=="test"         set run=run-tests.exe&goto arg-ok
if /i "%1"=="bench"        set run=run-benchmarks.exe&goto arg-ok
if /i "%1"=="clean"        set target=Clean&goto arg-ok
if /i "%1"=="noprojgen"    set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild"      set nobuild=1&goto arg-ok
if /i "%1"=="x86"          set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="ia32"         set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="x64"          set target_arch=x64&set platform=amd64&set vs_toolset=x64&goto arg-ok
if /i "%1"=="shared"       set library=shared_library&goto arg-ok
if /i "%1"=="static"       set library=static_library&goto arg-ok
:arg-ok
shift
goto next-arg
:args-done

@rem Look for Visual Studio 2010
if not defined VS100COMNTOOLS goto vc-set-2008
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2010
goto select-target

:vc-set-2008
@rem Look for Visual Studio 2008
if not defined VS90COMNTOOLS goto vc-set-notfound
if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
echo Warning: building with Visual Studio 2008 is currently not supported.
set GYP_MSVS_VERSION=2008
goto select-target

:vc-set-notfound
echo Warning: Visual Studio not found

:select-target
if not "%config%"=="" goto project-gen
if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
set config=Debug

:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild

@rem Generate the VS project.
if exist build\gyp goto have_gyp
echo svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
if errorlevel 1 goto gyp_install_failed
goto have_gyp

:gyp_install_failed
echo Failed to download gyp. Make sure you have subversion installed, or
echo manually install gyp into %~dp0build\gyp.
goto exit

:have_gyp
python gyp_uv -Dtarget_arch=%target_arch% -Dlibrary=%library%
if errorlevel 1 goto create-msvs-files-failed
if not exist uv.sln goto create-msvs-files-failed
echo Project files generated.

:msbuild
@rem Skip project generation if requested.
if defined nobuild goto run

@rem Check if VS build env is available
if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found

:msbuild-not-found
echo Build skipped. To build, this file needs to run from VS cmd prompt.
goto run

@rem Build the sln with msbuild.
:msbuild-found
msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto exit

:run
@rem Run tests if requested.
if "%run%"=="" goto exit
if not exist %config%\%run% goto exit
echo running '%config%\%run%'
%config%\%run%
goto exit

:create-msvs-files-failed
echo Failed to create vc project files.
goto exit

:help
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
echo Examples:
echo   vcbuild.bat              : builds debug build
echo   vcbuild.bat test         : builds debug build and runs tests
echo   vcbuild.bat release bench: builds release build and runs benchmarks
goto exit

:exit

@echo off

cd %~dp0

if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help

@rem Process arguments.
set config=
set target=Build
set noprojgen=
set nobuild=
set run=
set target_arch=ia32
set vs_toolset=x86
set platform=WIN32
set library=static_library

:next-arg
if "%1"=="" goto args-done
if /i "%1"=="debug"        set config=Debug&goto arg-ok
if /i "%1"=="release"      set config=Release&goto arg-ok
if /i "%1"=="test"         set run=run-tests.exe&goto arg-ok
if /i "%1"=="bench"        set run=run-benchmarks.exe&goto arg-ok
if /i "%1"=="clean"        set target=Clean&goto arg-ok
if /i "%1"=="noprojgen"    set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild"      set nobuild=1&goto arg-ok
if /i "%1"=="x86"          set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="ia32"         set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="x64"          set target_arch=x64&set platform=amd64&set vs_toolset=x64&goto arg-ok
if /i "%1"=="shared"       set library=shared_library&goto arg-ok
if /i "%1"=="static"       set library=static_library&goto arg-ok
:arg-ok
shift
goto next-arg
:args-done

@rem Look for Visual Studio 2010
if not defined VS100COMNTOOLS goto vc-set-2008
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2010
goto select-target

:vc-set-2008
@rem Look for Visual Studio 2008
if not defined VS90COMNTOOLS goto vc-set-notfound
if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
echo Warning: building with Visual Studio 2008 is currently not supported.
set GYP_MSVS_VERSION=2008
goto select-target

:vc-set-notfound
echo Warning: Visual Studio not found

:select-target
if not "%config%"=="" goto project-gen
if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
set config=Debug

:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild

@rem Generate the VS project.
if exist build\gyp goto have_gyp
echo svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
if errorlevel 1 goto gyp_install_failed
goto have_gyp

:gyp_install_failed
echo Failed to download gyp. Make sure you have subversion installed, or
echo manually install gyp into %~dp0build\gyp.
goto exit

:have_gyp
python gyp_uv -Dtarget_arch=%target_arch% -Dlibrary=%library%
if errorlevel 1 goto create-msvs-files-failed
if not exist uv.sln goto create-msvs-files-failed
echo Project files generated.

:msbuild
@rem Skip project generation if requested.
if defined nobuild goto run

@rem Check if VS build env is available
if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found

:msbuild-not-found
echo Build skipped. To build, this file needs to run from VS cmd prompt.
goto run

@rem Build the sln with msbuild.
:msbuild-found
msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto exit

:run
@rem Run tests if requested.
if "%run%"=="" goto exit
if not exist %config%\%run% goto exit
echo running '%config%\%run%'
%config%\%run%
goto exit

:create-msvs-files-failed
echo Failed to create vc project files.
goto exit

:help
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
echo Examples:
echo   vcbuild.bat              : builds debug build
echo   vcbuild.bat test         : builds debug build and runs tests
echo   vcbuild.bat release bench: builds release build and runs benchmarks
goto exit

:exit

fix vcbuild.bat issue

windows: fix vcbuild.bat issue

gyp_uv was complaining because it never receives a value for which type
of library to build (static vs shared). This makes vcbuild.bat set the
default to build a static library.


Add Build Time

Add Build Time


@echo off

mkdir build
cd build

rem Python 3.x not supported by OpenCV 2.x
if %ARCH%==32 (
  if %PY_VER% LSS 3 (
    set CMAKE_GENERATOR="Visual Studio 9 2008"
    set CMAKE_CONFIG="Release"
	set OPENCV_ARCH=x86
	set OPENCV_VC=vc9
  )
)
if %ARCH%==64 (
  if %PY_VER% LSS 3 (
    set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"
    set CMAKE_CONFIG="Release"
	set OPENCV_ARCH=x64
	set OPENCV_VC=vc9
  )
)

rem I had to take out the PNG_LIBRARY because it included
rem a Windows path which caused it to be wrongly escaped
rem and thus an error. Somehow though, CMAKE still finds
rem the correct png library...
cmake .. -G%CMAKE_GENERATOR%                        ^
    -DBUILD_TESTS=0                                 ^
    -DBUILD_DOCS=0                                  ^
    -DBUILD_PERF_TESTS=0                            ^
    -DBUILD_ZLIB=1                                  ^
    -DBUILD_TIFF=1                                  ^
    -DBUILD_PNG=1                                   ^
    -DBUILD_OPENEXR=1                               ^
    -DBUILD_JASPER=1                                ^
    -DBUILD_JPEG=1                                  ^
    -DPYTHON_EXECUTABLE="%PYTHON%"                  ^
    -DPYTHON_INCLUDE_PATH="%PREFIX%\include"        ^
    -DPYTHON_LIBRARY="%PREFIX%\libs\python27.lib"   ^
    -DPYTHON_PACKAGES_PATH="%SP_DIR%"               ^
    -DWITH_CUDA=0                                   ^
    -DWITH_OPENCL=0                                 ^
    -DWITH_OPENNI=0                                 ^
    -DWITH_FFMPEG=1                                 ^
    -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%"

cmake --build . --config %CMAKE_CONFIG% --target ALL_BUILD
cmake --build . --config %CMAKE_CONFIG% --target INSTALL

if errorlevel 1 exit 1

rem Let's just move the files around to a more sane structure (flat)
move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\bin\*.dll" "%LIBRARY_BIN%"
move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\bin\*.exe" "%LIBRARY_BIN%"
move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\lib\*.lib" "%LIBRARY_LIB%"
rmdir "%LIBRARY_PREFIX%\%OPENCV_ARCH%" /S /Q

rem By default cv.py is installed directly in site-packages
rem Therefore, we have to copy all of the dlls directly into it!
xcopy "%LIBRARY_BIN%\opencv*.dll" "%SP_DIR%"

@echo off

mkdir build
cd build

rem Python 3.x not supported by OpenCV 2.x
if %ARCH%==32 (
  if %PY_VER% LSS 3 (
    set CMAKE_GENERATOR="Visual Studio 9 2008"
    set CMAKE_CONFIG="Release"
	set OPENCV_ARCH=x86
	set OPENCV_VC=vc9
  )
)
if %ARCH%==64 (
  if %PY_VER% LSS 3 (
    set CMAKE_GENERATOR="Visual Studio 9 2008 Win64"
    set CMAKE_CONFIG="Release"
	set OPENCV_ARCH=x64
	set OPENCV_VC=vc9
  )
)

rem I had to take out the PNG_LIBRARY because it included
rem a Windows path which caused it to be wrongly escaped
rem and thus an error. Somehow though, CMAKE still finds
rem the correct png library...
cmake .. -G%CMAKE_GENERATOR%                        ^
    -DBUILD_TESTS=0                                 ^
    -DBUILD_DOCS=0                                  ^
    -DBUILD_PERF_TESTS=0                            ^
    -DBUILD_ZLIB=1                                  ^
    -DBUILD_TIFF=1                                  ^
    -DBUILD_PNG=1                                   ^
    -DBUILD_OPENEXR=1                               ^
    -DBUILD_JASPER=1                                ^
    -DBUILD_JPEG=1                                  ^
    -DPYTHON_EXECUTABLE="%PYTHON%"                  ^
    -DPYTHON_INCLUDE_PATH="%PREFIX%\include"        ^
    -DPYTHON_LIBRARY="%PREFIX%\libs\python27.lib"   ^
    -DPYTHON_PACKAGES_PATH="%SP_DIR%"               ^
    -DWITH_CUDA=0                                   ^
    -DWITH_OPENCL=0                                 ^
    -DWITH_OPENNI=0                                 ^
    -DWITH_FFMPEG=0                                 ^
    -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%"

cmake --build . --config %CMAKE_CONFIG% --target ALL_BUILD
cmake --build . --config %CMAKE_CONFIG% --target INSTALL

if errorlevel 1 exit 1

rem Let's just move the files around to a more sane structure (flat)
move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\bin\*.dll" "%LIBRARY_BIN%"
move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\bin\*.exe" "%LIBRARY_BIN%"
move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\lib\*.lib" "%LIBRARY_LIB%"
rmdir "%LIBRARY_PREFIX%\%OPENCV_ARCH%" /S /Q

rem By default cv.py is installed directly in site-packages
rem Therefore, we have to copy all of the dlls directly into it!
xcopy "%LIBRARY_BIN%\opencv*.dll" "%SP_DIR%"

Remove FFMPEG from Windows

Remove FFMPEG from Windows


@echo off
set GAMEID=test
set ASSETPATH="E:\Games\Planetside 2 Test\Resources\Assets"

for /f "delims=" %%a in ('external\date.exe +%%Y%%m%%d_%%H%%M%%S') do @set timestamp=%%a
mkdir assets\%GAMEID%\all_%timestamp%
node packer.js extractall %ASSETPATH% assets\%GAMEID%\all_%timestamp%
pause

@echo off
set GAMEID=test
set ASSETPATH="E:\Games\Planetside 2 Test\Resources\Assets"

for /f "delims=" %%a in ('..\external\date.exe +%%Y%%m%%d_%%H%%M%%S') do @set timestamp=%%a
mkdir ..\assets\%GAMEID%\all_%timestamp%
node ..\packer.js extractall %ASSETPATH% ..\assets\%GAMEID%\all_%timestamp%
pause

fix new paths

fix new paths


@echo off
setlocal

if "%~1" equ "" goto :wrongSyntax

if not defined CMDER_USER_FLAGS (
  :: in case nothing was passed to %CMDER_USER_FLAGS%
  set "CMDER_USER_FLAGS= "
)

set "feNot=false"
goto :parseArgument

:doShift
  shift

:parseArgument
set "currenArgu=%~1"
if /i "%currenArgu%" equ "/setPath" (
  :: set %flag_exists% shortcut
  endlocal
  set "ccall=call %~dp0cexec.cmd"
  set "cexec=%~dp0cexec.cmd"
) else if /i "%currenArgu%" == "/?" (
  goto :help
) else if /i "%currenArgu%" equ "/help" (
  goto :help
) else if /i "%currenArgu%" equ "/h" (
  goto :help
) else if /i "%currenArgu%" equ "NOT" (
  set "feNot=true"
  goto :doShift
) else (
  if "%~1" equ "" goto :wrongSyntax
  if "%~2" equ "" goto :wrongSyntax
  set "feFlagName=%~1"
  set "feCommand=%~2"
  if not "%~3" equ "" (
    set "feParam=%~3"
  )
  goto :detect
)

:detect
:: to avoid erroneous deteciton like "/do" "/doNOT", which both have a "/do"
:: we added a space after the flag name, like "/do ", which won't match "/doN"
set "feFlagName=%feFlagName% "
:: echo.
:: echo %CMDER_USER_FLAGS%
:: echo %feNOT%
:: echo %feFlagName%
:: echo %feCommand%
:: echo %feParam%
:: echo.
echo %CMDER_USER_FLAGS% | find /i "%feFlagName%">nul
if "%ERRORLEVEL%" == "0" (
  if "%feNOT%" == "false" (
    call %feCommand% %feParam%
    exit /b 0
  )
) else (
  if "%feNOT%" == "true" (
    call %feCommand% %feParam%
    exit /b 0
  )
)
endlocal
exit /b 1

:wrongSyntax
echo The syntax of the command is incorrect.
echo.
echo use /? for help
echo.
endlocal
exit /b

:help
echo.
echo CExec - Conditional Exec
echo.
echo Handles with custom arguments for cmder's init.bat.
echo   written by xiazeyu, inspired DRSDavidSoft.
echo.
echo Usage:
echo.
echo cexec /setPath [NOT] flagName command/program [parameters]
echo.
echo   /setPath         Generate a global varible %%cexec%% for
echo                    quicker use. Following arguments will be ignored.
echo.
echo   NOT              Specifies that cexec should carry out
echo                    the command only if the flag is missing.
echo.
echo   /[flagName]      Specifies which flag name is to detect. It's recommand
echo                    to use a pair of double quotation marks to wrap
echo                    your flag name to avoid exceed expectation.
echo.
echo   command/program  Specifies the command to carry out if the
echo                    argument name is detected. It's recommand to
echo                    use a pair of double quotation marks to
echo                    wrap your command to avoid exceed expectation.
echo.
echo   parameters       These are the parameters passed to the command/program.
echo                    It's recommand to use a pair of double quotation marks
echo                    to wrap your flag name to avoid exceed expectation.
echo.
echo Examples:
echo.
echo   These examples are expected to be written in %cmder_root%/config/user-profile.cmd
echo   CExec evaluates the environment varible "CMDER_USER_FLAGS" and conditionally
echo   caries out actions based on flags that are passed.
echo.
echo   Case 1:
echo.
echo   The following command in user-profile.cmd would execute "notepad.exe"
echo.
echo     call cexec "/startNotepad" "start" "notepad.exe"
echo.
echo   If you pass parameter to init.bat like:
echo.
echo     init.bat /startNotepad
echo.
echo   Case 2:
echo.
echo   The following command in user-profile.cmd would execute "notepad.exe"
echo.
echo     call cexec NOT "/dontStartNotepad" "start" "notepad.exe"
echo.
echo   UNLESS you pass parameter to init.bat like:
echo.
echo     init.bat /dontStartNotepad
echo.
endlocal
exit /b

@echo off
setlocal

if "%~1" equ "" goto :wrongSyntax

if not defined CMDER_USER_FLAGS (
  :: in case nothing was passed to %CMDER_USER_FLAGS%
  set "CMDER_USER_FLAGS= "
)

set "feNot=false"
goto :parseArgument

:doShift
  shift

:parseArgument
set "currenArgu=%~1"
if /i "%currenArgu%" equ "/setPath" (
  :: set %flag_exists% shortcut
  endlocal
  set "ccall=call %~dp0cexec.cmd"
  set "cexec=%~dp0cexec.cmd"
) else if /i "%currenArgu%" == "/?" (
  goto :help
) else if /i "%currenArgu%" equ "/help" (
  goto :help
) else if /i "%currenArgu%" equ "/h" (
  goto :help
) else if /i "%currenArgu%" equ "NOT" (
  set "feNot=true"
  goto :doShift
) else (
  if "%~1" equ "" goto :wrongSyntax
  if "%~2" equ "" goto :wrongSyntax
  set "feFlagName=%~1"
  set "feCommand=%~2"
  if not "%~3" equ "" (
    set "feParam=%~3"
  )
  goto :detect
)

:detect
:: to avoid erroneous deteciton like "/do" "/doNOT", which both have a "/do"
:: we added a space after the flag name, like "/do ", which won't match "/doN"
set "feFlagName=%feFlagName% "
:: echo.
:: echo %CMDER_USER_FLAGS%
:: echo %feNOT%
:: echo %feFlagName%
:: echo %feCommand%
:: echo %feParam%
:: echo.
echo %CMDER_USER_FLAGS% | find /i "%feFlagName%">nul
if "%ERRORLEVEL%" == "0" (
  if "%feNOT%" == "false" (
    endlocal && call %feCommand% %feParam%
    exit /b 0
  )
) else (
  if "%feNOT%" == "true" (
    endlocal && call %feCommand% %feParam%
    exit /b 0
  )
)
endlocal
exit /b 1

:wrongSyntax
echo The syntax of the command is incorrect.
echo.
echo use /? for help
echo.
endlocal
exit /b

:help
echo.
echo CExec - Conditional Exec
echo.
echo Handles with custom arguments for cmder's init.bat.
echo   written by xiazeyu, inspired DRSDavidSoft.
echo.
echo Usage:
echo.
echo cexec /setPath [NOT] flagName command/program [parameters]
echo.
echo   /setPath         Generate a global varible %%cexec%% for
echo                    quicker use. Following arguments will be ignored.
echo.
echo   NOT              Specifies that cexec should carry out
echo                    the command only if the flag is missing.
echo.
echo   /[flagName]      Specifies which flag name is to detect. It's recommand
echo                    to use a pair of double quotation marks to wrap
echo                    your flag name to avoid exceed expectation.
echo.
echo   command/program  Specifies the command to carry out if the
echo                    argument name is detected. It's recommand to
echo                    use a pair of double quotation marks to
echo                    wrap your command to avoid exceed expectation.
echo.
echo   parameters       These are the parameters passed to the command/program.
echo                    It's recommand to use a pair of double quotation marks
echo                    to wrap your flag name to avoid exceed expectation.
echo.
echo Examples:
echo.
echo   These examples are expected to be written in %cmder_root%/config/user-profile.cmd
echo   CExec evaluates the environment varible "CMDER_USER_FLAGS" and conditionally
echo   caries out actions based on flags that are passed.
echo.
echo   Case 1:
echo.
echo   The following command in user-profile.cmd would execute "notepad.exe"
echo.
echo     call cexec "/startNotepad" "start" "notepad.exe"
echo.
echo   If you pass parameter to init.bat like:
echo.
echo     init.bat /startNotepad
echo.
echo   Case 2:
echo.
echo   The following command in user-profile.cmd would execute "notepad.exe"
echo.
echo     call cexec NOT "/dontStartNotepad" "start" "notepad.exe"
echo.
echo   UNLESS you pass parameter to init.bat like:
echo.
echo     init.bat /dontStartNotepad
echo.
endlocal
exit /b

allow conditionally setting environment variables


@echo off

rmdir /s /q "%USERPROFILE%/zpm-install" 2>NUL

set root=%cd%

mkdir "%USERPROFILE%/zpm-install"
cd "%USERPROFILE%/zpm-install"

if exist "premake5.zip" del /q "premake5.zip"

powershell -command "Invoke-WebRequest -Uri https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe"

if defined GH_TOKEN (
    powershell -command "Invoke-WebRequest -Uri https://github.com/premake/premake-core/releases/download/v5.0.0-alpha11/premake-5.0.0-alpha11-windows.zip -OutFile premake5.zip -Headers @{'Authorization'='token %GH_TOKEN%'}"
) else (
    powershell -command "Invoke-WebRequest -Uri https://github.com/premake/premake-core/releases/download/v5.0.0-alpha11/premake-5.0.0-alpha11-windows.zip -OutFile premake5.zip"
)
echo Finished downloading premake...

powershell -command "Expand-Archive premake5.zip -DestinationPath ."

git clone https://github.com/Zefiros-Software/ZPM.git ./zpm --depth 1 -b features/refactor

for /f "tokens=*" %%i in ('.\premake5 show install --file=zpm/zpm.lua') do set ZPM_DIR=%%i
set CONDA_DIR="%ZPM_DIR%/conda/"
echo %CONDA_DIR%
start /wait "" miniconda.exe /RegisterPython=0 /AddToPath=0 /S /D=%CONDA_DIR%

echo Finished cloning ZPM...

if defined GH_TOKEN (
    premake5.exe --github-token=%GH_TOKEN% --file=zpm/zpm.lua install zpm
) else (
    premake5.exe --file=zpm/zpm.lua install zpm
)

cd %root%

rmdir /s /q "%USERPROFILE%/zpm-install"

echo ZPM is installed, however a restart is required!

SET PATH=%PATH%;%USERPROFILE%\zpm\bin\

@echo off

rmdir /s /q "%USERPROFILE%/zpm-install" 2>NUL

set root=%cd%

mkdir "%USERPROFILE%/zpm-install"
cd "%USERPROFILE%/zpm-install"

if exist "premake5.zip" del /q "premake5.zip"

powershell -command "Invoke-WebRequest -Uri https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe"

if defined GH_TOKEN (
    powershell -command "Invoke-WebRequest -Uri https://github.com/premake/premake-core/releases/download/v5.0.0-alpha11/premake-5.0.0-alpha11-windows.zip -OutFile premake5.zip -Headers @{'Authorization'='token %GH_TOKEN%'}"
) else (
    powershell -command "Invoke-WebRequest -Uri https://github.com/premake/premake-core/releases/download/v5.0.0-alpha11/premake-5.0.0-alpha11-windows.zip -OutFile premake5.zip"
)
echo Finished downloading premake...

powershell -command "Expand-Archive premake5.zip -DestinationPath ."

git clone https://github.com/Zefiros-Software/ZPM.git ./zpm --depth 1 -b features/refactor

for /f "tokens=*" %%i in ('.\premake5 show install --file=zpm/zpm.lua') do set ZPM_DIR=%%i
set CONDA_DIR="%ZPM_DIR%/conda/"
echo %CONDA_DIR%
echo %ZPM_DIR%
start /wait "" miniconda.exe /RegisterPython=0 /AddToPath=0 /S /D=%CONDA_DIR%

echo Finished cloning ZPM...

if defined GH_TOKEN (
    premake5.exe --github-token=%GH_TOKEN% --file=zpm/zpm.lua install zpm
) else (
    premake5.exe --file=zpm/zpm.lua install zpm
)

cd %root%

rmdir /s /q "%USERPROFILE%/zpm-install"

echo ZPM is installed, however a restart is required!

SET PATH=%PATH%;%USERPROFILE%\zpm\bin\

Debug windows install

Debug windows install


Change the default port

Change the default port


REM create the Dependencies.7z file, placing it in the Downloads folder
REM it's meant to be called from a cea-aware conda environment

REM Make sure we have access to the executables needed for this
SET PATH=C:\Program Files\7-Zip;%PATH%
PUSHD %USERPROFILE%\Downloads
REM %~dp0
CALL conda env remove -n cea
CALL conda env create -n cea -f "%~dp0..\environment.yml"
CALL conda activate cea
WHERE python
CALL python -m pip install "%~dp0.."
CALL python -m pip install "%~dp0..\..\cea-workflow-utils"
CALL python -m pip install pandana urbanaccess
CALL python -m pip install jupyter ipython
CALL python -m pip install sphinx
CALL conda deactivate
DEL /F/Q cea.zip
CALL conda-pack -n cea -j -1 --format zip
DEL /F/Q/S "%USERPROFILE%\Downloads\Dependencies" > NUL
RMDIR /Q/S "%USERPROFILE%\Downloads\Dependencies
CALL 7z x cea.zip -oDependencies\Python -y
CALL 7z a Dependencies.7z Dependencies\ -x9 -sdel

REM create the Dependencies.7z file, placing it in the Downloads folder
REM it's meant to be called from a cea-aware conda environment

REM Make sure we have access to the executables needed for this
SET PATH=C:\Program Files\7-Zip;%PATH%
PUSHD %USERPROFILE%\Downloads
REM %~dp0
CALL conda env remove -n cea
CALL conda env create -n cea -f "%~dp0..\environment.yml"
CALL conda activate cea
WHERE python
CALL python -m pip install "%~dp0.."
CALL python -m pip install "%~dp0..\..\cea-workflow-utils"
CALL python -m pip install pandana urbanaccess
CALL python -m pip install jupyter ipython
CALL python -m pip install sphinx
CALL conda deactivate
DEL /F/Q cea.zip
DEL /F/Q Dependencies.7z
CALL conda-pack -n cea -j -1 --format zip
DEL /F/Q/S "%USERPROFILE%\Downloads\Dependencies" > NUL
RMDIR /Q/S "%USERPROFILE%\Downloads\Dependencies
CALL 7z x cea.zip -oDependencies\Python -y
CALL 7z a Dependencies.7z Dependencies\ -mx9 -sdel

Update build-dependencies.bat

Update build-dependencies.bat


@echo off

rem   Licensed to the Apache Software Foundation (ASF) under one or more
rem   contributor license agreements.  See the NOTICE file distributed with
rem   this work for additional information regarding copyright ownership.
rem   The ASF licenses this file to You under the Apache License, Version 2.0
rem   (the "License"); you may not use this file except in compliance with
rem   the License.  You may obtain a copy of the License at
rem
rem       http://www.apache.org/licenses/LICENSE-2.0
rem
rem   Unless required by applicable law or agreed to in writing, software
rem   distributed under the License is distributed on an "AS IS" BASIS,
rem   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem   See the License for the specific language governing permissions and
rem   limitations under the License.

rem   =====================================================
rem   Environment variables that can be defined externally:
rem
rem   JMETER_BIN - JMeter bin directory (must end in \)
rem   JM_LAUNCH - java.exe (default) or javaw.exe
rem   JVM_ARGS - additional java options, e.g. -Dprop=val
rem   JM_START - set this to "start" to launch JMeter in a separate window
rem              this is used by the jmeterw.cmd script.
rem
rem   =====================================================

setlocal

rem Minimal version to run JMeter
set MINIMAL_VERSION=1.6.0

for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
    rem @echo Debug Output: %%g
    set JAVAVER=%%g
)
if not defined JAVAVER (
    @echo Not able to find Java executable or version. Please check your Java installation.
    set ERRORLEVEL=2
    goto pause
)
set JAVAVER=%JAVAVER:"=%
for /f "delims=. tokens=1-3" %%v in ("%JAVAVER%") do (
    set current_minor=%%w
)

for /f "delims=. tokens=1-3" %%v in ("%MINIMAL_VERSION%") do (
    set minimal_minor=%%w
)

if not defined current_minor (
    @echo Not able to find Java executable or version. Please check your Java installation.
    set ERRORLEVEL=2
    goto pause
)
rem @echo Debug: CURRENT=%current_minor% - MINIMAL=%minimal_minor%
if %current_minor% LSS %minimal_minor% (
    @echo Error: Java version -- %JAVAVER% -- is too low to run JMeter. Needs a Java version greater than or equal to %MINIMAL_VERSION%
    set ERRORLEVEL=3
    goto pause
)

if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe

if exist jmeter.bat goto winNT1
if .%JMETER_BIN% == . set JMETER_BIN=%~dp0

:winNT1
rem On NT/2K grab all arguments at once
set JMETER_CMD_LINE_ARGS=%*

rem The following link describes the -XX options:
rem http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
rem http://java.sun.com/developer/TechTips/2000/tt1222.html has some more descriptions
rem Unfortunately TechTips no longer seem to be available

rem See the unix startup file for the rationale of the following parameters,
rem including some tuning recommendations
set HEAP=-Xms512m -Xmx512m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=128m
set SURVIVOR=-XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=50%
set TENURING=-XX:MaxTenuringThreshold=2
rem Java 8 remove Permanent generation, don't settings the PermSize
if %current_minor% LEQ "8" (
    rem Increase MaxPermSize if you use a lot of Javascript in your Test Plan :
    set PERM=-XX:PermSize=64m -XX:MaxPermSize=128m
)

set CLASS_UNLOAD=-XX:+CMSClassUnloadingEnabled
rem set DEBUG=-verbose:gc -XX:+PrintTenuringDistribution

rem Always dump on OOM (does not cost anything unless triggered)
set DUMP=-XX:+HeapDumpOnOutOfMemoryError

rem Additional settings that might help improve GUI performance on some platforms
rem See: http://java.sun.com/products/java-media/2D/perf_graphics.html

set DDRAW=
rem  Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
rem set DDRAW=%DDRAW% -Dsun.java2d.noddraw=true

rem  Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
rem set DDRAW=%DDRAW% -Dsun.java2d.ddoffscreen=false

rem Setting this flag to true enables hardware-accelerated scaling.
rem set DDRAW=%DDRAW% -Dsun.java2d.ddscale=true

rem Server mode
rem Collect the settings defined above
set ARGS=%DUMP% %HEAP% %NEW% %SURVIVOR% %TENURING% %PERM% %CLASS_UNLOAD% %DDRAW%

%JM_START% %JM_LAUNCH% %ARGS% %JVM_ARGS% -jar "%JMETER_BIN%ApacheJMeter.jar" %JMETER_CMD_LINE_ARGS%

rem If the errorlevel is not zero, then display it and pause

if NOT errorlevel 0 goto pause
if errorlevel 1 goto pause

goto end

:pause
echo errorlevel=%ERRORLEVEL%
pause

:end

@echo off

rem   Licensed to the Apache Software Foundation (ASF) under one or more
rem   contributor license agreements.  See the NOTICE file distributed with
rem   this work for additional information regarding copyright ownership.
rem   The ASF licenses this file to You under the Apache License, Version 2.0
rem   (the "License"); you may not use this file except in compliance with
rem   the License.  You may obtain a copy of the License at
rem
rem       http://www.apache.org/licenses/LICENSE-2.0
rem
rem   Unless required by applicable law or agreed to in writing, software
rem   distributed under the License is distributed on an "AS IS" BASIS,
rem   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem   See the License for the specific language governing permissions and
rem   limitations under the License.

rem   =====================================================
rem   Environment variables that can be defined externally:
rem
rem   JMETER_BIN - JMeter bin directory (must end in \)
rem   JM_LAUNCH - java.exe (default) or javaw.exe
rem   JVM_ARGS - additional java options, e.g. -Dprop=val
rem   JM_START - set this to "start" to launch JMeter in a separate window
rem              this is used by the jmeterw.cmd script.
rem
rem   =====================================================

setlocal

rem Minimal version to run JMeter
set MINIMAL_VERSION=1.7.0

for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
    rem @echo Debug Output: %%g
    set JAVAVER=%%g
)
if not defined JAVAVER (
    @echo Not able to find Java executable or version. Please check your Java installation.
    set ERRORLEVEL=2
    goto pause
)
set JAVAVER=%JAVAVER:"=%
for /f "delims=. tokens=1-3" %%v in ("%JAVAVER%") do (
    set current_minor=%%w
)

for /f "delims=. tokens=1-3" %%v in ("%MINIMAL_VERSION%") do (
    set minimal_minor=%%w
)

if not defined current_minor (
    @echo Not able to find Java executable or version. Please check your Java installation.
    set ERRORLEVEL=2
    goto pause
)
rem @echo Debug: CURRENT=%current_minor% - MINIMAL=%minimal_minor%
if %current_minor% LSS %minimal_minor% (
    @echo Error: Java version -- %JAVAVER% -- is too low to run JMeter. Needs a Java version greater than or equal to %MINIMAL_VERSION%
    set ERRORLEVEL=3
    goto pause
)

if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe

if exist jmeter.bat goto winNT1
if .%JMETER_BIN% == . set JMETER_BIN=%~dp0

:winNT1
rem On NT/2K grab all arguments at once
set JMETER_CMD_LINE_ARGS=%*

rem The following link describes the -XX options:
rem http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
rem http://java.sun.com/developer/TechTips/2000/tt1222.html has some more descriptions
rem Unfortunately TechTips no longer seem to be available

rem See the unix startup file for the rationale of the following parameters,
rem including some tuning recommendations
set HEAP=-Xms512m -Xmx512m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=128m
set SURVIVOR=-XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=50%
set TENURING=-XX:MaxTenuringThreshold=2
rem Java 8 remove Permanent generation, don't settings the PermSize
if %current_minor% LEQ "8" (
    rem Increase MaxPermSize if you use a lot of Javascript in your Test Plan :
    set PERM=-XX:PermSize=64m -XX:MaxPermSize=128m
)

set CLASS_UNLOAD=-XX:+CMSClassUnloadingEnabled
rem set DEBUG=-verbose:gc -XX:+PrintTenuringDistribution

rem Always dump on OOM (does not cost anything unless triggered)
set DUMP=-XX:+HeapDumpOnOutOfMemoryError

rem Additional settings that might help improve GUI performance on some platforms
rem See: http://java.sun.com/products/java-media/2D/perf_graphics.html

set DDRAW=
rem  Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
rem set DDRAW=%DDRAW% -Dsun.java2d.noddraw=true

rem  Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
rem set DDRAW=%DDRAW% -Dsun.java2d.ddoffscreen=false

rem Setting this flag to true enables hardware-accelerated scaling.
rem set DDRAW=%DDRAW% -Dsun.java2d.ddscale=true

rem Server mode
rem Collect the settings defined above
set ARGS=%DUMP% %HEAP% %NEW% %SURVIVOR% %TENURING% %PERM% %CLASS_UNLOAD% %DDRAW%

%JM_START% %JM_LAUNCH% %ARGS% %JVM_ARGS% -jar "%JMETER_BIN%ApacheJMeter.jar" %JMETER_CMD_LINE_ARGS%

rem If the errorlevel is not zero, then display it and pause

if NOT errorlevel 0 goto pause
if errorlevel 1 goto pause

goto end

:pause
echo errorlevel=%ERRORLEVEL%
pause

:end

Update windows jmeter start script to force a minimum of java 7. Thanks Andrey for reminding - again.

Bugzilla Id: 57981

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1700299 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: d84ac497b9b869a8511f83335f424f71c44590ff


@echo OFF

REM ##############################################################################
REM ##
REM ##  Continuuity Reactor start up script for WINDOWS
REM ##  Copyright 2012-2014 Continuuity,Inc. All Rights Reserved.
REM ##
REM ##############################################################################

SET CONTINUUITY_HOME=%~dp0
SET CONTINUUITY_HOME=%CONTINUUITY_HOME:~0,-5%
SET JAVACMD=%JAVA_HOME%\bin\java.exe

SET CLASSPATH=%CONTINUUITY_HOME%\lib\*;%CONTINUUITY_HOME%\conf\
SET PATH=%PATH%;%CONTINUUITY_HOME%\libexec\bin

REM Check for 64-bit version of OS. Currently not supporting 32-bit Windows
IF NOT EXIST "%PROGRAMFILES(X86)%" (
  echo 32-bit Windows operating system is currently not supported
  GOTO :FINALLY
)

REM Check for correct setting for JAVA_HOME path
if [%JAVA_HOME%] == [] (
  echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  echo Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
  GOTO :FINALLY
)

REM Check for Java version
setlocal ENABLEDELAYEDEXPANSION
set /a counter=0
for /f "tokens=* delims= " %%f in ('%JAVACMD% -version 2^>^&1') do @(
  if "!counter!"=="0" set line=%%f
  set /a counter+=1
)
set line=%line:java version "1.=!!%
set line=%line:~0,1%
if NOT "%line%" == "6" (
  if NOT "%line%" == "7" (
    echo ERROR: Java version not supported. Please install Java 6 or 7 - other versions of Java are not yet supported.
    GOTO :FINALLY
  )
)
endlocal

mkdir %CONTINUUITY_HOME%\logs > NUL 2>&1

set auth_file=%~dp0access_token
REM check if token-file is provided. if not use the default file
set tokenFileProvided=false
for %%a in (%*) do (
  if "%%a" == "--file" (
    set tokenFileProvided=true
  )
)

if "%tokenFileProvided%" == "true" (
  %JAVACMD% -classpath %CLASSPATH% com.continuuity.security.tools.AccessTokenClient %*
)
if "%tokenFileProvided%" == "false" (
  %JAVACMD% -classpath %CLASSPATH% com.continuuity.security.tools.AccessTokenClient %* --file %auth_file%
)

:FINALLY

@echo OFF

REM ##############################################################################
REM ##
REM ##  Continuuity Reactor start up script for WINDOWS
REM ##  Copyright 2012-2014 Continuuity,Inc. All Rights Reserved.
REM ##
REM ##############################################################################

SET CONTINUUITY_HOME=%~dp0
SET CONTINUUITY_HOME=%CONTINUUITY_HOME:~0,-5%
SET JAVACMD=%JAVA_HOME%\bin\java.exe

SET CLASSPATH=%CONTINUUITY_HOME%\lib\*;%CONTINUUITY_HOME%\conf\
SET PATH=%PATH%;%CONTINUUITY_HOME%\libexec\bin

REM Check for 64-bit version of OS. Currently not supporting 32-bit Windows
IF NOT EXIST "%PROGRAMFILES(X86)%" (
  echo 32-bit Windows operating system is currently not supported
  GOTO :FINALLY
)

REM Check for correct setting for JAVA_HOME path
if [%JAVA_HOME%] == [] (
  echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  echo Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
  GOTO :FINALLY
)

REM Check for Java version
setlocal ENABLEDELAYEDEXPANSION
set /a counter=0
for /f "tokens=* delims= " %%f in ('%JAVACMD% -version 2^>^&1') do @(
  if "!counter!"=="0" set line=%%f
  set /a counter+=1
)
set line=%line:java version "1.=!!%
set line=%line:~0,1%
if NOT "%line%" == "6" (
  if NOT "%line%" == "7" (
    echo ERROR: Java version not supported. Please install Java 6 or 7 - other versions of Java are not yet supported.
    GOTO :FINALLY
  )
)
endlocal

mkdir %CONTINUUITY_HOME%\logs > NUL 2>&1

set auth_file=%HOMEPATH%\.continuuity.accesstoken
REM check if token-file is provided. if not use the default file
set tokenFileProvided=false
for %%a in (%*) do (
  if "%%a" == "--file" (
    set tokenFileProvided=true
  )
)

if "%tokenFileProvided%" == "true" (
  %JAVACMD% -classpath %CLASSPATH% com.continuuity.security.tools.AccessTokenClient %*
)
if "%tokenFileProvided%" == "false" (
  %JAVACMD% -classpath %CLASSPATH% com.continuuity.security.tools.AccessTokenClient %* --file %auth_file%
)

:FINALLY

Fix filepath for Windows

Fix filepath for Windows