@echo off
setlocal enabledelayedexpansion

REM ///////////////////////////////////////////////////////////////////////////
REM // Set Paths
REM ///////////////////////////////////////////////////////////////////////////
set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
set "UPX3_PATH=C:\Program Files (x86)\UPX"
set "PDOC_PATH=C:\Program Files (x86)\Pandoc"
set "QT_SOURCE=C:\Qt\4.8.6"
set "QT_SHARED=C:\Qt\4.8.6-Shared"
set "QT_STATIC=C:\Qt\4.8.6-Static"
set "JDK8_PATH=C:\Program Files (x86)\Java\jdk1.8.0_25"
set "ANT1_PATH=C:\Eclipse\plugins\org.apache.ant_1.9.2.v201404171502"

REM ###############################################
REM # DO NOT MODIFY ANY LINES BELOW THIS LINE !!! #
REM ###############################################

REM ///////////////////////////////////////////////////////////////////////////
REM // Setup environment
REM ///////////////////////////////////////////////////////////////////////////
set "QTDIR=%QT_SOURCE%"
call "%MSVC_PATH%\vcvarsall.bat" x86
set "JAVA_HOME=%JDK8_PATH%"
set "ANT_HOME=%ANT1_PATH%"
set "PATH=%QTDIR%\bin;%PATH%"

REM ///////////////////////////////////////////////////////////////////////////
REM // Check environment
REM ///////////////////////////////////////////////////////////////////////////
if "%VCINSTALLDIR%"=="" (
	echo %%VCINSTALLDIR%% not specified. Please check your MSVC_PATH var^^!
	goto BuildError
)
if not exist "%VCINSTALLDIR%\bin\cl.exe" (
	echo C++ compiler binary not found. Please check your MSVC_PATH var^^!
	goto BuildError
)
if not exist "%UPX3_PATH%\upx.exe" (
	echo UPX binary could not be found. Please check your UPX3_PATH var^^!
	goto BuildError
)
if not exist "%PDOC_PATH%\pandoc.exe" (
	echo Pandoc binary could not be found. Please check your PDOC_PATH var^^!
	goto BuildError
)
if not exist "%QTDIR%\bin\moc.exe" (
	echo Qt could not be found. Please check your QT_SOURCE var^^!
	goto BuildError
)
if not exist "%QTDIR%\include\QtCore\qglobal.h" (
	echo Qt could not be found. Please check your QT_SOURCE var^^!
	goto BuildError
)
if not exist "%QT_SHARED%\bin\QtCore4.dll" (
	echo Qt *shared* libraries could not be found. Please check your QT_SHARED var^^!
	goto BuildError
)
if not exist "%QT_STATIC%\lib\QtCore.lib" (
	echo Qt *static* libraries could not be found. Please check your QT_STATIC var^^!
	goto BuildError
)
if not exist "%JDK8_PATH%\include\jni.h" (
	echo JNI header files could not be found. Please check your JDK8_PATH var^^!
	goto BuildError
)
if not exist "%ANT1_PATH%\lib\ant.jar" (
	echo Ant library file could not be found. Please check your ANT1_PATH var^^!
	goto BuildError
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Get current date and time (in ISO format)
REM ///////////////////////////////////////////////////////////////////////////
set "ISO_DATE="
set "ISO_TIME="
if not exist "%~dp0\etc\date.exe" BuildError
for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\etc\date.exe" +ISODATE:%%Y-%%m-%%d') do (
	if "%%a"=="ISODATE" set "ISO_DATE=%%b"
)
for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\etc\date.exe" +ISOTIME:%%T') do (
	if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
)
if "%ISO_DATE%"=="" goto BuildError
if "%ISO_TIME%"=="" goto BuildError

REM ///////////////////////////////////////////////////////////////////////////
REM // Detect version number
REM ///////////////////////////////////////////////////////////////////////////
set "VER_MAJOR="
set "VER_MINOR="
set "VER_PATCH="
for /F "tokens=4,5,6 delims=; " %%a in (%~dp0\DynamicAudioNormalizerAPI\src\Version.cpp) do (
	if "%%b"=="=" (
		if "%%a"=="DYNAUDNORM_VERSION_MAJOR" set "VER_MAJOR=%%c"
		if "%%a"=="DYNAUDNORM_VERSION_MINOR" set "VER_MINOR=%%c"
		if "%%a"=="DYNAUDNORM_VERSION_PATCH" set "VER_PATCH=%%c"
	)
)
if "%VER_MAJOR%"=="" goto BuildError
if "%VER_MINOR%"=="" goto BuildError
if "%VER_PATCH%"=="" goto BuildError
if %VER_MINOR% LSS 10 set "VER_MINOR=0%VER_MINOR%

REM ///////////////////////////////////////////////////////////////////////////
REM // Clean Binaries
REM ///////////////////////////////////////////////////////////////////////////
for /d %%d in (%~dp0\bin\*) do (rmdir /S /Q "%%~d")
for /d %%d in (%~dp0\obj\*) do (rmdir /S /Q "%%~d")

REM ///////////////////////////////////////////////////////////////////////////
REM // Build the binaries
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	for %%p in (Win32, x64) do (
		echo ---------------------------------------------------------------------
		echo BEGIN BUILD [%%p/Release_%%c]
		echo ---------------------------------------------------------------------

		MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:clean   "%~dp0\DynamicAudioNormalizer.sln"
		if not "!ERRORLEVEL!"=="0" goto BuildError
		MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:rebuild "%~dp0\DynamicAudioNormalizer.sln"
		if not "!ERRORLEVEL!"=="0" goto BuildError
		MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:build   "%~dp0\DynamicAudioNormalizer.sln"
		if not "!ERRORLEVEL!"=="0" goto BuildError
	)
)

call "%ANT1_PATH%\bin\ant.bat" -buildfile "%~dp0\DynamicAudioNormalizerJNI\build.xml"

REM ///////////////////////////////////////////////////////////////////////////
REM // Copy program files
REM ///////////////////////////////////////////////////////////////////////////
set "PACK_PATH=%TMP%\~%RANDOM%%RANDOM%.tmp"
mkdir "%PACK_PATH%"

for %%c in (DLL, Static) do (
	echo ---------------------------------------------------------------------
	echo BEGIN PACKAGING [Release_%%c]
	echo ---------------------------------------------------------------------

	mkdir "%PACK_PATH%\%%c"
	mkdir "%PACK_PATH%\%%c\x64"
	mkdir "%PACK_PATH%\%%c\img"

	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerCLI.exe" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerGUI.exe" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerVST.dll" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerVST.dll" "%PACK_PATH%\%%c\x64"
	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerWA5.dll" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerWA5.dll" "%PACK_PATH%\%%c\x64"

	if "%%c"=="DLL" (
		mkdir "%PACK_PATH%\%%c\include"

		copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerAPI.dll" "%PACK_PATH%\%%c"
		copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerAPI.lib" "%PACK_PATH%\%%c"
		copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerNET.dll" "%PACK_PATH%\%%c"
		copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerAPI.dll" "%PACK_PATH%\%%c\x64"
		copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerAPI.lib" "%PACK_PATH%\%%c\x64"
		copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerNET.dll" "%PACK_PATH%\%%c\x64"

		copy "%~dp0\DynamicAudioNormalizerAPI\include\*.h"               "%PACK_PATH%\%%c\include"
		copy "%~dp0\DynamicAudioNormalizerPAS\include\*.pas"             "%PACK_PATH%\%%c\include"
		copy "%~dp0\DynamicAudioNormalizerJNI\out\*.jar"                 "%PACK_PATH%\%%c"
		copy "%~dp0\etc\sndfile\lib\Win32\shared\libsndfile-1.dll"       "%PACK_PATH%\%%c"
		copy "%~dp0\etc\pthread\lib\Win32\shared\pthreadVC2.dll"         "%PACK_PATH%\%%c"
		copy "%~dp0\etc\pthread\lib\x64\.\shared\pthreadVC2.dll"         "%PACK_PATH%\%%c\x64"

		copy "%MSVC_PATH%\redist\x86\Microsoft.VC120.CRT\msvc????.dll"   "%PACK_PATH%\%%c"
		copy "%MSVC_PATH%\redist\x64\Microsoft.VC120.CRT\msvc????.dll"   "%PACK_PATH%\%%c\x64"
		copy "%QT_SHARED%\bin\QtGui4.dll"                                "%PACK_PATH%\%%c"
		copy "%QT_SHARED%\bin\QtCore4.dll"                               "%PACK_PATH%\%%c"
	)

	copy "%~dp0\LICENSE-LGPL.html" "%PACK_PATH%\%%c"
	copy "%~dp0\LICENSE-GPL2.html" "%PACK_PATH%\%%c"
	copy "%~dp0\LICENSE-GPL3.html" "%PACK_PATH%\%%c"
	copy "%~dp0\img\*.png"         "%PACK_PATH%\%%c\img"

	"%PDOC_PATH%\pandoc.exe" --from markdown_github+header_attributes --to html5 --standalone -H "%~dp0\img\Style.inc" "%~dp0\README.md" --output "%PACK_PATH%\%%c\README.html"
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Compress
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	"%UPX3_PATH%\upx.exe" --best "%PACK_PATH%\%%c\*.exe"
	"%UPX3_PATH%\upx.exe" --best "%PACK_PATH%\%%c\*.dll"
	"%UPX3_PATH%\upx.exe" --best "%PACK_PATH%\%%c\x64\*.dll"
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Attributes
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	attrib +R "%PACK_PATH%\%%c\*.exe"
	attrib +R "%PACK_PATH%\%%c\*.html"
	attrib +R "%PACK_PATH%\%%c\*.dll"
	attrib +R "%PACK_PATH%\%%c\*.jar"
	attrib +R "%PACK_PATH%\%%c\*.lib"
	attrib +R "%PACK_PATH%\%%c\x64\*.dll"
	attrib +R "%PACK_PATH%\%%c\x64\*.lib"
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Generate outfile name
REM ///////////////////////////////////////////////////////////////////////////
mkdir "%~dp0\out" 2> NUL
set "OUT_NAME=DynamicAudioNormalizer.%ISO_DATE%"
:CheckOutName
for %%c in (DLL, Static) do (
	if exist "%~dp0\out\%OUT_NAME%.%%c.zip" (
		set "OUT_NAME=%OUT_NAME%.new"
		goto CheckOutName
	)
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Create version tag
REM ///////////////////////////////////////////////////////////////////////////
echo Dynamic Audio Normalizer >                                                                      "%PACK_PATH%\BUILD_TAG"
echo Copyright (C) 2014 LoRd_MuldeR ^<MuldeR2@GMX.de^> >>                                            "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
echo Version %VER_MAJOR%.%VER_MINOR%-%VER_PATCH%. Built on %ISO_DATE%, at %ISO_TIME% >>              "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
cl 2>&1  | "%~dp0\etc\head.exe" -n1 | "%~dp0\etc\sed.exe" -e "/^$/d" -e "s/^/Compiler version: /" >> "%PACK_PATH%\BUILD_TAG"
ver 2>&1 |                            "%~dp0\etc\sed.exe" -e "/^$/d" -e "s/^/Build platform:   /" >> "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
echo This library is free software; you can redistribute it and/or >>                                "%PACK_PATH%\BUILD_TAG"
echo modify it under the terms of the GNU Lesser General Public >>                                   "%PACK_PATH%\BUILD_TAG"
echo License as published by the Free Software Foundation; either >>                                 "%PACK_PATH%\BUILD_TAG"
echo version 2.1 of the License, or (at your option) any later version. >>                           "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
echo This library is distributed in the hope that it will be useful, >>                              "%PACK_PATH%\BUILD_TAG"
echo but WITHOUT ANY WARRANTY; without even the implied warranty of >>                               "%PACK_PATH%\BUILD_TAG"
echo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >>                            "%PACK_PATH%\BUILD_TAG"
echo Lesser General Public License for more details. >>                                              "%PACK_PATH%\BUILD_TAG"

REM ///////////////////////////////////////////////////////////////////////////
REM // Build the package
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	copy "%PACK_PATH%\BUILD_TAG" "%PACK_PATH%\%%c"
	pushd "%PACK_PATH%\%%c"
	"%~dp0\etc\zip.exe" -9 -r -z "%~dp0\out\%OUT_NAME%.%%c.zip" "*.*" < "%PACK_PATH%\BUILD_TAG"
	popd
	attrib +R "%~dp0\out\%OUT_NAME%.%%c.zip"
)

REM Clean up!
rmdir /Q /S "%PACK_PATH%"

REM ///////////////////////////////////////////////////////////////////////////
REM // COMPLETE
REM ///////////////////////////////////////////////////////////////////////////
echo.
echo Build completed.
echo.
pause
goto:eof

REM ///////////////////////////////////////////////////////////////////////////
REM // FAILED
REM ///////////////////////////////////////////////////////////////////////////
:BuildError
echo.
echo Build has failed ^^!^^!^^!
echo.
pause

@echo off
setlocal enabledelayedexpansion

REM ///////////////////////////////////////////////////////////////////////////
REM // Set Paths
REM ///////////////////////////////////////////////////////////////////////////
set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
set "UPX3_PATH=C:\Program Files (x86)\UPX"
set "PDOC_PATH=C:\Program Files (x86)\Pandoc"
set "QT_SOURCE=C:\Qt\4.8.6"
set "QT_SHARED=C:\Qt\4.8.6-Shared"
set "QT_STATIC=C:\Qt\4.8.6-Static"
set "JDK8_PATH=C:\Program Files (x86)\Java\jdk1.8.0_25"
set "ANT1_PATH=C:\Eclipse\plugins\org.apache.ant_1.9.2.v201404171502"

REM ###############################################
REM # DO NOT MODIFY ANY LINES BELOW THIS LINE !!! #
REM ###############################################

REM ///////////////////////////////////////////////////////////////////////////
REM // Setup environment
REM ///////////////////////////////////////////////////////////////////////////
set "QTDIR=%QT_SOURCE%"
call "%MSVC_PATH%\vcvarsall.bat" x86
set "JAVA_HOME=%JDK8_PATH%"
set "ANT_HOME=%ANT1_PATH%"
set "PATH=%QTDIR%\bin;%PATH%"

REM ///////////////////////////////////////////////////////////////////////////
REM // Check environment
REM ///////////////////////////////////////////////////////////////////////////
if "%VCINSTALLDIR%"=="" (
	echo %%VCINSTALLDIR%% not specified. Please check your MSVC_PATH var^^!
	goto BuildError
)
if not exist "%VCINSTALLDIR%\bin\cl.exe" (
	echo C++ compiler binary not found. Please check your MSVC_PATH var^^!
	goto BuildError
)
if not exist "%UPX3_PATH%\upx.exe" (
	echo UPX binary could not be found. Please check your UPX3_PATH var^^!
	goto BuildError
)
if not exist "%PDOC_PATH%\pandoc.exe" (
	echo Pandoc binary could not be found. Please check your PDOC_PATH var^^!
	goto BuildError
)
if not exist "%QTDIR%\bin\moc.exe" (
	echo Qt could not be found. Please check your QT_SOURCE var^^!
	goto BuildError
)
if not exist "%QTDIR%\include\QtCore\qglobal.h" (
	echo Qt could not be found. Please check your QT_SOURCE var^^!
	goto BuildError
)
if not exist "%QT_SHARED%\bin\QtCore4.dll" (
	echo Qt *shared* libraries could not be found. Please check your QT_SHARED var^^!
	goto BuildError
)
if not exist "%QT_STATIC%\lib\QtCore.lib" (
	echo Qt *static* libraries could not be found. Please check your QT_STATIC var^^!
	goto BuildError
)
if not exist "%JDK8_PATH%\include\jni.h" (
	echo JNI header files could not be found. Please check your JDK8_PATH var^^!
	goto BuildError
)
if not exist "%ANT1_PATH%\lib\ant.jar" (
	echo Ant library file could not be found. Please check your ANT1_PATH var^^!
	goto BuildError
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Get current date and time (in ISO format)
REM ///////////////////////////////////////////////////////////////////////////
set "ISO_DATE="
set "ISO_TIME="
if not exist "%~dp0\etc\date.exe" BuildError
for /F "tokens=1,2 delims=:" %%a in ('"%~dp0\etc\date.exe" +ISODATE:%%Y-%%m-%%d') do (
	if "%%a"=="ISODATE" set "ISO_DATE=%%b"
)
for /F "tokens=1,2,3,4 delims=:" %%a in ('"%~dp0\etc\date.exe" +ISOTIME:%%T') do (
	if "%%a"=="ISOTIME" set "ISO_TIME=%%b:%%c:%%d"
)
if "%ISO_DATE%"=="" goto BuildError
if "%ISO_TIME%"=="" goto BuildError

REM ///////////////////////////////////////////////////////////////////////////
REM // Detect version number
REM ///////////////////////////////////////////////////////////////////////////
set "VER_MAJOR="
set "VER_MINOR="
set "VER_PATCH="
for /F "tokens=4,5,6 delims=; " %%a in (%~dp0\DynamicAudioNormalizerAPI\src\Version.cpp) do (
	if "%%b"=="=" (
		if "%%a"=="DYNAUDNORM_VERSION_MAJOR" set "VER_MAJOR=%%c"
		if "%%a"=="DYNAUDNORM_VERSION_MINOR" set "VER_MINOR=%%c"
		if "%%a"=="DYNAUDNORM_VERSION_PATCH" set "VER_PATCH=%%c"
	)
)
if "%VER_MAJOR%"=="" goto BuildError
if "%VER_MINOR%"=="" goto BuildError
if "%VER_PATCH%"=="" goto BuildError
if %VER_MINOR% LSS 10 set "VER_MINOR=0%VER_MINOR%

REM ///////////////////////////////////////////////////////////////////////////
REM // Clean Binaries
REM ///////////////////////////////////////////////////////////////////////////
for /d %%d in (%~dp0\bin\*) do (rmdir /S /Q "%%~d")
for /d %%d in (%~dp0\obj\*) do (rmdir /S /Q "%%~d")

REM ///////////////////////////////////////////////////////////////////////////
REM // Build the binaries
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	for %%p in (Win32, x64) do (
		echo ---------------------------------------------------------------------
		echo BEGIN BUILD [%%p/Release_%%c]
		echo ---------------------------------------------------------------------

		MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:clean   "%~dp0\DynamicAudioNormalizer.sln"
		if not "!ERRORLEVEL!"=="0" goto BuildError
		MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:rebuild "%~dp0\DynamicAudioNormalizer.sln"
		if not "!ERRORLEVEL!"=="0" goto BuildError
		MSBuild.exe /property:Platform=%%p /property:Configuration=Release_%%c /target:build   "%~dp0\DynamicAudioNormalizer.sln"
		if not "!ERRORLEVEL!"=="0" goto BuildError
	)
)

call "%ANT1_PATH%\bin\ant.bat" -buildfile "%~dp0\DynamicAudioNormalizerJNI\build.xml"

REM ///////////////////////////////////////////////////////////////////////////
REM // Copy program files
REM ///////////////////////////////////////////////////////////////////////////
set "PACK_PATH=%TMP%\~%RANDOM%%RANDOM%.tmp"
mkdir "%PACK_PATH%"

for %%c in (DLL, Static) do (
	echo ---------------------------------------------------------------------
	echo BEGIN PACKAGING [Release_%%c]
	echo ---------------------------------------------------------------------

	mkdir "%PACK_PATH%\%%c"
	mkdir "%PACK_PATH%\%%c\x64"
	mkdir "%PACK_PATH%\%%c\img"

	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerCLI.exe" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerGUI.exe" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerVST.dll" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerVST.dll" "%PACK_PATH%\%%c\x64"
	copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerWA5.dll" "%PACK_PATH%\%%c"
	copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerWA5.dll" "%PACK_PATH%\%%c\x64"

	if "%%c"=="DLL" (
		mkdir "%PACK_PATH%\%%c\include"

		copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerAPI.dll" "%PACK_PATH%\%%c"
		copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerAPI.lib" "%PACK_PATH%\%%c"
		copy "%~dp0\bin\Win32\Release_%%c\DynamicAudioNormalizerNET.dll" "%PACK_PATH%\%%c"
		copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerAPI.dll" "%PACK_PATH%\%%c\x64"
		copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerAPI.lib" "%PACK_PATH%\%%c\x64"
		copy "%~dp0\bin\x64\.\Release_%%c\DynamicAudioNormalizerNET.dll" "%PACK_PATH%\%%c\x64"

		copy "%~dp0\DynamicAudioNormalizerAPI\include\*.h"               "%PACK_PATH%\%%c\include"
		copy "%~dp0\DynamicAudioNormalizerPAS\include\*.pas"             "%PACK_PATH%\%%c\include"
		copy "%~dp0\DynamicAudioNormalizerJNI\out\*.jar"                 "%PACK_PATH%\%%c"
		copy "%~dp0\etc\sndfile\lib\Win32\shared\libsndfile-1.dll"       "%PACK_PATH%\%%c"
		copy "%~dp0\etc\pthread\lib\Win32\shared\pthreadVC2.dll"         "%PACK_PATH%\%%c"
		copy "%~dp0\etc\pthread\lib\x64\.\shared\pthreadVC2.dll"         "%PACK_PATH%\%%c\x64"

		copy "%MSVC_PATH%\redist\x86\Microsoft.VC120.CRT\msvc????.dll"   "%PACK_PATH%\%%c"
		copy "%MSVC_PATH%\redist\x64\Microsoft.VC120.CRT\msvc????.dll"   "%PACK_PATH%\%%c\x64"
		copy "%QT_SHARED%\bin\QtGui4.dll"                                "%PACK_PATH%\%%c"
		copy "%QT_SHARED%\bin\QtCore4.dll"                               "%PACK_PATH%\%%c"
	)

	copy "%~dp0\LICENSE-LGPL.html" "%PACK_PATH%\%%c"
	copy "%~dp0\LICENSE-GPL2.html" "%PACK_PATH%\%%c"
	copy "%~dp0\LICENSE-GPL3.html" "%PACK_PATH%\%%c"
	copy "%~dp0\img\*.png"         "%PACK_PATH%\%%c\img"

	"%PDOC_PATH%\pandoc.exe" --from markdown_github+header_attributes --to html5 --standalone -H "%~dp0\img\Style.inc" "%~dp0\README.md" --output "%PACK_PATH%\%%c\README.html"
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Compress
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	"%UPX3_PATH%\upx.exe" --best "%PACK_PATH%\%%c\*.exe"
	"%UPX3_PATH%\upx.exe" --best "%PACK_PATH%\%%c\*.dll"
	"%UPX3_PATH%\upx.exe" --best "%PACK_PATH%\%%c\x64\*.dll"
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Create version tag
REM ///////////////////////////////////////////////////////////////////////////
echo Dynamic Audio Normalizer >                                                                      "%PACK_PATH%\BUILD_TAG"
echo Copyright (C) 2014 LoRd_MuldeR ^<MuldeR2@GMX.de^> >>                                            "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
echo Version %VER_MAJOR%.%VER_MINOR%-%VER_PATCH%. Built on %ISO_DATE%, at %ISO_TIME% >>              "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
cl 2>&1  | "%~dp0\etc\head.exe" -n1 | "%~dp0\etc\sed.exe" -e "/^$/d" -e "s/^/Compiler version: /" >> "%PACK_PATH%\BUILD_TAG"
ver 2>&1 |                            "%~dp0\etc\sed.exe" -e "/^$/d" -e "s/^/Build platform:   /" >> "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
echo This library is free software; you can redistribute it and/or >>                                "%PACK_PATH%\BUILD_TAG"
echo modify it under the terms of the GNU Lesser General Public >>                                   "%PACK_PATH%\BUILD_TAG"
echo License as published by the Free Software Foundation; either >>                                 "%PACK_PATH%\BUILD_TAG"
echo version 2.1 of the License, or (at your option) any later version. >>                           "%PACK_PATH%\BUILD_TAG"
echo. >>                                                                                "%PACK_PATH%\BUILD_TAG"
echo This library is distributed in the hope that it will be useful, >>                              "%PACK_PATH%\BUILD_TAG"
echo but WITHOUT ANY WARRANTY; without even the implied warranty of >>                               "%PACK_PATH%\BUILD_TAG"
echo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU >>                            "%PACK_PATH%\BUILD_TAG"
echo Lesser General Public License for more details. >>                                              "%PACK_PATH%\BUILD_TAG"

REM ///////////////////////////////////////////////////////////////////////////
REM // Attributes
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	attrib +R "%PACK_PATH%\%%c\*"
	attrib +R "%PACK_PATH%\%%c\x64\*"
	attrib +R "%PACK_PATH%\%%c\include\*"
	attrib +R "%PACK_PATH%\%%c\img\*"
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Generate outfile name
REM ///////////////////////////////////////////////////////////////////////////
mkdir "%~dp0\out" 2> NUL
set "OUT_NAME=DynamicAudioNormalizer.%ISO_DATE%"
:CheckOutName
for %%c in (DLL, Static) do (
	if exist "%~dp0\out\%OUT_NAME%.%%c.zip" (
		set "OUT_NAME=%OUT_NAME%.new"
		goto CheckOutName
	)
)

REM ///////////////////////////////////////////////////////////////////////////
REM // Build the package
REM ///////////////////////////////////////////////////////////////////////////
for %%c in (DLL, Static) do (
	copy "%PACK_PATH%\BUILD_TAG" "%PACK_PATH%\%%c"
	pushd "%PACK_PATH%\%%c"
	"%~dp0\etc\zip.exe" -9 -r -z "%~dp0\out\%OUT_NAME%.%%c.zip" "*.*" < "%PACK_PATH%\BUILD_TAG"
	popd
	attrib +R "%~dp0\out\%OUT_NAME%.%%c.zip"
)

REM Clean up!
rmdir /Q /S "%PACK_PATH%"

REM ///////////////////////////////////////////////////////////////////////////
REM // COMPLETE
REM ///////////////////////////////////////////////////////////////////////////
echo.
echo Build completed.
echo.
pause
goto:eof

REM ///////////////////////////////////////////////////////////////////////////
REM // FAILED
REM ///////////////////////////////////////////////////////////////////////////
:BuildError
echo.
echo Build has failed ^^!^^!^^!
echo.
pause

Update build script.

Update build script.


@echo off

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

rem ---------------------------------------------------------------------------
rem Main Script for WSO2 Carbon
rem
rem Environment Variable Prequisites
rem
rem   CARBON_HOME   Home of CARBON installation. If not set I will  try
rem                   to figure it out.
rem
rem
rem   JAVA_HOME       Must point at your Java Development Kit installation.
rem
rem   JAVA_OPTS       (Optional) Java runtime options used when the commands
rem                   is executed.
rem ---------------------------------------------------------------------------

rem ----- if JAVA_HOME is not set we're not happy ------------------------------
:checkJava

if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
goto checkServer

:noJavaHome
echo "You must set the JAVA_HOME variable before running CARBON."
goto end

rem ----- Only set CARBON_HOME if not already set ----------------------------
:checkServer
rem %~sdp0 is expanded pathname of the current script under NT with spaces in the path removed
SET CARBON_HOME=%~sdp0..
SET curDrive=%cd:~0,1%
SET wsasDrive=%CARBON_HOME:~0,1%
if not "%curDrive%" == "%wsasDrive%" %wsasDrive%:

rem find CARBON_HOME if it does not exist due to either an invalid value passed
rem by the user or the %0 problem on Windows 9x
if not exist "%CARBON_HOME%\bin\version.txt" goto noServerHome

set AXIS2_HOME=%CARBON_HOME%
goto updateClasspath

:noServerHome
echo CARBON_HOME is set incorrectly or CARBON could not be located. Please set CARBON_HOME.
goto end

rem ----- update classpath -----------------------------------------------------
:updateClasspath

setlocal EnableDelayedExpansion
cd %CARBON_HOME%
set CARBON_CLASSPATH=
FOR %%C in ("%CARBON_HOME%\bin\*.jar") DO set CARBON_CLASSPATH=!CARBON_CLASSPATH!;".\bin\%%~nC%%~xC"

set CARBON_CLASSPATH="%JAVA_HOME%\lib\tools.jar";%CARBON_CLASSPATH%;

FOR %%D in ("%CARBON_HOME%\wso2\lib\*.jar") DO set CARBON_CLASSPATH=!CARBON_CLASSPATH!;".wso2\lib\%%~nD%%~xD"

rem ----- Process the input command -------------------------------------------

rem Slurp the command line arguments. This loop allows for an unlimited number
rem of arguments (up to the command line limit, anyway).

:setupArgs
if ""%1""=="""" goto doneStart

if ""%1""==""-run""     goto commandLifecycle
if ""%1""==""--run""    goto commandLifecycle
if ""%1""==""run""      goto commandLifecycle

if ""%1""==""-restart""  goto commandLifecycle
if ""%1""==""--restart"" goto commandLifecycle
if ""%1""==""restart""   goto commandLifecycle

if ""%1""==""debug""    goto commandDebug
if ""%1""==""-debug""   goto commandDebug
if ""%1""==""--debug""  goto commandDebug

if ""%1""==""version""   goto commandVersion
if ""%1""==""-version""  goto commandVersion
if ""%1""==""--version"" goto commandVersion

shift
goto setupArgs

rem ----- commandVersion -------------------------------------------------------
:commandVersion
shift
type "%CARBON_HOME%\bin\version.txt"
type "%CARBON_HOME%\bin\wso2carbon-version.txt"
goto end

rem ----- commandDebug ---------------------------------------------------------
:commandDebug
shift
set DEBUG_PORT=%1
if "%DEBUG_PORT%"=="" goto noDebugPort
if not "%JAVA_OPTS%"=="" echo Warning !!!. User specified JAVA_OPTS will be ignored, once you give the --debug option.
set JAVA_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%DEBUG_PORT%
echo Please start the remote debugging client to continue...
goto findJdk

:noDebugPort
echo Please specify the debug port after the --debug option
goto end

rem ----- commandLifecycle -----------------------------------------------------
:commandLifecycle
goto findJdk

:doneStart
if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal

rem ---------- Handle the SSL Issue with proper JDK version --------------------
rem find the version of the jdk
:findJdk

set CMD=RUN %*

:checkJdk17
PATH %PATH%;%JAVA_HOME%\bin\
for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "JAVA_VERSION=%%j%%k"
if %JAVA_VERSION% LSS 17 goto unknownJdk
if %JAVA_VERSION% GTR 110 goto unknownJdk
goto jdk17

:unknownJdk
echo Starting WSO2 Carbon (in unsupported JDK)
echo [ERROR] CARBON is supported only on JDK 1.7, 1.8, 9, 10 and 11
goto jdk17

:jdk17
goto runServer

rem ----------------- Execute The Requested Command ----------------------------

:runServer
cd %CARBON_HOME%

rem ------------------ Remove tmp folder on startup -----------------------------
set TMP_DIR=%CARBON_HOME%\wso2\tmp
cd "%TMP_DIR%"
del *.* /s /q > nul
FOR /d %%G in ("*.*") DO rmdir %%G /s /q
cd ..\..

rem ---------- Add jars to classpath ----------------

if %JAVA_VERSION% GEQ 110 set CARBON_CLASSPATH=.\wso2\lib\*;%CARBON_CLASSPATH%
if %JAVA_VERSION% LEQ 18 set JAVA_VER_BASED_OPTS=-Djava.endorsed.dirs=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed"
if %JAVA_VERSION% GEQ 110 set JAVA_VER_BASED_OPTS=--add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED

set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof"  -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\wso2\tmp" -Dcatalina.base="%CARBON_HOME%\wso2\lib\tomcat" -Dwso2.carbon.xml="%CARBON_HOME%\conf\carbon.xml" -Dwso2.registry.xml="%CARBON_HOME%\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\conf"  -Dcomponents.repo="%CARBON_HOME%\wso2\components\plugins" -Dcarbon.config.dir.path="%CARBON_HOME%\conf" -Dcarbon.components.dir.path="%CARBON_HOME%\wso2\components" -Dcarbon.extensions.dir.path="%CARBON_HOME%\extensions" -Dcarbon.dropins.dir.path="%CARBON_HOME%\dropins" -Dcarbon.external.lib.dir.path="%CARBON_HOME%\lib" -Dcarbon.patches.dir.path="%CARBON_HOME%\patches" -Dcarbon.servicepacks.dir.path="%CARBON_HOME%\servicepacks" -Dcarbon.internal.lib.dir.path="%CARBON_HOME%\wso2\lib" -Dconf.location="%CARBON_HOME%\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\wso2\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 -DworkerNode=false -Dei.extendedURIBasedDispatcher=org.wso2.carbon.integrator.core.handler.IntegratorStatefulHandler -Dorg.wso2.ignoreHostnameVerification=true -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*"

:runJava
echo JAVA_HOME environment variable is set to %JAVA_HOME%
echo CARBON_HOME environment variable is set to %CARBON_HOME%
"%JAVA_HOME%\bin\java" %CMD_LINE_ARGS% org.wso2.carbon.bootstrap.Bootstrap %CMD%
if "%ERRORLEVEL%"=="121" goto runJava
:end
goto endlocal

:endlocal

:END

@echo off

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

rem ---------------------------------------------------------------------------
rem Main Script for WSO2 Carbon
rem
rem Environment Variable Prequisites
rem
rem   CARBON_HOME   Home of CARBON installation. If not set I will  try
rem                   to figure it out.
rem
rem
rem   JAVA_HOME       Must point at your Java Development Kit installation.
rem
rem   JAVA_OPTS       (Optional) Java runtime options used when the commands
rem                   is executed.
rem ---------------------------------------------------------------------------

rem ----- if JAVA_HOME is not set we're not happy ------------------------------
:checkJava

if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
goto checkServer

:noJavaHome
echo "You must set the JAVA_HOME variable before running CARBON."
goto end

rem ----- Only set CARBON_HOME if not already set ----------------------------
:checkServer
rem %~sdp0 is expanded pathname of the current script under NT with spaces in the path removed
SET CARBON_HOME=%~sdp0..
SET curDrive=%cd:~0,1%
SET wsasDrive=%CARBON_HOME:~0,1%
if not "%curDrive%" == "%wsasDrive%" %wsasDrive%:

rem find CARBON_HOME if it does not exist due to either an invalid value passed
rem by the user or the %0 problem on Windows 9x
if not exist "%CARBON_HOME%\bin\version.txt" goto noServerHome

set AXIS2_HOME=%CARBON_HOME%
goto updateClasspath

:noServerHome
echo CARBON_HOME is set incorrectly or CARBON could not be located. Please set CARBON_HOME.
goto end

rem ----- update classpath -----------------------------------------------------
:updateClasspath

setlocal EnableDelayedExpansion
cd %CARBON_HOME%
set CARBON_CLASSPATH=
FOR %%C in ("%CARBON_HOME%\bin\*.jar") DO set CARBON_CLASSPATH=!CARBON_CLASSPATH!;".\bin\%%~nC%%~xC"

set CARBON_CLASSPATH="%JAVA_HOME%\lib\tools.jar";%CARBON_CLASSPATH%;

FOR %%D in ("%CARBON_HOME%\wso2\lib\*.jar") DO set CARBON_CLASSPATH=!CARBON_CLASSPATH!;".wso2\lib\%%~nD%%~xD"

rem ----- Process the input command -------------------------------------------

rem Slurp the command line arguments. This loop allows for an unlimited number
rem of arguments (up to the command line limit, anyway).

:setupArgs
if ""%1""=="""" goto doneStart

if ""%1""==""-run""     goto commandLifecycle
if ""%1""==""--run""    goto commandLifecycle
if ""%1""==""run""      goto commandLifecycle

if ""%1""==""-restart""  goto commandLifecycle
if ""%1""==""--restart"" goto commandLifecycle
if ""%1""==""restart""   goto commandLifecycle

if ""%1""==""debug""    goto commandDebug
if ""%1""==""-debug""   goto commandDebug
if ""%1""==""--debug""  goto commandDebug

if ""%1""==""version""   goto commandVersion
if ""%1""==""-version""  goto commandVersion
if ""%1""==""--version"" goto commandVersion

shift
goto setupArgs

rem ----- commandVersion -------------------------------------------------------
:commandVersion
shift
type "%CARBON_HOME%\bin\version.txt"
type "%CARBON_HOME%\bin\wso2carbon-version.txt"
goto end

rem ----- commandDebug ---------------------------------------------------------
:commandDebug
shift
set DEBUG_PORT=%1
if "%DEBUG_PORT%"=="" goto noDebugPort
if not "%JAVA_OPTS%"=="" echo Warning !!!. User specified JAVA_OPTS will be ignored, once you give the --debug option.
set JAVA_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%DEBUG_PORT%
echo Please start the remote debugging client to continue...
goto findJdk

:noDebugPort
echo Please specify the debug port after the --debug option
goto end

rem ----- commandLifecycle -----------------------------------------------------
:commandLifecycle
goto findJdk

:doneStart
if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal

rem ---------- Handle the SSL Issue with proper JDK version --------------------
rem find the version of the jdk
:findJdk

set CMD=RUN %*

:checkJdk17
PATH %PATH%;%JAVA_HOME%\bin\
for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "JAVA_VERSION=%%j%%k"
if %JAVA_VERSION% LSS 17 goto unknownJdk
if %JAVA_VERSION% GTR 110 goto unknownJdk
goto jdk17

:unknownJdk
echo Starting WSO2 Carbon (in unsupported JDK)
echo [ERROR] CARBON is supported only on JDK 1.7, 1.8, 9, 10 and 11
goto jdk17

:jdk17
goto runServer

rem ----------------- Execute The Requested Command ----------------------------

:runServer
cd %CARBON_HOME%

rem ------------------ Remove tmp folder on startup -----------------------------
set TMP_DIR=%CARBON_HOME%\wso2\tmp
cd "%TMP_DIR%"
del *.* /s /q > nul
FOR /d %%G in ("*.*") DO rmdir %%G /s /q
cd ..\..

rem ---------- Add jars to classpath ----------------

if %JAVA_VERSION% GEQ 110 set CARBON_CLASSPATH=.\wso2\lib\*;%CARBON_CLASSPATH%
if %JAVA_VERSION% LEQ 18 set CARBON_CLASSPATH=.\wso2\lib\*;%CARBON_CLASSPATH%
if %JAVA_VERSION% GEQ 110 set JAVA_VER_BASED_OPTS=--add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED

set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof"  -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\wso2\tmp" -Dcatalina.base="%CARBON_HOME%\wso2\lib\tomcat" -Dwso2.carbon.xml="%CARBON_HOME%\conf\carbon.xml" -Dwso2.registry.xml="%CARBON_HOME%\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\conf"  -Dcomponents.repo="%CARBON_HOME%\wso2\components\plugins" -Dcarbon.config.dir.path="%CARBON_HOME%\conf" -Dcarbon.components.dir.path="%CARBON_HOME%\wso2\components" -Dcarbon.extensions.dir.path="%CARBON_HOME%\extensions" -Dcarbon.dropins.dir.path="%CARBON_HOME%\dropins" -Dcarbon.external.lib.dir.path="%CARBON_HOME%\lib" -Dcarbon.patches.dir.path="%CARBON_HOME%\patches" -Dcarbon.servicepacks.dir.path="%CARBON_HOME%\servicepacks" -Dcarbon.internal.lib.dir.path="%CARBON_HOME%\wso2\lib" -Dconf.location="%CARBON_HOME%\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\wso2\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 -DworkerNode=false -Dei.extendedURIBasedDispatcher=org.wso2.carbon.integrator.core.handler.IntegratorStatefulHandler -Dorg.wso2.ignoreHostnameVerification=true -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" -DavoidConfigUpdate=true -DenableCorrelationLogs=false

:runJava
echo JAVA_HOME environment variable is set to %JAVA_HOME%
echo CARBON_HOME environment variable is set to %CARBON_HOME%
"%JAVA_HOME%\bin\java" %CMD_LINE_ARGS% org.wso2.carbon.bootstrap.Bootstrap %CMD%
if "%ERRORLEVEL%"=="121" goto runJava
:end
goto endlocal

:endlocal

:END

Fix startup issue in windows environment

This issue happens since we have used endorsed directory
in java 1.8. This has been fixed with this fix.

Fixes: https://github.com/wso2/product-ei/issues/4825


geth --datadir "./" --cache=512 --rpc --rpccorsdomain "*"

geth --datadir "./" --rpc --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "*" --nodiscover

Fix geth run command.

Fix geth run command.


:<<"::CMDLITERAL"
@ECHO OFF
SET MASTHEADURL=http://%1:52311/masthead/masthead.afxm
SET BASEFOLDER=C:\Windows\Temp
ECHO

REM http://stackoverflow.com/questions/4781772/how-to-test-if-an-executable-exists-in-the-path-from-a-windows-batch-file
where /q powershell || ECHO Cound not find powershell. && EXIT /B

powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://software.bigfix.com/download/bes/95/BigFix-BES-Client-9.5.1.9.exe', 'c:\Windows\Temp\BESClient.exe') }" -ExecutionPolicy Bypass
powershell -command "& { (New-Object Net.WebClient).DownloadFile('%MASTHEADURL%', 'c:\Windows\Temp\actionsite.afxm') }" -ExecutionPolicy Bypass

REM https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Endpoint%20Manager/page/Configuration%20Settings
REM https://gist.github.com/jgstew/51a99ab4b5997efa0318
ECHO > %BASEFOLDER%\clientsettings.cfg
ECHO _BESClient_RelaySelect_FailoverRelay=http://%1:port/bfmirror/downloads/>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Resource_StartupNormalSpeed=1>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_RetryMinutes=1>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Resource_WorkIdle=20>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Resource_SleepIdle=500>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Comm_CommandPollEnable=1>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Comm_CommandPollIntervalSeconds=10800>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Log_Days=30>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_UtilitiesCacheLimitMB=500>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_DownloadsCacheLimitMB=5000>> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_MinimumDiskFreeMB=2000>> C:\Windows\Temp\clientsettings.cfg

ECHO I am %COMSPEC%
ECHO put CMD/BAT lines in here.
ECHO %0
ECHO %1
ECHO %MASTHEADURL%

PAUSE
EXIT
::CMDLITERAL

:<<"::CMDLITERAL"
@ECHO OFF
SET MASTHEADURL=http://%1:52311/masthead/masthead.afxm
SET BASEFOLDER=C:\Windows\Temp
ECHO

REM http://stackoverflow.com/questions/4781772/how-to-test-if-an-executable-exists-in-the-path-from-a-windows-batch-file
where /q powershell || ECHO Cound not find powershell. && EXIT /B

powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://software.bigfix.com/download/bes/95/BigFix-BES-Client-9.5.1.9.exe', 'c:\Windows\Temp\BESClient.exe') }" -ExecutionPolicy Bypass
powershell -command "& { (New-Object Net.WebClient).DownloadFile('%MASTHEADURL%', 'c:\Windows\Temp\actionsite.afxm') }" -ExecutionPolicy Bypass

REM https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Endpoint%20Manager/page/Configuration%20Settings
REM https://gist.github.com/jgstew/51a99ab4b5997efa0318
ECHO NUL > C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_RelaySelect_FailoverRelay=http://%1:port/bfmirror/downloads/ >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Resource_StartupNormalSpeed=1 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_RetryMinutes=1 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Resource_WorkIdle=20 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Resource_SleepIdle=500 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Comm_CommandPollEnable=1 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Comm_CommandPollIntervalSeconds=10800 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Log_Days=30 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_UtilitiesCacheLimitMB=500 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_DownloadsCacheLimitMB=5000 >> C:\Windows\Temp\clientsettings.cfg
ECHO _BESClient_Download_MinimumDiskFreeMB=2000 >> C:\Windows\Temp\clientsettings.cfg

ECHO I am %COMSPEC%
ECHO put CMD/BAT lines in here.
ECHO %0
ECHO %1
ECHO %MASTHEADURL%

PAUSE
EXIT
::CMDLITERAL

Update install_bigfix.bat

Update install_bigfix.bat


@ECHO OFF
rem ******************************************************************************
rem *
rem * Notepad2-mod
rem *
rem * coverity.bat
rem *   Batch file used to create the coverity scan analysis file
rem *   Originally taken and adapted from  https://github.com/mpc-hc/mpc-hc
rem *
rem * See License.txt for details about distribution and modification.
rem *
rem *                                     (c) XhmikosR 2013-2014
rem *                                     https://github.com/XhmikosR/notepad2-mod
rem *
rem ******************************************************************************

SETLOCAL

PUSHD %~dp0

IF NOT DEFINED COVDIR SET "COVDIR=H:\progs\thirdparty\cov-analysis-win64-7.5.0"
IF DEFINED COVDIR IF NOT EXIST "%COVDIR%" (
  ECHO.
  ECHO ERROR: Coverity not found in "%COVDIR%"
  GOTO End
)

CALL "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86
IF %ERRORLEVEL% NEQ 0 (
  ECHO vcvarsall.bat call failed.
  GOTO End
)

:Cleanup
IF EXIST "cov-int" RD /q /s "cov-int"
IF EXIST "Notepad2-mod.lzma" DEL "Notepad2-mod.lzma"
IF EXIST "Notepad2-mod.tar"  DEL "Notepad2-mod.tar"
IF EXIST "Notepad2-mod.tgz"  DEL "Notepad2-mod.tgz"

:Main
"%COVDIR%\bin\cov-build.exe" --dir cov-int "build_vs2013.bat" Rebuild All Release

:tar
tar --version 1>&2 2>NUL || (ECHO. & ECHO ERROR: tar not found & GOTO SevenZip)
tar caf "Notepad2-mod.lzma" "cov-int"
GOTO End

:SevenZip
CALL :SubDetectSevenzipPath

rem Coverity is totally bogus with lzma...
rem And since I cannot replicate the arguments with 7-Zip, just use tar/gzip.
IF EXIST "%SEVENZIP%" (
  "%SEVENZIP%" a -ttar "Notepad2-mod.tar" "cov-int"
  "%SEVENZIP%" a -tgzip "Notepad2-mod.tgz" "Notepad2-mod.tar"
  IF EXIST "Notepad2-mod.tar" DEL "Notepad2-mod.tar"
  GOTO End
)

:SubDetectSevenzipPath
FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)

FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)

FOR /F "tokens=2*" %%A IN (
  'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
   REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe"
EXIT /B

:End
POPD
ECHO. & ECHO Press any key to close this window...
PAUSE >NUL
ENDLOCAL
EXIT /B

@ECHO OFF
rem ******************************************************************************
rem *
rem * Notepad2-mod
rem *
rem * coverity.bat
rem *   Batch file used to create the coverity scan analysis file
rem *   Originally taken and adapted from  https://github.com/mpc-hc/mpc-hc
rem *
rem * See License.txt for details about distribution and modification.
rem *
rem *                                     (c) XhmikosR 2013-2015
rem *                                     https://github.com/XhmikosR/notepad2-mod
rem *
rem ******************************************************************************

SETLOCAL

PUSHD %~dp0

IF NOT DEFINED COVDIR SET "COVDIR=H:\progs\thirdparty\cov-analysis-win64"
IF DEFINED COVDIR IF NOT EXIST "%COVDIR%" (
  ECHO.
  ECHO ERROR: Coverity not found in "%COVDIR%"
  GOTO End
)

CALL "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86
IF %ERRORLEVEL% NEQ 0 (
  ECHO vcvarsall.bat call failed.
  GOTO End
)

:Cleanup
IF EXIST "cov-int" RD /q /s "cov-int"
IF EXIST "Notepad2-mod.lzma" DEL "Notepad2-mod.lzma"
IF EXIST "Notepad2-mod.tar"  DEL "Notepad2-mod.tar"
IF EXIST "Notepad2-mod.tgz"  DEL "Notepad2-mod.tgz"

:Main
"%COVDIR%\bin\cov-build.exe" --dir cov-int "build_vs2013.bat" Rebuild All Release

:tar
tar --version 1>&2 2>NUL || (ECHO. & ECHO ERROR: tar not found & GOTO SevenZip)
tar caf "Notepad2-mod.lzma" "cov-int"
GOTO End

:SevenZip
CALL :SubDetectSevenzipPath

rem Coverity is totally bogus with lzma...
rem And since I cannot replicate the arguments with 7-Zip, just use tar/gzip.
IF EXIST "%SEVENZIP%" (
  "%SEVENZIP%" a -ttar "Notepad2-mod.tar" "cov-int"
  "%SEVENZIP%" a -tgzip "Notepad2-mod.tgz" "Notepad2-mod.tar"
  IF EXIST "Notepad2-mod.tar" DEL "Notepad2-mod.tar"
  GOTO End
)

:SubDetectSevenzipPath
FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)

FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)

FOR /F "tokens=2*" %%A IN (
  'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
   REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe"
EXIT /B

:End
POPD
ECHO. & ECHO Press any key to close this window...
PAUSE >NUL
ENDLOCAL
EXIT /B

update coverity path.

build/coverity.bat: update coverity path.


:: Usage:
:: - Drag & drop .cpp file on this file from Windows explorer
:: - Run from cmd/powershell:
::   - > _winpack_build_sample.cmd cpp\opencv_version.cpp
:: Requires:
:: - CMake
:: - MSVS 2015/2017
:: (tools are searched on default paths or environment should be pre-configured)
@echo off
setlocal

set SCRIPTDIR=%~dp0
if NOT exist "%SCRIPTDIR%\..\..\build" (
  set "MSG=OpenCV Winpack installation is required"
  goto die
)

if [%1]==[] (
  set "MSG=Sample path is required"
  goto die
)
if exist %1\* (
  set "MSG=Only .cpp samples are allowed (not a directory): %1"
  goto die
)
if NOT "%~x1" == ".cpp" (
  set "MSG=Only .cpp samples are allowed: %~x1"
  goto die
)
set SRC_FILENAME=%~dpnx1
echo SRC_FILENAME=%SRC_FILENAME%
call :dirname "%SRC_FILENAME%" SRC_DIR
echo SRC_DIR=%SRC_DIR%
set "SRC_NAME=%~n1"
echo SRC_NAME=%SRC_NAME%
echo ================================================================================

:: Path to FFMPEG binary files
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\bin\"

:: Detect compiler
cl /? >NUL 2>NUL <NUL
if %ERRORLEVEL% NEQ 0 (
  PUSHD %CD%
  if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" (
    CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat"
    goto check_msvc
  )
  if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" (
    CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
    goto check_msvc
  )
  if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" (
    CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
    goto check_msvc
  )
  if exist "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" (
    CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
    goto check_msvc
  )
:check_msvc
  POPD
  cl /? >NUL 2>NUL <NUL
  if %ERRORLEVEL% NEQ 0 (
    set "MSG=Can't detect Microsoft Visial Studio C++ compiler (cl.exe). MSVS 2015/2017 are supported only from standard locations"
    goto die
  )
)

:: Detect CMake
cmake --version >NUL 2>NUL
if %ERRORLEVEL% EQU 0 GOTO :CMAKE_FOUND

if NOT exist "C:\Program Files\CMake\bin" GOTO CMAKE_NOT_FOUND
set "PATH=%PATH%;C:\Program Files\CMake\bin"
cmake --version >NUL 2>NUL
if %ERRORLEVEL% EQU 0 GOTO :CMAKE_FOUND

:CMAKE_NOT_FOUND
set "MSG=CMake is required to build OpenCV samples. Download it from here: https://cmake.org/download/ and install into 'C:\Program Files\CMake'"
goto die

:CMAKE_FOUND
set CMAKE_FOUND=1
call :execute cmake --version
echo CMake is detected

:: Detect available MSVS version
if NOT DEFINED VisualStudioVersion (
  set "MSG=Can't determine MSVS version. 'VisualStudioVersion' is not defined"
  goto die
)
if "%VisualStudioVersion%" == "14.0" (
  set CMAKE_GENERATOR="Visual Studio 14 Win64"
  set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc14\bin\"
) else (
  if "%VisualStudioVersion%" == "15.0" (
    set CMAKE_GENERATOR="Visual Studio 15 Win64"
    set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\"
  ) else (
    set "MSG=Unsupported MSVS version. VisualStudioVersion=%VisualStudioVersion%"
    goto die
  )
)

set "BUILD_DIR=%SRC_DIR%\build_%SRC_NAME%"
call :set_title Create build directory
if NOT exist "%BUILD_DIR%" ( call :execute md "%BUILD_DIR%" )
PUSHD "%BUILD_DIR%"
if NOT exist "%BUILD_DIR%/sample" ( call :execute md "%BUILD_DIR%/sample" )
call :execute copy /Y "%SCRIPTDIR%/CMakeLists.example.in" "%BUILD_DIR%/sample/CMakeLists.txt"

call :set_title Configuring via CMake
call :execute cmake -G%CMAKE_GENERATOR% "%BUILD_DIR%\sample" -DEXAMPLE_NAME=%SRC_NAME% "-DEXAMPLE_FILE=%SRC_FILENAME%" "-DOpenCV_DIR=%SCRIPTDIR%\..\..\build"
if %ERRORLEVEL% NEQ 0 (
  set "MSG=CMake configuration step failed: %BUILD_DIR%"
  goto die
)

call :set_title Build sample project via CMake
call :execute cmake --build . --config Release
if %ERRORLEVEL% NEQ 0 (
  set "MSG=Build step failed: %BUILD_DIR%"
  goto die
)

call :set_title Launch %SRC_NAME%
if NOT exist "%BUILD_DIR%\Release\%SRC_NAME%.exe" (
  echo. "ERROR: Can't find executable file (build seems broken): %SRC_NAME%.exe"
) else (
  cd "%BUILD_DIR%\Release"
  call :execute "%SRC_NAME%.exe" --help
  echo ================================================================================
  echo **  Type '%SRC_NAME%.exe' to run sample application
  echo **  Type '%SRC_NAME%.exe --help' to get list of available options (if available)
  echo **  Type 'start ..\%SRC_NAME%.sln' to launch MSVS IDE
  echo **  Type 'cmake --build .. --config Release' to rebuild sample
  echo **  Type 'exit' to exit from interactive shell and open the build directory
  echo ================================================================================
)

call :set_title Hands-on: %SRC_NAME%
cmd /k echo Current directory: %CD%

call :set_title Done: %SRC_NAME%
echo Opening build directory with project files...
explorer "%BUILD_DIR%"

POPD
echo Done%

pause
exit /B 0

::
:: Helper routines
::

:set_title
  title OpenCV sample: %*
  EXIT /B 0

:execute
  echo =================================================================================
  setlocal
  echo %*
  call %*
  endlocal
  EXIT /B %ERRORLEVEL%

:dirname file resultVar
  setlocal
  set _dir=%~dp1
  set _dir=%_dir:~0,-1%
  endlocal & set %2=%_dir%
  EXIT /B 0

:: 'goto die' instead of 'call'
:die
  TITLE OpenCV sample: ERROR: %MSG%
  echo ERROR: %MSG%
  pause
  EXIT /B 1

:: Usage:
:: - Drag & drop .cpp file on this file from Windows explorer
:: - Run from cmd/powershell:
::   - > _winpack_build_sample.cmd cpp\opencv_version.cpp
:: Requires:
:: - CMake
:: - MSVS 2015/2017
:: (tools are searched on default paths or environment should be pre-configured)
@echo off
setlocal

set SCRIPTDIR=%~dp0
if NOT exist "%SCRIPTDIR%\..\..\build" (
  set "MSG=OpenCV Winpack installation is required"
  goto die
)

if [%1]==[] (
  set "MSG=Sample path is required"
  goto die
)
if exist %1\* (
  set "MSG=Only .cpp samples are allowed (not a directory): %1"
  goto die
)
if NOT "%~x1" == ".cpp" (
  set "MSG=Only .cpp samples are allowed: %~x1"
  goto die
)
set SRC_FILENAME=%~dpnx1
echo SRC_FILENAME=%SRC_FILENAME%
call :dirname "%SRC_FILENAME%" SRC_DIR
echo SRC_DIR=%SRC_DIR%
set "SRC_NAME=%~n1"
echo SRC_NAME=%SRC_NAME%
echo ================================================================================

:: Path to FFMPEG binary files
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\bin\"

:: Detect compiler
cl /? >NUL 2>NUL <NUL
if %ERRORLEVEL% == 0 (
  goto detect_cmake
)
PUSHD %CD%

CALL :try_call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
IF ERRORLEVEL 1 (
  CALL :try_call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
)
IF ERRORLEVEL 1 (
  CALL :try_call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
)

IF ERRORLEVEL 1 (
  CALL :try_call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat"
)
IF ERRORLEVEL 1 (
  CALL :try_call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
)
IF ERRORLEVEL 1 (
  CALL :try_call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
)

IF ERRORLEVEL 1 (
  CALL :try_call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
)

POPD
cl /? >NUL 2>NUL <NUL
if %ERRORLEVEL% NEQ 0 (
  set "MSG=Can't detect Microsoft Visial Studio C++ compiler (cl.exe). MSVS 2015/2017/2019 are supported only from standard locations"
  goto die
)

:: Detect CMake
:detect_cmake
cmake --version >NUL 2>NUL
if %ERRORLEVEL% EQU 0 GOTO :CMAKE_FOUND

if NOT exist "C:\Program Files\CMake\bin" GOTO CMAKE_NOT_FOUND
set "PATH=%PATH%;C:\Program Files\CMake\bin"
cmake --version >NUL 2>NUL
if %ERRORLEVEL% EQU 0 GOTO :CMAKE_FOUND

:CMAKE_NOT_FOUND
set "MSG=CMake is required to build OpenCV samples. Download it from here: https://cmake.org/download/ and install into 'C:\Program Files\CMake'"
goto die

:CMAKE_FOUND
set CMAKE_FOUND=1
call :execute cmake --version
echo CMake is detected
where cmake

:: Detect available MSVS version
if NOT DEFINED VisualStudioVersion (
  set "MSG=Can't determine MSVS version. 'VisualStudioVersion' is not defined"
  goto die
)
if "%VisualStudioVersion%" == "14.0" (
  set "CMAKE_GENERATOR=-G^"Visual Studio 14 Win64^""
  set "BUILD_DIR_SUFFIX=.vc14"
  set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc14\bin\"
) else (
  if "%VisualStudioVersion%" == "15.0" (
    set "CMAKE_GENERATOR=-G^"Visual Studio 15 Win64^""
    set "BUILD_DIR_SUFFIX=.vc15"
    set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\"
  ) else (
    if "%VisualStudioVersion%" == "16.0" (
      echo.==========================================
      echo.*  Note: MSVS 2019 requires CMake 3.14+  *
      echo.==========================================
      set "CMAKE_GENERATOR=-G^"Visual Studio 16 2019^" -A x64"
      set "BUILD_DIR_SUFFIX=.vc16"
      set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\"
    ) else (
      set "MSG=Unsupported MSVS version. VisualStudioVersion=%VisualStudioVersion%"
      goto die
    )
  )
)

set "BUILD_DIR=%SRC_DIR%\build_%SRC_NAME%%BUILD_DIR_SUFFIX%"
call :set_title Create build directory
if NOT exist "%BUILD_DIR%" ( call :execute md "%BUILD_DIR%" )
PUSHD "%BUILD_DIR%"
if NOT exist "%BUILD_DIR%/sample" ( call :execute md "%BUILD_DIR%/sample" )
call :execute copy /Y "%SCRIPTDIR%/CMakeLists.example.in" "%BUILD_DIR%/sample/CMakeLists.txt"

call :set_title Configuring via CMake
call :execute cmake %CMAKE_GENERATOR% "%BUILD_DIR%\sample" -DEXAMPLE_NAME=%SRC_NAME% "-DEXAMPLE_FILE=%SRC_FILENAME%" "-DOpenCV_DIR=%SCRIPTDIR%\..\..\build"
if %ERRORLEVEL% NEQ 0 (
  set "MSG=CMake configuration step failed: %BUILD_DIR%"
  goto die
)

call :set_title Build sample project via CMake
call :execute cmake --build . --config Release
if %ERRORLEVEL% NEQ 0 (
  set "MSG=Build step failed: %BUILD_DIR%"
  goto die
)

call :set_title Launch %SRC_NAME%
if NOT exist "%BUILD_DIR%\Release\%SRC_NAME%.exe" (
  echo. "ERROR: Can't find executable file (build seems broken): %SRC_NAME%.exe"
) else (
  cd "%BUILD_DIR%\Release"
  call :execute "%SRC_NAME%.exe" --help
  echo ================================================================================
  echo **  Type '%SRC_NAME%.exe' to run sample application
  echo **  Type '%SRC_NAME%.exe --help' to get list of available options (if available)
  echo **  Type 'start ..\%SRC_NAME%.sln' to launch MSVS IDE
  echo **  Type 'cmake --build .. --config Release' to rebuild sample
  echo **  Type 'exit' to exit from interactive shell and open the build directory
  echo ================================================================================
)

call :set_title Hands-on: %SRC_NAME%
cmd /k echo Current directory: %CD%

call :set_title Done: %SRC_NAME%
echo Opening build directory with project files...
explorer "%BUILD_DIR%"

POPD
echo Done%

pause
exit /B 0

::
:: Helper routines
::

:set_title
  title OpenCV sample: %*
  EXIT /B 0

:execute
  echo =================================================================================
  setlocal
  echo %*
  call %*
  endlocal
  EXIT /B %ERRORLEVEL%

:dirname file resultVar
  setlocal
  set _dir=%~dp1
  set _dir=%_dir:~0,-1%
  endlocal & set %2=%_dir%
  EXIT /B 0

:try_call
IF EXIST %1 (
  CALL %*
  EXIT /B
) ELSE (
  EXIT /B 1
)

:: 'goto die' instead of 'call'
:die
  TITLE OpenCV sample: ERROR: %MSG%
  echo ERROR: %MSG%
  pause
  EXIT /B 1

support MSVS 2019 compiler

samples: support MSVS 2019 compiler

requires CMake 3.14+


@echo off
setlocal
SET JDK=c:\jdk1.3
set JING_HOME=%~d0%~p0..
%JDK%\bin\java -Dant.home=%JING_HOME% -cp %JING_HOME%\lib\ant.jar;%JING_HOME%\lib\saxon.jar;%JING_HOME%\lib\crimson.jar;%JING_HOME%\lib\optional.jar;%JDK%\lib\tools.jar;%JING_HOME%\lib\junit.jar;%JING_HOME%\lib\regex.jar;%JING_HOME%\lib\isorelax.jar org.apache.tools.ant.Main -buildfile %JING_HOME%\build.xml %*

@echo off
setlocal
SET JDK=c:\jdk1.3
set JING_HOME=%~d0%~p0..
%JDK%\bin\java -Dant.home=%JING_HOME% -cp %JING_HOME%\lib\ant.jar;%JING_HOME%\lib\saxon.jar;%JING_HOME%\lib\crimson.jar;%JING_HOME%\lib\optional.jar;%JDK%\lib\tools.jar;%JING_HOME%\lib\junit.jar;%JING_HOME%\lib\regex.jar;%JING_HOME%\lib\regex2.jar;%JING_HOME%\lib\isorelax.jar org.apache.tools.ant.Main -buildfile %JING_HOME%\build.xml %*

Add regex2.jar

Add regex2.jar


call \ned\bin\switchpy 23
python setup.py develop
nosetests
call \ned\bin\switchpy 24
python setup.py develop
nosetests
call \ned\bin\switchpy 25
python setup.py develop
nosetests
call \ned\bin\switchpy 26
python setup.py develop
nosetests

call \ned\bin\switchpy 23
python setup.py develop
nosetests
del coverage\tracer.pyd
nosetests
call \ned\bin\switchpy 24
python setup.py develop
nosetests
del coverage\tracer.pyd
nosetests
call \ned\bin\switchpy 25
python setup.py develop
nosetests
del coverage\tracer.pyd
nosetests
call \ned\bin\switchpy 26
python setup.py develop
nosetests
del coverage\tracer.pyd
nosetests

Test the code without a C extension.

Test the code without a C extension.


npm install
cd character
npm install ; tsd install
cd ..\enemytarget
npm install ; tsd install
cd ..\friendlytarget
npm install ; tsd install
cd ..\lib
git clone https://github.com/Mehuge/cu-components
cd cu-components
npm install ; tsd install
cd ../..

Initialise the development environment (run after cloning)


@setlocal enableextensions enabledelayedexpansion & set "PATH0=%~f0" & PowerShell.exe -Command "& (Invoke-Expression -Command ('{#' + ((Get-Content '!PATH0:'=''!') -join \"`n\") + '}'))" %* & exit /b !errorlevel!
#
# - Name
#     ssh.bat
#
# - Contents
#     Simplify SSH Connect by Tera Term.
#     <Windows> + <R> => ssh root@192.168.1.100
#
# - Install
#     powershell.exe -Command "Invoke-RestMethod -Uri "https://initsh.github.io/ps1/ssh.bat" | Out-File -Encoding utf8 "$env:USERPROFILE\ssh.bat""
#
# - Reference
#     http://pf-j.sakura.ne.jp/program/tips/ps1bat2.htm
#
# - Revision
#     2016-12-28 created.
#     2017-04-14 modified.
#     2017-05-22 modified.
#     yyyy-MM-dd modified.
#

################
# constant
################
### 作業ディレクトリ
#[System.String] $base_dir = "$env:Userprofile"             # ベースディレクトリ
[System.String] $base_dir = "$env:Userprofile\GoogleDrive" # ベースディレクトリ
[System.String] $ssh_dir  = "$base_dir\ssh"                # teraterm起動ディレクトリ
[System.String] $log_dir  = "$ssh_dir\log"                 # teratermログ出力ディレクトリ
[System.String] $key_dir  = "$ssh_dir\key"                 # 秘密鍵設置ディレクトリ
[System.String] $csv_file = "$ssh_dir\hosts.csv"           # ログイン情報CSVファイル
[System.String] $tt_install_uri = "https://ja.osdn.net/frs/redir.php?m=ymu&f=%2Fttssh2%2F67179%2Fteraterm-4.94.exe"
[System.String] $tt_install_exe = "$env:USERPROFILE\Downloads\teraterm-4.94.exe"

################
# variable
################
[System.String] $date = Get-Date -Format yyyyMMdd
[System.String] $time = Get-Date -Format HHmmss

################
# main
################
### ディレクトリを作成
if ((Get-Item $ssh_dir).Mode | Select-String -NotMatch '^d') { mkdir $ssh_dir; }
if ((Get-Item $log_dir).Mode | Select-String -NotMatch '^d') { mkdir $log_dir; }
if ((Get-Item $key_dir).Mode | Select-String -NotMatch '^d') { mkdir $ssh_dir; }
if (-Not (Test-Path $csv_file))
{
    Write-Output @'
Hostname,Port,Username,AuthType,Value,Alias
# 1行目はヘッダー情報となります。編集しないでください。

# 以下を参照の上、記載例のように設定してください。
# ホスト名,ポート番号,ユーザ名,認証タイプ[password|publickey],値[パスワード|keyディレクトリ配下の秘密鍵の名前],sshコマンドの引数とする任意のエイリアス文字列を指定。UPN表記を推奨。

# 以下、記載例。
www.example.com,22,admin,publickey,id_rsa,admin@www.example.com
192.168.1.100,22,root,password,P@ssw0rd,root@192.168.1.100
'@ > $csv_file
    Write-Output "$(Get-Date -Format yyyy-MM-ddTHH:mm:sszzz) [NOTICE]: Check the file( $csv_file ) and set it as shown in the description example."
    Write-Output "$(Get-Date -Format yyyy-MM-ddTHH:mm:sszzz) [NOTICE]: Edit the file( $csv_file ) and try again."
    notepad $csv_file
    [Console]::ReadKey() | Out-Null
    exit 1
}

### teratemrインストールディレクトリからttermpro.exeを検索し、ttermpro.exeのフルパスを取得する
[System.String] $ssh_client = Get-ChildItem -recurse "C:\Program Files*\teraterm" | Where-Object { $_.Name -match "ttermpro" } | ForEach-Object { $_.FullName }
###
if (-Not ($?) -Or -Not (Test-Path -Path $ssh_client))
{
    Invoke-WebRequest -Uri $tt_install_uri -OutFile $tt_install_exe
    Start-Process -FilePath $tt_install_exe -PassThru -Wait
    [System.String] $ssh_client = Get-ChildItem -recurse "C:\Program Files*\teraterm" | Where-Object { $_.Name -match "ttermpro" } | ForEach-Object { $_.FullName }
    if (-Not ($?) -Or -Not (Test-Path -Path $ssh_client))
    {
        Write-Output "$(Get-Date -Format yyyy-MM-ddTHH:mm:sszzz) [ERROR]: ttermpro.exe not found in `"C:\Program Files*`"."
        [Console]::ReadKey() | Out-Null
        exit 1
    }
}

if ($args[0])
{
    ### $args[0]には<username>@<hostname>形式を想定
    [System.String] $ssh_alias = $args[0]
    [System.Array] $ssh_args = $args[0] -split "@"
    [System.String] $ssh_log = "$log_dir\" + $ssh_args[1] + "_" + $ssh_args[0] + "_" + $date + "_" + $time + ".log"

    ### $args[0]の値と、CSV内のAliasの値で、一致するものを取得する
    [System.Array] $csv_data = Import-Csv $csv_file | Where-Object { $_.Alias -eq $ssh_alias }

    ### $args[0]の値と、CSV内のAliasの値で、一致するものが存在する場合
    if ($csv_data)
    {
        ### TeraTermに渡す引数を作成
        [System.String] $opt_host = "ssh2://" + $csv_data[0].Hostname + ":" + $csv_data[0].Port
        [System.String] $opt_user = "/user=" + $csv_data[0].Username
        [System.String] $opt_auth = "/auth=" + $csv_data[0].AuthType
        if ($csv_data[0].AuthType -eq "password")
        {
            [System.String] $opt_value = "/passwd=" + $csv_data[0].Value
        }
        elseif ($csv_data[0].AuthType -eq "publickey")
        {
            [System.String] $opt_value = "/keyfile=$key_dir\" + $csv_data[0].Value
        }
        [System.String] $opt_dir = "/FD=$ssh_dir"
        [System.String] $opt_log = "/L=$ssh_log"

        [System.Array] $opt_array = @($opt_host,$opt_user,$opt_auth,$opt_value,$opt_dir,$opt_log,"/ssh-v","/LA=J")

    }
    ### $args[0]の値と、CSV内のAliasの値で、一致するものが存在しない場合
    else
    {
        ### CSVの内容を表示
        Get-Item $csv_file
        Import-Csv $csv_file | Where-Object { ($_.Alias) } | Select-Object Username,Hostname,Alias | Format-Table -AutoSize
        [Console]::ReadKey() | Out-Null
        exit 0
    }
}
else
{
    [System.String] $ssh_log = "$log_dir\undefined_undefined_" + $date + "_" + $time + ".log"
    [System.String] $opt_dir = "/FD=" + $ssh_dir
    [System.String] $opt_log = "/L=$ssh_log"
    [System.Array] $opt_array = @($opt_dir,$opt_log,"/ssh-v","/LA=J")
}

### teratermを実行
$ssh_process = Start-Process -FilePath $ssh_client -ArgumentList $opt_array -PassThru -Wait
### teratermログファイルの属性を読み込み専用に変更
Set-ItemProperty -Path $ssh_log -Name Attributes -Value Readonly
### teratermログファイルの内容を表示(個人的な趣味)
Get-Content -Path $ssh_log
### teratermログファイルの情報を画面に出力
Write-Output "$(Get-Date -Format yyyy-MM-ddThh:mm:sszzz) [INFO]: Log file: $ssh_log"
### TeraTermが異常終了 => 既に確立済みのsshセッションが、ネットワーク切断等により強制終了した場合
if ($ssh_process.ExitCode -ne 0)
{
    Write-Output "$(Get-Date -Format yyyy-MM-ddThh:mm:sszzz) [ERROR]: ttermpro.exe exit code NOT equal 0."
}
[Console]::ReadKey() | Out-Null
exit 0

@setlocal enableextensions enabledelayedexpansion & set "PATH0=%~f0" & PowerShell.exe -Command "& (Invoke-Expression -Command ('{#' + ((Get-Content '!PATH0:'=''!') -join \"`n\") + '}'))" %* & exit /b !errorlevel!
#
# - Name
#     ssh.bat
#
# - Contents
#     Simplify SSH Connect by Tera Term.
#     <Windows> + <R> => ssh root@192.168.1.100
#
# - Install
#     powershell.exe -Command "Invoke-RestMethod -Uri "https://initsh.github.io/ps1/ssh.bat" | Out-File -Encoding utf8 "$env:USERPROFILE\ssh.bat""
#
# - Reference
#     http://pf-j.sakura.ne.jp/program/tips/ps1bat2.htm
#
# - Revision
#     2016-12-28 created.
#     2017-04-14 modified.
#     2017-05-22 modified.
#     yyyy-MM-dd modified.
#

################
# constant
################
#[System.String] $base_dir = "$env:Userprofile"
[System.String] $base_dir = "$env:Userprofile\GoogleDrive"
[System.String] $ssh_dir  = "$base_dir\ssh"
[System.String] $log_dir  = "$ssh_dir\log"
[System.String] $key_dir  = "$ssh_dir\key"
[System.String] $csv_file = "$ssh_dir\hosts.csv"
[System.String] $tt_install_uri = "https://ja.osdn.net/frs/redir.php?m=ymu&f=%2Fttssh2%2F67179%2Fteraterm-4.94.exe"
[System.String] $tt_install_exe = "$env:USERPROFILE\Downloads\teraterm-4.94.exe"

################
# variable
################
[System.String] $date = Get-Date -Format yyyyMMdd
[System.String] $time = Get-Date -Format HHmmss

################
# main
################
### Create directorys.
if ((Get-Item $ssh_dir).Mode | Select-String -NotMatch '^d') { mkdir $ssh_dir; }
if ((Get-Item $log_dir).Mode | Select-String -NotMatch '^d') { mkdir $log_dir; }
if ((Get-Item $key_dir).Mode | Select-String -NotMatch '^d') { mkdir $ssh_dir; }
if (-Not (Test-Path $csv_file))
{
    Write-Output @'
Hostname,Port,Username,AuthType,Value,Alias
# In the first line, Header information is written. Please do not edit!

# Please refer to the following and set it like the description example.
# Hostname,PortNumber,Username,AuthenticationType[password|publickey],Value[Passphrase|NameOfSecretKey],Set an alias character string as an argument of ssh command. UPN notation is recommended.

# description example:
www.example.com,22,admin,publickey,id_rsa,admin@www.example.com
192.168.1.100,22,root,password,P@ssw0rd,root@192.168.1.100
'@ > $csv_file
    Write-Output "$(Get-Date -Format yyyy-MM-ddTHH:mm:sszzz) [NOTICE]: Check the file( $csv_file ) and set it as shown in the description example."
    Write-Output "$(Get-Date -Format yyyy-MM-ddTHH:mm:sszzz) [NOTICE]: Edit the file( $csv_file ) and try again."
    notepad $csv_file
    [Console]::ReadKey() | Out-Null
    exit 1
}

### Search for ttermpro.exe from the directory where teraterm was installed and get the full path of ttermpro.exe.
[System.String] $ssh_client = Get-ChildItem -recurse "C:\Program Files*\teraterm" | Where-Object { $_.Name -match "ttermpro" } | ForEach-Object { $_.FullName }
###
if (-Not ($?) -Or -Not (Test-Path -Path $ssh_client))
{
    Invoke-WebRequest -Uri $tt_install_uri -OutFile $tt_install_exe
    Start-Process -FilePath $tt_install_exe -PassThru -Wait
    [System.String] $ssh_client = Get-ChildItem -recurse "C:\Program Files*\teraterm" | Where-Object { $_.Name -match "ttermpro" } | ForEach-Object { $_.FullName }
    if (-Not ($?) -Or -Not (Test-Path -Path $ssh_client))
    {
        Write-Output "$(Get-Date -Format yyyy-MM-ddTHH:mm:sszzz) [ERROR]: ttermpro.exe not found in `"C:\Program Files*`"."
        [Console]::ReadKey() | Out-Null
        exit 1
    }
}

if ($args[0])
{
    ### $args[0] = Alias. UPN notation is recommended.
    [System.String] $ssh_alias = $args[0]
    [System.Array] $ssh_args = $args[0] -split "@"
    [System.String] $ssh_log = "$log_dir\" + $ssh_args[1] + "_" + $ssh_args[0] + "_" + $date + "_" + $time + ".log"

    ### Get a match with the value of $args[0] and the value of Alias in CSV.
    [System.Array] $csv_data = Import-Csv $csv_file | Where-Object { $_.Alias -eq $ssh_alias }

    ### If there is a match between the value of $args[0] and the value of Alias in CSV,
    if ($csv_data)
    {
        ### Create arguments to pass to ttermpro.exe.
        [System.String] $opt_host = "ssh2://" + $csv_data[0].Hostname + ":" + $csv_data[0].Port
        [System.String] $opt_user = "/user=" + $csv_data[0].Username
        [System.String] $opt_auth = "/auth=" + $csv_data[0].AuthType
        if ($csv_data[0].AuthType -eq "password")
        {
            [System.String] $opt_value = "/passwd=" + $csv_data[0].Value
        }
        elseif ($csv_data[0].AuthType -eq "publickey")
        {
            [System.String] $opt_value = "/keyfile=$key_dir\" + $csv_data[0].Value
        }
        [System.String] $opt_dir = "/FD=$ssh_dir"
        [System.String] $opt_log = "/L=$ssh_log"

        [System.Array] $opt_array = @($opt_host,$opt_user,$opt_auth,$opt_value,$opt_dir,$opt_log,"/ssh-v","/LA=J")

    }
    ### If there is no matching match between the value of $args[0] and the value of Alias in CSV,
    else
    {
        ### Show contents of CSV.
        Get-Item $csv_file
        Import-Csv $csv_file | Where-Object { ($_.Alias) } | Select-Object Username,Hostname,Alias | Format-Table -AutoSize
        [Console]::ReadKey() | Out-Null
        exit 0
    }
}
else
{
    [System.String] $ssh_log = "$log_dir\undefined_undefined_" + $date + "_" + $time + ".log"
    [System.String] $opt_dir = "/FD=" + $ssh_dir
    [System.String] $opt_log = "/L=$ssh_log"
    [System.Array] $opt_array = @($opt_dir,$opt_log,"/ssh-v","/LA=J")
}

### Run teraterm.
$ssh_process = Start-Process -FilePath $ssh_client -ArgumentList $opt_array -PassThru -Wait
### Change attribute of teraterm log file to read only.
Set-ItemProperty -Path $ssh_log -Name Attributes -Value Readonly
### Display the contents of teraterm log file (personal preference...).
Get-Content -Path $ssh_log
### Output contents of teraterm log file to screen.
Write-Output "$(Get-Date -Format yyyy-MM-ddThh:mm:sszzz) [INFO]: Log file: $ssh_log"
### TeraTerm abnormal termination: A case where an already established ssh session is forcibly terminated due to network disconnection or the like.
if ($ssh_process.ExitCode -ne 0)
{
    Write-Output "$(Get-Date -Format yyyy-MM-ddThh:mm:sszzz) [ERROR]: ttermpro.exe exit code NOT equal 0."
}
[Console]::ReadKey() | Out-Null
exit 0

Update ssh.bat

Update ssh.bat


@echo off

goto entry

:usage
  echo usage: bolt build [-c^|--config CONFIG_JS] [-o^|--output OUTPUT_DIR] [-s^|--src-dir SRC_DIR]
  echo                   [-i^|--inline] [-n^|--invoke-main MAIN_MODULE] [-r^|--register]
  echo                   [-m^|--modules] [-e^|--entry-points FILE ...] [-g^|--entry-group NAME FILE ...]
  echo.
  echo options:
  echo   -c^|--config CONFIG_JS         override bolt configuration file
  echo                                    default: config/bolt/prod.js
  echo   -o^|--output OUTPUT_DIR         override output directory, note this is different
  echo                                  to the jsc compile directory, the compiled output,
  echo                                  will be located at $OUTPUT_DIR/compile
  echo                                    default: scratch/main/js
  echo   -s^|--src-dir SRC_DIR           override source directory
  echo                                    default: src/main/js
  echo   -i^|--inline                    enable generation of inline scripts (only produces output
  echo                                  in conjunction with -e or -g).
  echo   -n^|--invoke-main MAIN_MODULE   specify main module of inline scripts.
  echo   -r^|--register                  register modules in global namespace for inline scripts,
  echo                                  this will default to true unless -n is specified.
  echo   -m^|--modules                   enable generation of flat module files.
  echo   -e^|--entry-points FILE ...     specify a set of entry points, a compiled output
  echo                                  will be generated for each entry point. Multiple
  echo                                  -e flags may be specified.
  echo   -g^|--entry-group NAME FILE ... specify an entry group, a single compiled output
  echo                                  will be generated with NAME for each entry-group.
  echo                                  Multiple -g flags may be specified.
  echo.
  echo example:
  echo   Produce a bolt build for a top level application. A compiled file will be
  echo   generated for each Main module in this example.
  echo.
  echo     bolt build -e src/main/js/**/*Main.js
  echo.
  echo.
  echo   Produce a bolt build for a top level library. A self contained script registering
  echo   all modules in their namespace will be produced.
  echo.
  echo     bolt build -i -g example src/main/js/**/api/*.js
  echo.
  echo.
  echo   Produce a bolt build for a general purpose library, in this build we only want
  echo   modules to be produced, no compiled output.
  echo.
  echo     bolt build -m src/main/js

  exit /b 0

:fail_usage
  echo.
  call :usage
  exit /b 1

:fail
  exit /b 1

:is_dir
  setlocal
  set olddir=%CD%
  cd /D "%~1" 2>NUL
  set err=%errorlevel%
  cd /D "%olddir%"
  exit /b %err%

:entry

if "%help_mode%"=="true" call :usage && exit /b 0

set count_targets=0
set count_entry_point=0
set count_entry_group_name=0

:parse_flags
  set flag=%~1
  if not "%flag:~0,1%"=="-" goto done_parse_flags
  shift

  if "%flag%"=="-c" goto parse_config
  if "%flag%"=="--config" goto parse_config
  if "%flag%"=="-o" goto parse_output
  if "%flag%"=="--output" goto parse_output
  if "%flag%"=="-s" goto parse_src
  if "%flag%"=="--src-dir" goto parse_src
  if "%flag%"=="-n" goto parse_invoke
  if "%flag%"=="--invoke-main" goto parse_invoke
  if "%flag%"=="-r" goto parse_register
  if "%flag%"=="--register" goto parse_register
  if "%flag%"=="-i" goto parse_inline
  if "%flag%"=="--inline" goto parse_inline
  if "%flag%"=="-m" goto parse_modules
  if "%flag%"=="--modules" goto parse_modules
  if "%flag%"=="-e" goto parse_points
  if "%flag%"=="--entry-points" goto parse_points
  if "%flag%"=="-g" goto parse_group
  if "%flag%"=="--entry-group" goto parse_group
  if "%flag%"=="--" goto done_parse_flags
  echo invalid flag [%flag%] && goto fail_usage

  goto parse_flags

  :parse_config
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set config_js=%~1
    shift
  goto parse_flags

  :parse_output
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set output_dir=%~1
    shift
  goto parse_flags

  :parse_src
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set src_dir=%~1
    shift
  goto parse_flags

  :parse_invoke
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set invoke_main_flag=-n "%~1"
    shift
  goto parse_flags

  :parse_register
    set register_modules_flag=-r
  goto parse_flags

  :parse_inline
    set generate_inline=true
  goto parse_flags

  :parse_modules
    set generate_modules=true
  goto parse_flags

  :parse_points
    :point_loop
      set entry=%~1
      if "%entry%"=="" goto end_point_loop
      if "%entry:~0,1%"=="-" goto end_point_loop
      shift

      if not exist "%entry%" echo specified file for entry point not found [%entry%] && goto fail
      call :is_dir "%entry%"
      if %errorlevel%==0 echo specified file for entry point not found [%entry%] && goto fail

      set entry_point_%count_entry_point%=%entry%
      set /a count_entry_point=%count_entry_point% + 1
    goto point_loop
    :end_point_loop
  goto parse_flags

  :parse_group
    if "%~2"=="" echo %flag% requires two arguments to be specified && goto fail_usage
    set name=%~1
    shift

    echo.%name%| findstr /C:"/" >NUL 2>&1 && echo entry group name must not contain special characters >&2 && goto fail

    set entry_group_name_%count_entry_group_name%=%name%
    set /a count_entry_group_name=%count_entry_group_name% + 1

    set safe_name=%name:-=_%
    set /a count_entry_groups_%safe_name%=0

    :group_loop
      set file=%~1
      if "%file%"=="" goto end_group_loop
      if "%file:~0,1%"=="-" goto end_group_loop
      shift

      if not exist "%file%" echo specified file for entry group not found [%file%] && goto fail
      call :is_dir "%file%"
      if %errorlevel%==0 echo specified file for entry group not found [%file%] && goto fail

      set count=!count_entry_groups_%safe_name%!
      set entry_groups_%safe_name%_%count%=%file%
      set /a count_entry_groups_%safe_name%=%count% + 1
    goto group_loop
    :end_group_loop
  goto parse_flags

:done_parse_flags

if "%config_js%"=="" set config_js=config/bolt/prod.js
if "%output_dir%"=="" set output_dir=scratch/main/js
if "%src_dir%"=="" set src_dir=src/main/js
if "%generate_inline%"=="" set generate_inline=false
if "%generate_modules%"=="" set generate_modules=false

goto dispatch

:bolt_inline
  set target=%~1
  set name=%~2
  mkdir "%output_dir%/inline" 2> NUL
  call "%base%jsc.bat" inline -c "%config_js%" %invoke_main_flag% %register_modules_flag% "%target%" "%output_dir%/inline/%name%.js" || exit /b %errorlevel%
  exit /b 0

:bolt_point
  mkdir "%output_dir%/compile" 2>NUL

  set /a num=%count_entry_point% - 1
  for /L %%i in (0,1,%num%) do (
    rem iterate through the array
    set file=!entry_point_%%i!
    for /F "usebackq delims=" %%j in (`""%base%jsc" identify "!file!""`) do set name=%%j
    set target=!output_dir!\compile\!name!.js

    rem push onto the targets array so things can be linked later
    set targets_!count_targets!=!target!
    set /a count_targets=!count_targets! + 1

    call "!base!jsc.bat" compile -c "%config_js%" "!file!" "!target!" || exit /b !errorlevel!

    if "%generate_inline%"=="true" call :bolt_inline "!target!" "!name!"
  )
  exit /b 0

:bolt_group
  echo bolt_group unimplemented.
  exit /b 0

:bolt_link
  echo bolt_link unimplemented.
  exit /b 0

:bolt_modules
  mkdir "%output_dir%/module" 2>NUL
  set olddir=%CD%
  cd /D "%output_dir%/module"
  for /F "usebackq delims=" %%i in (`cd`) do set module_dir=%%i
  cd /D "%olddir%"
  cd /D "%src_dir%"
  for /F "usebackq delims=" %%m in (`glob **\*.js`) do (set module=%%m) && copy "%%m" "%module_dir%\!module:\=.!" >NUL
  cd /D "%olddir%"
  exit /b 0

:dispatch

if %count_entry_point% GTR 0 call :bolt_point || exit /b %errorlevel%
if %count_entry_group_name% GTR 0 call :bolt_group || exit /b %errorlevel%
if %count_targets% GTR 0 call :bolt_link || exit /b %errorlevel%
if "%generate_modules%"=="true" call :bolt_modules || exit /b %errorlevel%

exit /b 0

@echo off

goto entry

:usage
  echo usage: bolt build [-c^|--config CONFIG_JS] [-o^|--output OUTPUT_DIR] [-s^|--src-dir SRC_DIR]
  echo                   [-i^|--inline] [-n^|--invoke-main MAIN_MODULE] [-r^|--register]
  echo                   [-m^|--modules] [-e^|--entry-points FILE ...] [-g^|--entry-group NAME FILE ...]
  echo.
  echo options:
  echo   -c^|--config CONFIG_JS         override bolt configuration file
  echo                                    default: config/bolt/prod.js
  echo   -o^|--output OUTPUT_DIR         override output directory, note this is different
  echo                                  to the jsc compile directory, the compiled output,
  echo                                  will be located at $OUTPUT_DIR/compile
  echo                                    default: scratch/main/js
  echo   -s^|--src-dir SRC_DIR           override source directory
  echo                                    default: src/main/js
  echo   -i^|--inline                    enable generation of inline scripts (only produces output
  echo                                  in conjunction with -e or -g).
  echo   -n^|--invoke-main MAIN_MODULE   specify main module of inline scripts.
  echo   -r^|--register                  register modules in global namespace for inline scripts,
  echo                                  this will default to true unless -n is specified.
  echo   -m^|--modules                   enable generation of flat module files.
  echo   -e^|--entry-points FILE ...     specify a set of entry points, a compiled output
  echo                                  will be generated for each entry point. Multiple
  echo                                  -e flags may be specified.
  echo   -g^|--entry-group NAME FILE ... specify an entry group, a single compiled output
  echo                                  will be generated with NAME for each entry-group.
  echo                                  Multiple -g flags may be specified.
  echo.
  echo example:
  echo   Produce a bolt build for a top level application. A compiled file will be
  echo   generated for each Main module in this example.
  echo.
  echo     bolt build -e src/main/js/**/*Main.js
  echo.
  echo.
  echo   Produce a bolt build for a top level library. A self contained script registering
  echo   all modules in their namespace will be produced.
  echo.
  echo     bolt build -i -g example src/main/js/**/api/*.js
  echo.
  echo.
  echo   Produce a bolt build for a general purpose library, in this build we only want
  echo   modules to be produced, no compiled output.
  echo.
  echo     bolt build -m src/main/js

  exit /b 0

:fail_usage
  echo.
  call :usage
  exit /b 1

:fail
  exit /b 1

:is_dir
  setlocal
  set olddir=%CD%
  cd /D "%~1" 2>NUL
  set err=%errorlevel%
  cd /D "%olddir%"
  exit /b %err%

:entry

if "%help_mode%"=="true" call :usage && exit /b 0

set targets=
set count_targets=0
set count_entry_point=0
set count_entry_group_name=0

:parse_flags
  set flag=%~1
  if not "%flag:~0,1%"=="-" goto done_parse_flags
  shift

  if "%flag%"=="-c" goto parse_config
  if "%flag%"=="--config" goto parse_config
  if "%flag%"=="-o" goto parse_output
  if "%flag%"=="--output" goto parse_output
  if "%flag%"=="-s" goto parse_src
  if "%flag%"=="--src-dir" goto parse_src
  if "%flag%"=="-n" goto parse_invoke
  if "%flag%"=="--invoke-main" goto parse_invoke
  if "%flag%"=="-r" goto parse_register
  if "%flag%"=="--register" goto parse_register
  if "%flag%"=="-i" goto parse_inline
  if "%flag%"=="--inline" goto parse_inline
  if "%flag%"=="-m" goto parse_modules
  if "%flag%"=="--modules" goto parse_modules
  if "%flag%"=="-e" goto parse_points
  if "%flag%"=="--entry-points" goto parse_points
  if "%flag%"=="-g" goto parse_group
  if "%flag%"=="--entry-group" goto parse_group
  if "%flag%"=="--" goto done_parse_flags
  echo invalid flag [%flag%] && goto fail_usage

  goto parse_flags

  :parse_config
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set config_js=%~1
    shift
  goto parse_flags

  :parse_output
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set output_dir=%~1
    shift
  goto parse_flags

  :parse_src
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set src_dir=%~1
    shift
  goto parse_flags

  :parse_invoke
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set invoke_main_flag=-n "%~1"
    shift
  goto parse_flags

  :parse_register
    set register_modules_flag=-r
  goto parse_flags

  :parse_inline
    set generate_inline=true
  goto parse_flags

  :parse_modules
    set generate_modules=true
  goto parse_flags

  :parse_points
    :point_loop
      set entry=%~1
      if "%entry%"=="" goto end_point_loop
      if "%entry:~0,1%"=="-" goto end_point_loop
      shift

      if not exist "%entry%" echo specified file for entry point not found [%entry%] && goto fail
      call :is_dir "%entry%"
      if %errorlevel%==0 echo specified file for entry point not found [%entry%] && goto fail

      set entry_point_%count_entry_point%=%entry%
      set /a count_entry_point=%count_entry_point% + 1
    goto point_loop
    :end_point_loop
  goto parse_flags

  :parse_group
    if "%~2"=="" echo %flag% requires two arguments to be specified && goto fail_usage
    set name=%~1
    shift

    echo.%name%| findstr /C:"/" >NUL 2>&1 && echo entry group name must not contain special characters >&2 && goto fail

    set entry_group_name_%count_entry_group_name%=%name%
    set /a count_entry_group_name=%count_entry_group_name% + 1

    set safe_name=%name:-=_%
    set /a count_entry_groups_%safe_name%=0

    :group_loop
      set file=%~1
      if "%file%"=="" goto end_group_loop
      if "%file:~0,1%"=="-" goto end_group_loop
      shift

      if not exist "%file%" echo specified file for entry group not found [%file%] && goto fail
      call :is_dir "%file%"
      if %errorlevel%==0 echo specified file for entry group not found [%file%] && goto fail

      set count=!count_entry_groups_%safe_name%!
      set entry_groups_%safe_name%_%count%=%file%
      set /a count_entry_groups_%safe_name%=%count% + 1
    goto group_loop
    :end_group_loop
  goto parse_flags

:done_parse_flags

if "%config_js%"=="" set config_js=config/bolt/prod.js
if "%output_dir%"=="" set output_dir=scratch/main/js
if "%src_dir%"=="" set src_dir=src/main/js
if "%generate_inline%"=="" set generate_inline=false
if "%generate_modules%"=="" set generate_modules=false

goto dispatch

:bolt_inline
  set target=%~1
  set name=%~2
  mkdir "%output_dir%/inline" 2> NUL
  call "%base%jsc.bat" inline -c "%config_js%" %invoke_main_flag% %register_modules_flag% "%target%" "%output_dir%/inline/%name%.js" || exit /b %errorlevel%
  exit /b 0

:bolt_point
  mkdir "%output_dir%/compile" 2>NUL

  set /a num=%count_entry_point% - 1
  for /L %%i in (0,1,%num%) do (
    rem iterate through the array
    set file=!entry_point_%%i!
    for /F "usebackq delims=" %%j in (`""%base%jsc" identify "!file!""`) do set name=%%j
    set target=!output_dir!\compile\!name!.js

    rem add to targets variable so things can be linked later
    set targets=!targets! "!target!"
    set /a count_targets=!count_targets! + 1

    call "!base!jsc.bat" compile -c "%config_js%" "!file!" "!target!" || exit /b !errorlevel!

    if "%generate_inline%"=="true" call :bolt_inline "!target!" "!name!"
  )
  exit /b 0

:bolt_group
  echo bolt_group unimplemented.
  exit /b 0

:bolt_link
  call "%base%jsc.bat" link -c "%config_js%" %targets% "%output_dir%/compile/bootstrap.js" || exit /b %errorlevel%
  exit /b 0

:bolt_modules
  mkdir "%output_dir%/module" 2>NUL
  set olddir=%CD%
  cd /D "%output_dir%/module"
  for /F "usebackq delims=" %%i in (`cd`) do set module_dir=%%i
  cd /D "%olddir%"
  cd /D "%src_dir%"
  for /F "usebackq delims=" %%m in (`glob **\*.js`) do (set module=%%m) && copy "%%m" "%module_dir%\!module:\=.!" >NUL
  cd /D "%olddir%"
  exit /b 0

:dispatch

if %count_entry_point% GTR 0 call :bolt_point || exit /b %errorlevel%
if %count_entry_group_name% GTR 0 call :bolt_group || exit /b %errorlevel%
if %count_targets% GTR 0 call :bolt_link || exit /b %errorlevel%
if "%generate_modules%"=="true" call :bolt_modules || exit /b %errorlevel%

exit /b 0

Implement bolt build linking

Implement bolt build linking


@echo off
rem --------------------------------------------------------------------
rem Release vims setting script in windows.
rem
rem Version: 0.0.0
rem Author: Shohei Mukai
rem Licence: MIT Licence
rem --------------------------------------------------------------------
rem :: Remain works::
rem     * Set http request command.
rem     * If not exist http command request, not moving some
rem       NeoBundle.
rem --------------------------------------------------------------------

rem Set variable data.
set CUR_DIR=%~dp0
set HOME_DIR=%HOMEPATH%
set TODAY=%date:~0,4%%date:~5,2%%date:~8,2%
set NOW=%TODAY%%time:~0,2%%time:~3,2%%time:~6,2%

rem Backup vim files.
set BACKUP_DIR=%HOME_DIR%.vim-backup
if not exist %BACKUP_DIR% (
  cd %HOME_DIR%
  mkdir .vim-backup
  cd %CUR_DIR%
)

rem Backup vimrc script.
if exist %HOME_DIR%\_vimrc (
  copy %HOME_DIR%\_vimrc %HOME_DIR%\.vim-backup\_vimrc%NOW%
)

rem Backup gvimrc script.
if exist %HOME_DIR%\_vimrc (
  copy %HOME_DIR%\_gvimrc %HOME_DIR%\.vim-backup\_gvimrc%NOW%
)

rem Copy vimrc.
copy %CUR_DIR%vimrc %HOME_DIR%\_vimrc

rem Copy gvimrc.
copy %CUR_DIR%gvimrc %HOME_DIR%\_gvimrc

rem Copy vimrc command list (if you need).
set /P IS_COPY="Copy command default? [Y]: "
if "%IS_COPY%"=="Y" (
  copy %CUR_DIR%vimrc.command %HOME_DIR%\.vimrc.command
)

rem Copy vimrc.cnf(need confirm).
set /P IS_COPY="Copy cnf? [Y]: "
echo %IS_COPY%
if "%IS_COPY%"=="Y" (
  copy %CUR_DIR%vimrc.cnf %HOME_DIR%\.vimrc.cnf
)

@echo off
rem --------------------------------------------------------------------
rem Release vims setting script in windows.
rem
rem Version: 0.0.0
rem Author: Shohei Mukai
rem Licence: MIT Licence
rem --------------------------------------------------------------------
rem :: Remain works::
rem     * Set http request command.
rem     * If not exist http command request, not moving some
rem       NeoBundle.
rem --------------------------------------------------------------------

rem Set variable data.
set CUR_DIR=%~dp0
set HOME_DIR=%HOMEPATH%
set TODAY=%date:~0,4%%date:~5,2%%date:~8,2%
set NOW=%TODAY%%time:~0,2%%time:~3,2%%time:~6,2%

rem Backup vim files.
set BACKUP_DIR=%HOME_DIR%.vim-backup
if not exist %BACKUP_DIR% (
  cd %HOME_DIR%
  mkdir .vim-backup
  cd %CUR_DIR%
)

rem Backup vimrc script.
if exist %HOME_DIR%\.vimrc (
  copy %HOME_DIR%\.vimrc %HOME_DIR%\.vim-backup\.vimrc%NOW%
)

rem Backup gvimrc script.
if exist %HOME_DIR%\.vimrc (
  copy %HOME_DIR%\.gvimrc %HOME_DIR%\.vim-backup\.gvimrc%NOW%
)

rem Copy vimrc.
copy %CUR_DIR%vimrc %HOME_DIR%\.vimrc

rem Copy gvimrc.
copy %CUR_DIR%gvimrc %HOME_DIR%\.gvimrc

rem Copy vimrc command list (if you need).
set /P IS_COPY="Copy command default? [Y]: "
if "%IS_COPY%"=="Y" (
  copy %CUR_DIR%vimrc.command %HOME_DIR%\.vimrc.command
)

rem Copy vimrc.cnf(need confirm).
set /P IS_COPY="Copy cnf? [Y]: "
echo %IS_COPY%
if "%IS_COPY%"=="Y" (
  copy %CUR_DIR%vimrc.cnf %HOME_DIR%\.vimrc.cnf
)

Fix to use "." format on windows

Fix to use "." format on windows