:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
:: All rights reserved.
:: Contact: Nokia Corporation (qt-info@nokia.com)
::
:: This file is part of the Qt Mobility Components.
::
:: $QT_BEGIN_LICENSE:LGPL$
:: No Commercial Usage
:: This file contains pre-release code and may not be distributed.
:: You may use this file in accordance with the terms and conditions
:: contained in the Technology Preview License Agreement accompanying
:: this package.
::
:: GNU Lesser General Public License Usage
:: Alternatively, this file may be used under the terms of the GNU Lesser
:: General Public License version 2.1 as published by the Free Software
:: Foundation and appearing in the file LICENSE.LGPL included in the
:: packaging of this file.  Please review the following information to
:: ensure the GNU Lesser General Public License version 2.1 requirements
:: will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
::
:: In addition, as a special exception, Nokia gives you certain additional
:: rights.  These rights are described in the Nokia Qt LGPL Exception
:: version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
::
:: If you have questions regarding the use of this file, please contact
:: Nokia at qt-info@nokia.com.
::
::
::
::
::
::
::
::
:: $QT_END_LICENSE$
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off

set QT_MOBILITY_PREFIX= C:\QtMobility
set BUILD_PATH=%CD%
set SOURCE_PATH= %~dp0
cd /D %SOURCE_PATH%
set SOURCE_PATH=%CD%
cd /D %BUILD_PATH%

set PROJECT_CONFIG= %BUILD_PATH%\config.in
set PROJECT_LOG= %BUILD_PATH%\config.log
set RELEASEMODE=release
set QT_MOBILITY_LIB=
set BUILD_UNITTESTS=no
set BUILD_EXAMPLES=no
set CONTACTS_PLUGIN=
set VC_TEMPLATE_OPTION=
set QT_PATH=
set QMAKE_CACHE=%BUILD_PATH%\.qmake.cache

if exist "%QMAKE_CACHE%" del %QMAKE_CACHE%
if exist "%PROJECT_LOG%" del %PROJECT_LOG%
if exist "%PROJECT_CONFIG%" del %PROJECT_CONFIG%

echo QT_MOBILITY_SOURCE_TREE = %SOURCE_PATH% > %QMAKE_CACHE%
echo QT_MOBILITY_BUILD_TREE = %BUILD_PATH% >> %QMAKE_CACHE%

:cmdline_parsing

if "%1" == ""               goto startProcessing
if "%1" == "-debug"         goto debugTag
if "%1" == "-release"       goto releaseTag
if "%1" == "-silent"        goto silentTag
if "%1" == "-prefix"        goto prefixTag
if "%1" == "-libdir"        goto libTag
if "%1" == "-bindir"        goto binTag
if "%1" == "-headerdir"     goto headerTag
if "%1" == "-tests"         goto testTag
if "%1" == "-examples"      goto exampleTag
if "%1" == "-contact-src"   goto contactsTag
if "%1" == "-qt"            goto qtTag
if "%1" == "-vc"            goto vcTag
if "%1" == "/?"             goto usage
if "%1" == "-h"             goto usage
if "%1" == "-help"          goto usage
if "%1" == "--help"         goto usage

echo Unknown option: "%1"
goto usage

:usage
echo Usage: configure.bat [-prefix (dir)] [headerdir (dir)] [libdir (dir)]
    echo                  [-bindir (dir)] [-tests] [-examples]
    echo                  [-debug] [-release] [-silent]
    echo.
    echo Options:
    echo.
    echo -prefix (dir) ..... This will install everything relative to dir
    echo                     (default prefix: C:\QtMobility)
    echo -headerdir (dir) .. Header files will be installed to dir
    echo                     (default prefix: PREFIX/include)
    echo -libdir (dir) ..... Libraries will be installed to dir
    echo                     (default PREFIX/lib)
    echo -bindir (dir) ..... Executables will be installed to dir
    echo                     (default PREFIX/bin)
    echo -debug ............ Build with debugging symbols
    echo -release .......... Build without debugging symbols
    echo -silent ........... Reduces build output
    echo -tests ............ Build unit tests (not build by default)
    echo                     Note, this adds test symbols to all libraries
    echo                     and should not be used for release builds.
    echo -examples ......... Build example applications
    echo -vc ............... Generate Visual Studio make files
    echo -contact-src (backend) ...
    echo                     Compile the specified contacts API backend. Not selecting any backend
    echo                     will result in default selection for build platform
    echo                     options: symbian, wince, memory, maemo

if exist "%PROJECT_CONFIG%" del %PROJECT_CONFIG%
goto exitTag

:qtTag
shift
set QT_PATH=%1\
shift
goto cmdline_parsing

:contactsTag
shift
set CONTACTS_PLUGIN=%CONTACTS_PLUGIN% %1
shift
goto cmdline_parsing

:debugTag
if "%RELEASEMODE%" == "release" set RELEASEMODE=debug
shift
goto cmdline_parsing

:releaseTag
if "%RELEASEMODE%" == "debug"   set RELEASEMODE=release
shift
goto cmdline_parsing

:silentTag
echo CONFIG += silent > %PROJECT_CONFIG%
shift
goto cmdline_parsing

:prefixTag
shift
set QT_MOBILITY_PREFIX=%1
shift
goto cmdline_parsing

:libTag
shift
echo QT_MOBILITY_LIB = %1 >> %PROJECT_CONFIG%
shift
goto cmdline_parsing

:binTag
shift
echo QT_MOBILITY_BIN = %1 >> %PROJECT_CONFIG%
shift
goto cmdline_parsing

:headerTag
shift
echo QT_MOBILITY_INCLUDE = %1 >> %PROJECT_CONFIG%
shift
goto cmdline_parsing

:testTag
set BUILD_UNITTESTS=yes
shift
goto cmdline_parsing

:exampleTag
set BUILD_EXAMPLES=yes
shift
goto cmdline_parsing

:vcTag
shift
set VC_TEMPLATE_OPTION=-tp vc
goto cmdline_parsing

:startProcessing

copy %PROJECT_CONFIG% %BUILD_PATH%\config.pri
del %PROJECT_CONFIG%

echo CONFIG += %RELEASEMODE% >> %PROJECT_CONFIG%
echo CONTACTS_BACKENDS = %CONTACTS_PLUGIN% >> %PROJECT_CONFIG%

set CURRENTDIR=%CD%
echo %CURRENTDIR%
if exist %QT_MOBILITY_PREFIX% goto prefixExists
mkdir %QT_MOBILITY_PREFIX%
if errorlevel 1 goto invalidPrefix
cd /D %QT_MOBILITY_PREFIX%
set QT_MOBILITY_PREFIX=%CD%
cd /D %CURRENTDIR%
rd /S /Q %QT_MOBILITY_PREFIX%
goto endprefixProcessing

:invalidPrefix
echo "%QT_MOBILITY_PREFIX%" is not a valid directory path.
goto :exitTag

:prefixExists
cd /D %QT_MOBILITY_PREFIX%
set QT_MOBILITY_PREFIX=%CD%
cd /D %CURRENTDIR%

:endprefixProcessing
echo QT_MOBILITY_PREFIX = %QT_MOBILITY_PREFIX% >> %PROJECT_CONFIG%

echo build_unit_tests = %BUILD_UNITTESTS% >> %PROJECT_CONFIG%
echo build_examples = %BUILD_EXAMPLES% >> %PROJECT_CONFIG%
echo qmf_enabled = no >> %PROJECT_CONFIG%

echo isEmpty($$QT_MOBILITY_INCLUDE):QT_MOBILITY_INCLUDE=$$QT_MOBILITY_PREFIX/include >> %PROJECT_CONFIG%
echo isEmpty($$QT_MOBILITY_LIB):QT_MOBILITY_LIB=$$QT_MOBILITY_PREFIX/lib >> %PROJECT_CONFIG%
echo isEmpty($$QT_MOBILITY_BIN):QT_MOBILITY_BIN=$$QT_MOBILITY_PREFIX/bin >> %PROJECT_CONFIG%

echo Checking available Qt
%QT_PATH%qmake -v >> %PROJECT_LOG% 2>&1
if errorlevel 1 goto qmakeNotFound
goto qmakeFound
:qmakeNotFound
echo ... Not found  >> %PROJECT_LOG% 2>&1
if "%QT_PATH%" == "" (
    echo >&2 "Cannot find 'qmake' in your PATH."
) else (
    else echo >&2 "Cannot find 'qmake' in %QT_PATH%."
)
echo >&2 "Aborting."
exit 1

:qmakeFound
%QT_PATH%qmake -query QT_VERSION

goto checkMake

:makeTest
setlocal
    set CURRENT_PWD=%CD%

    if %BUILD_PATH% == %SOURCE_PATH% (
        cd %SOURCE_PATH%\config.tests\make
        if exist make del make
    ) else (
        rmdir /S /Q config.tests\make
        mkdir config.tests\make
        cd config.tests\make
    )

    for /f "tokens=3" %%i in ('%QT_PATH%qmake %SOURCE_PATH%\config.tests\make\make.pro 2^>^&1 1^>NUL') do set MAKETYPE=%%i

    if %MAKETYPE% == symbian-abld (
        make -h >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... Symbian abld make found.
            set MAKE=make
        )
    ) else if %MAKETYPE% == symbian-sbsv2 (
        make -h >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... Symbian sbsv2 make found.
            set MAKE=make
        )
    ) else if %MAKETYPE% == win32-nmake (
        nmake /? >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... nmake found.
            set MAKE=nmake
        )
    ) else if %MAKETYPE% == win32-mingw (
        mingw32-make -v >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... mingw32-make found.
            set MAKE=mingw32-make
        )
    ) else (
        echo ... Unknown target environment %MAKETYPE%.
    )
    cd %CURRENT_PWD%
endlocal&set %1=%MAKE%&set %2=%MAKETYPE%&goto :EOF

:checkMake
echo Checking make
call :makeTest MAKE MAKETYPE
if not "%MAKE%" == "" goto compileTests

echo >&2 "Cannot find 'nmake', 'mingw32-make' or 'make' in your PATH"
echo >&2 "Aborting."
exit 1

:compileTest
setlocal
    echo Checking %1
    set CURRENT_PWD=%CD%

    if %BUILD_PATH% == %SOURCE_PATH% (
        cd %SOURCE_PATH%\config.tests\%2
        if exist %2 del %2
    ) else (
        rmdir /S /Q config.tests\%2
        mkdir config.tests\%2
        cd config.tests\%2
    )

    %QT_PATH%qmake %SOURCE_PATH%\config.tests\%2\%2.pro >> %PROJECT_LOG% 2>&1
    %MAKE% clean >> %PROJECT_LOG%
    %MAKE% >> %PROJECT_LOG% 2>&1

    set FAILED=0
    if %MAKETYPE% == symbian-sbsv2 (
        for /f "tokens=2" %%i in ('%MAKE% SBS^="@sbs --check"') do set FAILED=1
    ) else if %MAKETYPE% == symbian-abld (
        for /f "tokens=2" %%i in ('%MAKE% ABLD^="@ABLD.BAT -c"') do set FAILED=1
    ) else if errorlevel 1 (
        set FAILED=1
    )

    if %FAILED% == 0 (
        echo ... OK
        echo %2_enabled = yes >> %PROJECT_CONFIG%
    ) else (
        echo ... Not Found
        echo %2_enabled = no >> %PROJECT_CONFIG%
    )

    cd %CURRENT_PWD%
endlocal&goto :EOF

:compileTests

echo.
echo Start of compile tests
REM compile tests go here.
call :compileTest LBT lbt
echo End of compile tests

if not exist "%BUILD_PATH%\features" mkdir %BUILD_PATH%\features
echo "Generating Mobility Headers..."
rd /s /q %BUILD_PATH%\include
mkdir %BUILD_PATH%\include
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\global
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\bearer
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\publishsubscribe
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\location
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\serviceframework
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\systeminfo
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\contacts
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\multimedia
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\messaging

if exist config.pri del config.pri
ren %PROJECT_CONFIG% config.pri

echo.
echo Running qmake...
%QT_PATH%qmake -recursive %VC_TEMPLATE_OPTION% %SOURCE_PATH%\qtmobility.pro
if errorlevel 1 goto qmakeRecError
echo.
echo configure has finished. You may run %MAKE% to build the project now.
goto exitTag

:qmakeRecError
echo.
echo configure failed.
exit 1

:exitTag

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
:: All rights reserved.
:: Contact: Nokia Corporation (qt-info@nokia.com)
::
:: This file is part of the Qt Mobility Components.
::
:: $QT_BEGIN_LICENSE:LGPL$
:: No Commercial Usage
:: This file contains pre-release code and may not be distributed.
:: You may use this file in accordance with the terms and conditions
:: contained in the Technology Preview License Agreement accompanying
:: this package.
::
:: GNU Lesser General Public License Usage
:: Alternatively, this file may be used under the terms of the GNU Lesser
:: General Public License version 2.1 as published by the Free Software
:: Foundation and appearing in the file LICENSE.LGPL included in the
:: packaging of this file.  Please review the following information to
:: ensure the GNU Lesser General Public License version 2.1 requirements
:: will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
::
:: In addition, as a special exception, Nokia gives you certain additional
:: rights.  These rights are described in the Nokia Qt LGPL Exception
:: version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
::
:: If you have questions regarding the use of this file, please contact
:: Nokia at qt-info@nokia.com.
::
::
::
::
::
::
::
::
:: $QT_END_LICENSE$
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off

set QT_MOBILITY_PREFIX= C:\QtMobility
set BUILD_PATH=%CD%
set SOURCE_PATH= %~dp0
cd /D %SOURCE_PATH%
set SOURCE_PATH=%CD%
cd /D %BUILD_PATH%

set PROJECT_CONFIG= %BUILD_PATH%\config.in
set PROJECT_LOG= %BUILD_PATH%\config.log
set RELEASEMODE=release
set QT_MOBILITY_LIB=
set BUILD_UNITTESTS=no
set BUILD_EXAMPLES=no
set CONTACTS_PLUGIN=
set VC_TEMPLATE_OPTION=
set QT_PATH=
set QMAKE_CACHE=%BUILD_PATH%\.qmake.cache

if exist "%QMAKE_CACHE%" del %QMAKE_CACHE%
if exist "%PROJECT_LOG%" del %PROJECT_LOG%
if exist "%PROJECT_CONFIG%" del %PROJECT_CONFIG%

echo QT_MOBILITY_SOURCE_TREE = %SOURCE_PATH% > %QMAKE_CACHE%
echo QT_MOBILITY_BUILD_TREE = %BUILD_PATH% >> %QMAKE_CACHE%
set QMAKE_CACHE=

:cmdline_parsing

if "%1" == ""               goto startProcessing
if "%1" == "-debug"         goto debugTag
if "%1" == "-release"       goto releaseTag
if "%1" == "-silent"        goto silentTag
if "%1" == "-prefix"        goto prefixTag
if "%1" == "-libdir"        goto libTag
if "%1" == "-bindir"        goto binTag
if "%1" == "-headerdir"     goto headerTag
if "%1" == "-tests"         goto testTag
if "%1" == "-examples"      goto exampleTag
if "%1" == "-contact-src"   goto contactsTag
if "%1" == "-qt"            goto qtTag
if "%1" == "-vc"            goto vcTag
if "%1" == "/?"             goto usage
if "%1" == "-h"             goto usage
if "%1" == "-help"          goto usage
if "%1" == "--help"         goto usage

echo Unknown option: "%1"
goto usage

:usage
echo Usage: configure.bat [-prefix (dir)] [headerdir (dir)] [libdir (dir)]
    echo                  [-bindir (dir)] [-tests] [-examples]
    echo                  [-debug] [-release] [-silent]
    echo.
    echo Options:
    echo.
    echo -prefix (dir) ..... This will install everything relative to dir
    echo                     (default prefix: C:\QtMobility)
    echo -headerdir (dir) .. Header files will be installed to dir
    echo                     (default prefix: PREFIX/include)
    echo -libdir (dir) ..... Libraries will be installed to dir
    echo                     (default PREFIX/lib)
    echo -bindir (dir) ..... Executables will be installed to dir
    echo                     (default PREFIX/bin)
    echo -debug ............ Build with debugging symbols
    echo -release .......... Build without debugging symbols
    echo -silent ........... Reduces build output
    echo -tests ............ Build unit tests (not build by default)
    echo                     Note, this adds test symbols to all libraries
    echo                     and should not be used for release builds.
    echo -examples ......... Build example applications
    echo -vc ............... Generate Visual Studio make files
    echo -contact-src (backend) ...
    echo                     Compile the specified contacts API backend. Not selecting any backend
    echo                     will result in default selection for build platform
    echo                     options: symbian, wince, memory, maemo

if exist "%PROJECT_CONFIG%" del %PROJECT_CONFIG%
goto exitTag

:qtTag
shift
set QT_PATH=%1\
shift
goto cmdline_parsing

:contactsTag
shift
set CONTACTS_PLUGIN=%CONTACTS_PLUGIN% %1
shift
goto cmdline_parsing

:debugTag
if "%RELEASEMODE%" == "release" set RELEASEMODE=debug
shift
goto cmdline_parsing

:releaseTag
if "%RELEASEMODE%" == "debug"   set RELEASEMODE=release
shift
goto cmdline_parsing

:silentTag
echo CONFIG += silent > %PROJECT_CONFIG%
shift
goto cmdline_parsing

:prefixTag
shift
set QT_MOBILITY_PREFIX=%1
shift
goto cmdline_parsing

:libTag
shift
echo QT_MOBILITY_LIB = %1 >> %PROJECT_CONFIG%
shift
goto cmdline_parsing

:binTag
shift
echo QT_MOBILITY_BIN = %1 >> %PROJECT_CONFIG%
shift
goto cmdline_parsing

:headerTag
shift
echo QT_MOBILITY_INCLUDE = %1 >> %PROJECT_CONFIG%
shift
goto cmdline_parsing

:testTag
set BUILD_UNITTESTS=yes
shift
goto cmdline_parsing

:exampleTag
set BUILD_EXAMPLES=yes
shift
goto cmdline_parsing

:vcTag
shift
set VC_TEMPLATE_OPTION=-tp vc
goto cmdline_parsing

:startProcessing

copy %PROJECT_CONFIG% %BUILD_PATH%\config.pri
del %PROJECT_CONFIG%

echo CONFIG += %RELEASEMODE% >> %PROJECT_CONFIG%
set RELEASEMODE=

echo CONTACTS_BACKENDS = %CONTACTS_PLUGIN% >> %PROJECT_CONFIG%

set CURRENTDIR=%CD%
echo %CURRENTDIR%
if exist %QT_MOBILITY_PREFIX% goto prefixExists
mkdir %QT_MOBILITY_PREFIX%
if errorlevel 1 goto invalidPrefix
cd /D %QT_MOBILITY_PREFIX%
set QT_MOBILITY_PREFIX=%CD%
cd /D %CURRENTDIR%
rd /S /Q %QT_MOBILITY_PREFIX%
goto endprefixProcessing

:invalidPrefix
echo "%QT_MOBILITY_PREFIX%" is not a valid directory path.
goto :exitTag

:prefixExists
cd /D %QT_MOBILITY_PREFIX%
set QT_MOBILITY_PREFIX=%CD%
cd /D %CURRENTDIR%

:endprefixProcessing
echo QT_MOBILITY_PREFIX = %QT_MOBILITY_PREFIX% >> %PROJECT_CONFIG%

echo build_unit_tests = %BUILD_UNITTESTS% >> %PROJECT_CONFIG%
set BUILD_UNITTESTS=

echo build_examples = %BUILD_EXAMPLES% >> %PROJECT_CONFIG%
set BUILD_EXAMPLES=

echo qmf_enabled = no >> %PROJECT_CONFIG%

echo isEmpty($$QT_MOBILITY_INCLUDE):QT_MOBILITY_INCLUDE=$$QT_MOBILITY_PREFIX/include >> %PROJECT_CONFIG%
echo isEmpty($$QT_MOBILITY_LIB):QT_MOBILITY_LIB=$$QT_MOBILITY_PREFIX/lib >> %PROJECT_CONFIG%
echo isEmpty($$QT_MOBILITY_BIN):QT_MOBILITY_BIN=$$QT_MOBILITY_PREFIX/bin >> %PROJECT_CONFIG%

echo Checking available Qt
%QT_PATH%qmake -v >> %PROJECT_LOG% 2>&1
if errorlevel 1 goto qmakeNotFound
goto qmakeFound
:qmakeNotFound
echo ... Not found  >> %PROJECT_LOG% 2>&1
if "%QT_PATH%" == "" (
    echo >&2 "Cannot find 'qmake' in your PATH."
) else (
    else echo >&2 "Cannot find 'qmake' in %QT_PATH%."
)
echo >&2 "Aborting."
goto errorTag

:qmakeFound
%QT_PATH%qmake -query QT_VERSION

goto checkMake

:makeTest
setlocal
    set CURRENT_PWD=%CD%

    if %BUILD_PATH% == %SOURCE_PATH% (
        cd %SOURCE_PATH%\config.tests\make
        if exist make del make
    ) else (
        rmdir /S /Q config.tests\make
        mkdir config.tests\make
        cd config.tests\make
    )

    for /f "tokens=3" %%i in ('%QT_PATH%qmake %SOURCE_PATH%\config.tests\make\make.pro 2^>^&1 1^>NUL') do set BUILDSYSTEM=%%i

    if %BUILDSYSTEM% == symbian-abld (
        make -h >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... Symbian abld make found.
            set MAKE=make
        )
    ) else if %BUILDSYSTEM% == symbian-sbsv2 (
        make -h >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... Symbian sbsv2 make found.
            set MAKE=make
        )
    ) else if %BUILDSYSTEM% == win32-nmake (
        nmake /? >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... nmake found.
            set MAKE=nmake
        )
    ) else if %BUILDSYSTEM% == win32-mingw (
        mingw32-make -v >> %PROJECT_LOG% 2>&1
        if not errorlevel 1 (
            echo ... mingw32-make found.
            set MAKE=mingw32-make
        )
    ) else (
        echo ... Unknown target environment %BUILDSYSTEM%.
    )
    cd %CURRENT_PWD%
endlocal&set %1=%MAKE%&set %2=%BUILDSYSTEM%&goto :EOF

:checkMake
echo Checking make
call :makeTest MOBILITY_MAKE MOBILITY_BUILDSYSTEM
if not "%MOBILITY_MAKE%" == "" goto compileTests

echo >&2 "Cannot find 'nmake', 'mingw32-make' or 'make' in your PATH"
echo >&2 "Aborting."
goto errorTag

:compileTest
setlocal
    echo Checking %1
    set CURRENT_PWD=%CD%

    if %BUILD_PATH% == %SOURCE_PATH% (
        cd %SOURCE_PATH%\config.tests\%2
        if exist %2 del %2
    ) else (
        rmdir /S /Q config.tests\%2
        mkdir config.tests\%2
        cd config.tests\%2
    )

    %QT_PATH%qmake %SOURCE_PATH%\config.tests\%2\%2.pro >> %PROJECT_LOG% 2>&1
    %MOBILITY_MAKE% clean >> %PROJECT_LOG%
    set > compile-test.env 2>&1
    %MOBILITY_MAKE% >> %PROJECT_LOG% 2>&1

    set FAILED=0
    if %MOBILITY_BUILDSYSTEM% == symbian-sbsv2 (
        for /f "tokens=2" %%i in ('%MOBILITY_MAKE% SBS^="@sbs --check"') do set FAILED=1
    ) else if %MOBILITY_BUILDSYSTEM% == symbian-abld (
        for /f "tokens=2" %%i in ('%MOBILITY_MAKE% ABLD^="@ABLD.BAT -c"') do set FAILED=1
    ) else if errorlevel 1 (
        set FAILED=1
    )

    if %FAILED% == 0 (
        echo ... OK
        echo %2_enabled = yes >> %PROJECT_CONFIG%
    ) else (
        echo ... Not Found
        echo %2_enabled = no >> %PROJECT_CONFIG%
    )

    cd %CURRENT_PWD%
endlocal&goto :EOF

:compileTests

echo.
echo Start of compile tests
REM compile tests go here.
call :compileTest LBT lbt
echo End of compile tests

if not exist "%BUILD_PATH%\features" mkdir %BUILD_PATH%\features
echo "Generating Mobility Headers..."
rd /s /q %BUILD_PATH%\include
mkdir %BUILD_PATH%\include
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\global
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\bearer
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\publishsubscribe
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\location
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\serviceframework
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\systeminfo
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\contacts
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\multimedia
perl -S %SOURCE_PATH%\bin\syncheaders %BUILD_PATH%\include %SOURCE_PATH%\src\messaging

if exist config.pri del config.pri
ren %PROJECT_CONFIG% config.pri

echo.
echo Running qmake...
%QT_PATH%qmake -recursive %VC_TEMPLATE_OPTION% %SOURCE_PATH%\qtmobility.pro
if errorlevel 1 goto qmakeRecError
echo.
echo configure has finished. You may run %MOBILITY_MAKE% to build the project now.
goto exitTag

:qmakeRecError
echo.
echo configure failed.
goto exitTag

:errorTag
set BUILD_PATH=
set CURRENTDIR=
set MOBILITY_MAKE=
set MOBILITY_BUILDSYSTEM=
set PROJECT_CONFIG=
set PROJECT_LOG=
set QT_MOBILITY_PREFIX=
set QT_PATH=
set SOURCE_PATH=
exit /b 1

:exitTag
set BUILD_PATH=
set CURRENTDIR=
set MOBILITY_MAKE=
set MOBILITY_BUILDSYSTEM=
set PROJECT_CONFIG=
set PROJECT_LOG=
set QT_MOBILITY_PREFIX=
set QT_PATH=
set SOURCE_PATH=

Fix configure.bat.

Fix configure.bat.

Exit on error correctly.
Don't pollute environment after script finishes.


@echo OFF
@setlocal

set VERSION=1.32.0
set TFDIR=C:\TreeFrog\%VERSION%
set MONBOC_VERSION=1.9.5
set LZ4_VERSION=1.9.3
set BASEDIR=%~dp0

:parse_loop
if "%1" == "" goto :start
if /i "%1" == "--prefix" goto :prefix
if /i "%1" == "--enable-debug" goto :enable_debug
if /i "%1" == "--enable-gui-mod" goto :enable_gui_mod
if /i "%1" == "--help" goto :help
if /i "%1" == "-h" goto :help
goto :help
:continue
shift
goto :parse_loop

:help
  echo Usage: %0 [OPTION]... [VAR=VALUE]...
  echo;
  echo Configuration:
  echo   -h, --help          display this help and exit
  echo   --enable-debug      compile with debugging information
  echo   --enable-gui-mod    compile and link with QtGui module
  echo;
  echo Installation directories:
  echo   --prefix=PREFIX     install files in PREFIX [%TFDIR%]
  goto :exit

:prefix
  shift
  if "%1" == "" goto :help
  set TFDIR=%1
  goto :continue

:enable_debug
  set DEBUG=yes
  goto :continue

:enable_gui_mod
  set USE_GUI=use_gui=1
  goto :continue

:start
if "%DEBUG%" == "yes" (
  set OPT="CONFIG+=debug"
) else (
  set OPT="CONFIG+=release"
)

::
:: Generates tfenv.bat
::
for %%I in (qmake.exe)  do if exist %%~$path:I set QMAKE=%%~$path:I
for %%I in (cmake.exe)  do if exist %%~$path:I set CMAKE=%%~$path:I
for %%I in (cl.exe)     do if exist %%~$path:I set MSCOMPILER=%%~$path:I
for %%I in (devenv.exe) do if exist %%~$path:I set DEVENV=%%~$path:I

if "%QMAKE%" == "" (
  echo Qt environment not found
  exit /b
)
if "%CMAKE%" == "" (
  echo CMake not found
  exit /b
)
if "%MSCOMPILER%" == "" if "%DEVENV%"  == "" (
  echo MSVC Compiler not found
  exit /b
)

:: get qt install prefix
for /f usebackq %%I in (`qtpaths.exe --install-prefix`) do (
  set QT_INSTALL_PREFIX=%%I
  goto :break
)
:break

:: vcvarsall.bat setup
set MAKE=nmake
if /i "%Platform%" == "x64" (
  set VCVARSOPT=amd64
  set BUILDTARGET=x64
  set ENVSTR=Environment to build for 64-bit executable  MSVC / Qt
) else (
  set VCVARSOPT=x86
  set BUILDTARGET=win32
  set ENVSTR=Environment to build for 32-bit executable  MSVC / Qt
)

echo %QT_INSTALL_PREFIX% | find "msvc2019" >NUL
if not ERRORLEVEL 1 (
  set VSVER=2019
  if /i "%Platform%" == "x64" (
    set CMAKEOPT=Visual Studio 16 2019
  ) else (
    set CMAKEOPT=Visual Studio 16 2019
  )
) else (
  echo %QT_INSTALL_PREFIX% | find "msvc2017" >NUL
  if not ERRORLEVEL 1 (
    set VSVER=2017
    if /i "%Platform%" == "x64" (
      set CMAKEOPT=Visual Studio 15 2017 Win64
    ) else (
      set CMAKEOPT=Visual Studio 15 2017
    )
  ) else (
    set VSVER=2015
    if /i "%Platform%" == "x64" (
      set CMAKEOPT=Visual Studio 14 2015 Win64
    ) else (
      set CMAKEOPT=Visual Studio 14 2015
    )
  )
)

SET /P X="%ENVSTR%"<NUL
qtpaths.exe --qt-version

for %%I in (qtenv2.bat) do if exist %%~$path:I set QTENV=%%~$path:I
set TFENV=tfenv.bat
echo @echo OFF> %TFENV%
echo ::>> %TFENV%
echo :: This file is generated by configure.bat>> %TFENV%
echo ::>> %TFENV%
echo;>> %TFENV%
echo set TFDIR=%TFDIR%>> %TFENV%
echo set TreeFrog_DIR=%TFDIR%>> %TFENV%
echo set QTENV="%QTENV%">> %TFENV%
echo set QMAKESPEC=%QMAKESPEC%>> %TFENV%
echo set VCVARSBAT="">> %TFENV%
echo set VSVER=%VSVER%>> %TFENV%
echo set VSWHERE="%%ProgramFiles(x86)%%\Microsoft Visual Studio\Installer\vswhere.exe">> %TFENV%
echo;>> %TFENV%
echo if exist %%QTENV%% call %%QTENV%%>> %TFENV%
echo if exist %%VSWHERE%% ^(>> %TFENV%
echo   for /f "usebackq tokens=*" %%%%i in ^(`%%VSWHERE%% -find  **\vcvarsall.bat`^) do ^(>> %TFENV%
echo     echo %%%%i ^| find "%%VSVER%%" ^>NUL>> %TFENV%
echo     if not ERRORLEVEL 1 ^(>> %TFENV%
echo       set VCVARSBAT="%%%%i">> %TFENV%
echo       goto :break>> %TFENV%
echo     ^)>> %TFENV%
echo   ^)>> %TFENV%
echo ^)>> %TFENV%
echo :break>> %TFENV%
echo if exist %%VCVARSBAT%% ^(>> %TFENV%
echo   echo Setting up environment for MSVC usage...>> %TFENV%
echo   call %%VCVARSBAT%% %VCVARSOPT%>> %TFENV%
echo ^)>> %TFENV%
echo set PATH=%%TFDIR^%%\bin;%%PATH%%>> %TFENV%
echo echo Setup a TreeFrog/Qt environment.>> %TFENV%
echo echo -- TFDIR set to %%TFDIR%%>> %TFENV%
echo cd /D %%HOMEDRIVE%%%%HOMEPATH%%>> %TFENV%

set TFDIR=%TFDIR:\=/%
del /f /q .qmake.stash src\.qmake.stash tools\.qmake.stash >nul 2>&1

:: Builds MongoDB driver
cd /d %BASEDIR%3rdparty
rd /s /q  mongo-driver >nul 2>&1
del /f /q mongo-driver >nul 2>&1
mklink /j mongo-driver mongo-c-driver-%MONBOC_VERSION% >nul 2>&1

cd %BASEDIR%3rdparty\mongo-driver\src\libbson
del /f /q CMakeCache.txt cmake_install.cmake CMakeFiles Makefile >nul 2>&1
cmake -G"%CMAKEOPT%" -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_TESTS=OFF .
echo Compiling BSON library ...
devenv libbson.sln /project bson_static /rebuild Release >nul 2>&1
if ERRORLEVEL 1 (
  :: Shows error
  devenv libbson.sln /project bson_static /build Release
  echo;
  echo Build failed.
  echo MongoDB driver not available.
  exit /b
)

cd %BASEDIR%3rdparty\mongo-driver
del /f /q CMakeCache.txt cmake_install.cmake CMakeFiles Makefile >nul 2>&1
echo cmake -G"%CMAKEOPT%" -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_SSL=OFF -DENABLE_SNAPPY=OFF -DENABLE_SRV=OFF -DENABLE_SASL=OFF -DENABLE_ZLIB=OFF -DENABLE_TESTS=OFF .
cmake -G"%CMAKEOPT%" -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_SSL=OFF -DENABLE_SNAPPY=OFF -DENABLE_SRV=OFF -DENABLE_SASL=OFF -DENABLE_ZLIB=OFF -DENABLE_TESTS=OFF .
echo Compiling MongoDB driver library ...
devenv libmongoc.sln /project mongoc_static /rebuild Release >nul 2>&1
if ERRORLEVEL 1 (
  :: Shows error
  devenv libmongoc.sln /project mongoc_static /build Release
  echo;
  echo Build failed.
  echo MongoDB driver not available.
  exit /b
)

:: Builds LZ4
cd %BASEDIR%3rdparty
echo Compiling LZ4 library ...
rd /s /q  lz4 >nul 2>&1
del /f /q lz4 >nul 2>&1
mklink /j lz4 lz4-%LZ4_VERSION% >nul 2>&1
for /F %%i in ('qtpaths.exe --install-prefix') do echo %%i | find "msvc2015" >NUL
if not ERRORLEVEL 1 (
  set VS=VS2015
) else (
  set VS=VS2017
)
devenv lz4\build\%VS%\lz4.sln /project liblz4 /rebuild "Release|%BUILDTARGET%" >nul 2>&1
if ERRORLEVEL 1 (
  :: Shows error
  devenv lz4\build\%VS%\lz4.sln /project liblz4 /build "Release|%BUILDTARGET%"
  echo;
  echo Build failed.
  echo LZ4 not available.
  exit /b
)

cd %BASEDIR%src
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' %USE_GUI%

cd %BASEDIR%tools
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake -recursive %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' datadir='%TFDIR%'
%MAKE% qmake

echo;
echo First, run "%MAKE% install" in src directory.
echo Next, run "%MAKE% install" in tools directory.

:exit
exit /b

@echo OFF
@setlocal

set VERSION=1.32.0
set TFDIR=C:\TreeFrog\%VERSION%
set MONBOC_VERSION=1.9.5
set LZ4_VERSION=1.9.3
set BASEDIR=%~dp0

:parse_loop
if "%1" == "" goto :start
if /i "%1" == "--prefix" goto :prefix
if /i "%1" == "--enable-debug" goto :enable_debug
if /i "%1" == "--enable-gui-mod" goto :enable_gui_mod
if /i "%1" == "--help" goto :help
if /i "%1" == "-h" goto :help
goto :help
:continue
shift
goto :parse_loop

:help
  echo Usage: %0 [OPTION]... [VAR=VALUE]...
  echo;
  echo Configuration:
  echo   -h, --help          display this help and exit
  echo   --enable-debug      compile with debugging information
  echo   --enable-gui-mod    compile and link with QtGui module
  echo;
  echo Installation directories:
  echo   --prefix=PREFIX     install files in PREFIX [%TFDIR%]
  goto :exit

:prefix
  shift
  if "%1" == "" goto :help
  set TFDIR=%1
  goto :continue

:enable_debug
  set DEBUG=yes
  goto :continue

:enable_gui_mod
  set USE_GUI=use_gui=1
  goto :continue

:start
if "%DEBUG%" == "yes" (
  set OPT="CONFIG+=debug"
) else (
  set OPT="CONFIG+=release"
)

::
:: Generates tfenv.bat
::
for %%I in (qmake.exe)  do if exist %%~$path:I set QMAKE=%%~$path:I
for %%I in (cmake.exe)  do if exist %%~$path:I set CMAKE=%%~$path:I
for %%I in (cl.exe)     do if exist %%~$path:I set MSCOMPILER=%%~$path:I
for %%I in (devenv.exe) do if exist %%~$path:I set DEVENV=%%~$path:I

if "%QMAKE%" == "" (
  echo Qt environment not found
  exit /b
)
if "%CMAKE%" == "" (
  echo CMake not found
  exit /b
)
if "%MSCOMPILER%" == "" if "%DEVENV%"  == "" (
  echo MSVC Compiler not found
  exit /b
)

:: get qt install prefix
for /f usebackq %%I in (`qtpaths.exe --install-prefix`) do (
  set QT_INSTALL_PREFIX=%%I
  goto :break
)
:break

:: vcvarsall.bat setup
set MAKE=nmake
if /i "%Platform%" == "x64" (
  set VCVARSOPT=amd64
  set BUILDTARGET=x64
  set ENVSTR=Environment to build for 64-bit executable  MSVC / Qt
) else (
  set VCVARSOPT=x86
  set BUILDTARGET=win32
  set ENVSTR=Environment to build for 32-bit executable  MSVC / Qt
)

echo %QT_INSTALL_PREFIX% | find "msvc2019" >NUL
if not ERRORLEVEL 1 (
  set VSVER=2019
  if /i "%Platform%" == "x64" (
    set CMAKEOPT=-G"Visual Studio 16 2019" -A x64
  ) else (
    set CMAKEOPT=-G"Visual Studio 16 2019" -A Win32
  )
) else (
  echo %QT_INSTALL_PREFIX% | find "msvc2017" >NUL
  if not ERRORLEVEL 1 (
    set VSVER=2017
    if /i "%Platform%" == "x64" (
      set CMAKEOPT=-G"Visual Studio 15 2017 Win64"
    ) else (
      set CMAKEOPT=-G"Visual Studio 15 2017"
    )
  ) else (
    set VSVER=2015
    if /i "%Platform%" == "x64" (
      set CMAKEOPT=-G"Visual Studio 14 2015 Win64"
    ) else (
      set CMAKEOPT=-G"Visual Studio 14 2015"
    )
  )
)

SET /P X="%ENVSTR%"<NUL
qtpaths.exe --qt-version

for %%I in (qtenv2.bat) do if exist %%~$path:I set QTENV=%%~$path:I
set TFENV=tfenv.bat
echo @echo OFF> %TFENV%
echo ::>> %TFENV%
echo :: This file is generated by configure.bat>> %TFENV%
echo ::>> %TFENV%
echo;>> %TFENV%
echo set TFDIR=%TFDIR%>> %TFENV%
echo set TreeFrog_DIR=%TFDIR%>> %TFENV%
echo set QTENV="%QTENV%">> %TFENV%
echo set QMAKESPEC=%QMAKESPEC%>> %TFENV%
echo set VCVARSBAT="">> %TFENV%
echo set VSVER=%VSVER%>> %TFENV%
echo set VSWHERE="%%ProgramFiles(x86)%%\Microsoft Visual Studio\Installer\vswhere.exe">> %TFENV%
echo;>> %TFENV%
echo if exist %%QTENV%% call %%QTENV%%>> %TFENV%
echo if exist %%VSWHERE%% ^(>> %TFENV%
echo   for /f "usebackq tokens=*" %%%%i in ^(`%%VSWHERE%% -find  **\vcvarsall.bat`^) do ^(>> %TFENV%
echo     echo %%%%i ^| find "%%VSVER%%" ^>NUL>> %TFENV%
echo     if not ERRORLEVEL 1 ^(>> %TFENV%
echo       set VCVARSBAT="%%%%i">> %TFENV%
echo       goto :break>> %TFENV%
echo     ^)>> %TFENV%
echo   ^)>> %TFENV%
echo ^)>> %TFENV%
echo :break>> %TFENV%
echo if exist %%VCVARSBAT%% ^(>> %TFENV%
echo   echo Setting up environment for MSVC usage...>> %TFENV%
echo   call %%VCVARSBAT%% %VCVARSOPT%>> %TFENV%
echo ^)>> %TFENV%
echo set PATH=%%TFDIR^%%\bin;%%PATH%%>> %TFENV%
echo echo Setup a TreeFrog/Qt environment.>> %TFENV%
echo echo -- TFDIR set to %%TFDIR%%>> %TFENV%
echo cd /D %%HOMEDRIVE%%%%HOMEPATH%%>> %TFENV%

set TFDIR=%TFDIR:\=/%
del /f /q .qmake.stash src\.qmake.stash tools\.qmake.stash >nul 2>&1

:: Builds MongoDB driver
cd /d %BASEDIR%3rdparty
rd /s /q  mongo-driver >nul 2>&1
del /f /q mongo-driver >nul 2>&1
mklink /j mongo-driver mongo-c-driver-%MONBOC_VERSION% >nul 2>&1

cd %BASEDIR%3rdparty\mongo-driver\src\libbson
del /f /q CMakeCache.txt cmake_install.cmake CMakeFiles Makefile >nul 2>&1
cmake %CMAKEOPT% -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_TESTS=OFF .
echo Compiling BSON library ...
devenv libbson.sln /project bson_static /rebuild Release >nul 2>&1
if ERRORLEVEL 1 (
  :: Shows error
  devenv libbson.sln /project bson_static /build Release
  echo;
  echo Build failed.
  echo MongoDB driver not available.
  exit /b
)

cd %BASEDIR%3rdparty\mongo-driver
del /f /q CMakeCache.txt cmake_install.cmake CMakeFiles Makefile >nul 2>&1
set CMAKECMD=cmake %CMAKEOPT% -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_STATIC=ON -DENABLE_SSL=OFF -DENABLE_SNAPPY=OFF -DENABLE_SRV=OFF -DENABLE_SASL=OFF -DENABLE_ZLIB=OFF -DENABLE_TESTS=OFF .
echo %CMAKECMD%
%CMAKECMD%

echo Compiling MongoDB driver library ...
set DEVENVCMD=devenv libmongoc.sln /project mongoc_static /rebuild Release >nul 2>&1
echo %DEVENVCMD%
%DEVENVCMD%
if ERRORLEVEL 1 (
  :: Shows error
  devenv libmongoc.sln /project mongoc_static /build Release
  echo;
  echo Build failed.
  echo MongoDB driver not available.
  exit /b
)

:: Builds LZ4
cd %BASEDIR%3rdparty
echo Compiling LZ4 library ...
rd /s /q  lz4 >nul 2>&1
del /f /q lz4 >nul 2>&1
mklink /j lz4 lz4-%LZ4_VERSION% >nul 2>&1
for /F %%i in ('qtpaths.exe --install-prefix') do echo %%i | find "msvc2015" >NUL
if not ERRORLEVEL 1 (
  set VS=VS2015
) else (
  set VS=VS2017
)
set DEVENVCMD=devenv lz4\build\%VS%\lz4.sln /project liblz4 /rebuild "Release|%BUILDTARGET%" >nul 2>&1
echo %DEVENVCMD%
%DEVENVCMD%
if ERRORLEVEL 1 (
  :: Shows error
  devenv lz4\build\%VS%\lz4.sln /project liblz4 /build "Release|%BUILDTARGET%"
  echo;
  echo Build failed.
  echo LZ4 not available.
  exit /b
)

cd %BASEDIR%src
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' %USE_GUI%

cd %BASEDIR%tools
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake -recursive %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' datadir='%TFDIR%'
%MAKE% qmake

echo;
echo First, run "%MAKE% install" in src directory.
echo Next, run "%MAKE% install" in tools directory.

:exit
exit /b

fix compilation error for VS2019 x64

fix compilation error for VS2019 x64


@echo OFF
@setlocal

set VERSION=1.25.0
set TFDIR=C:\TreeFrog\%VERSION%
set LZ4_VERSION=1.9.1

:parse_loop
if "%1" == "" goto :start
if /i "%1" == "--prefix" goto :prefix
if /i "%1" == "--enable-debug" goto :enable_debug
if /i "%1" == "--enable-gui-mod" goto :enable_gui_mod
if /i "%1" == "--help" goto :help
if /i "%1" == "-h" goto :help
goto :help
:continue
shift
goto :parse_loop

:help
  echo Usage: %0 [OPTION]... [VAR=VALUE]...
  echo;
  echo Configuration:
  echo   -h, --help          display this help and exit
  echo   --enable-debug      compile with debugging information
  echo   --enable-gui-mod    compile and link with QtGui module
  echo;
  echo Installation directories:
  echo   --prefix=PREFIX     install files in PREFIX [%TFDIR%]
  goto :exit

:prefix
  shift
  if "%1" == "" goto :help
  set TFDIR=%1
  goto :continue

:enable_debug
  set DEBUG=yes
  goto :continue

:enable_gui_mod
  set USE_GUI=use_gui=1
  goto :continue

:start
if "%DEBUG%" == "yes" (
  set OPT="CONFIG+=debug"
) else (
  set OPT="CONFIG+=release"
)

::
:: Generates tfenv.bat
::
for %%I in (qmake.exe) do if exist %%~$path:I set QMAKE=%%~$path:I
for %%I in (cl.exe) do if exist %%~$path:I set MSCOMPILER=%%~$path:I
for %%I in (g++.exe) do if exist %%~$path:I set GNUCOMPILER=%%~$path:I

if "%QMAKE%" == "" (
  echo Qt environment not found
  exit /b
)
if "%MSCOMPILER%" == "" if "%GNUCOMPILER%"  == "" (
  echo compiler not found
  exit /b
)

:: vcvarsall.bat setup
if not "%MSCOMPILER%" == "" (
  set MAKE=nmake
  if "%Platform%" == "X64" (
    set VCVARSOPT=amd64
    set ENVSTR=Environment to build for 64-bit executable  MSVC / Qt
  ) else if "%Platform%" == "x64" (
    set VCVARSOPT=amd64
    set ENVSTR=Environment to build for 64-bit executable  MSVC / Qt
  ) else (
    set VCVARSOPT=x86
    set ENVSTR=Environment to build for 32-bit executable  MSVC / Qt
  )
) else (
  set MAKE=mingw32-make -j%NUMBER_OF_PROCESSORS%
  set ENVSTR=Environment to build for executable MinGW / Qt
)
SET /P X="%ENVSTR%"<NUL
qtpaths.exe --qt-version

for %%I in (qtenv2.bat) do if exist %%~$path:I set QTENV=%%~$path:I
set TFENV=tfenv.bat
echo @echo OFF> %TFENV%
echo ::>> %TFENV%
echo :: This file is generated by configure.bat>> %TFENV%
echo ::>> %TFENV%
echo;>> %TFENV%
echo set TFDIR=%TFDIR%>> %TFENV%
echo set TreeFrog_DIR=%TFDIR%>> %TFENV%
echo set QTENV="%QTENV%">> %TFENV%
echo set QMAKESPEC=%QMAKESPEC%>> %TFENV%
echo if exist %%QTENV%% ( call %%QTENV%% )>> %TFENV%
if not "%VCVARSOPT%" == "" (
  echo if not "%%VS140COMNTOOLS%%" == "" ^(>> %TFENV%
  echo   set VCVARSBAT="%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat">> %TFENV%
  echo ^) else if not "%%VS120COMNTOOLS%%" == "" ^(>> %TFENV%
  echo   set VCVARSBAT="%%VS120COMNTOOLS%%..\..\VC\vcvarsall.bat">> %TFENV%
  echo ^) else ^(>> %TFENV%
  echo   set VCVARSBAT="">> %TFENV%
  echo ^)>> %TFENV%
  echo if exist %%VCVARSBAT%% ^(>> %TFENV%
  echo   echo Setting up environment for MSVC usage...>> %TFENV%
  echo   call %%VCVARSBAT%% %VCVARSOPT%>> %TFENV%
  echo ^)>> %TFENV%
)
echo set PATH=%%TFDIR^%%\bin;%%PATH%%>> %TFENV%
echo echo Setup a TreeFrog/Qt environment.>> %TFENV%
echo echo -- TFDIR set to %%TFDIR%%>> %TFENV%
echo cd /D %%HOMEDRIVE%%%%HOMEPATH%%>> %TFENV%

set TFDIR=%TFDIR:\=/%
del 3rdparty\mongo-c-driver\.qmake.stash src\.qmake.stash tools\.qmake.stash >nul 2>&1
:: Builds MongoDB driver
echo Compiling MongoDB driver library ...
cd 3rdparty\mongo-c-driver
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )

qmake -r %OPT%
%MAKE% >nul 2>&1
if ERRORLEVEL 1 (
  echo Compile failed.
  echo MongoDB driver not available.
  exit /b
)

:: Builds LZ4
cd ..
rd /s /q lz4 >nul 2>&1
del /f /q lz4 >nul 2>&1
mklink /d lz4 lz4-%LZ4_VERSION% >nul 2>&1
if not "%MSCOMPILER%" == "" (
  for /F %%i in ('qtpaths.exe --install-prefix') do echo %%i | find "msvc2015" >NUL
  if not ERRORLEVEL 1 (
    devenv lz4\visual\VS2015\lz4.sln /project liblz4 /rebuild "Release|x64"
  ) else (
    devenv lz4\visual\VS2017\lz4.sln /project liblz4 /rebuild "Release|x64"
  )
) else (
  cd lz4\lib
  qmake -o makefile.liblz4
  %MAKE% -f makefile.liblz4 clean
  %MAKE% -f makefile.liblz4
  cd ..\..
)
cd ..

cd src
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' %USE_GUI%
cd ..
cd tools
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake -recursive %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' datadir='%TFDIR%'
%MAKE% qmake
cd ..

echo;
echo First, run "%MAKE% install" in src directory.
echo Next, run "%MAKE% install" in tools directory.

:exit
exit /b

@echo OFF
@setlocal

set VERSION=1.25.0
set TFDIR=C:\TreeFrog\%VERSION%
set LZ4_VERSION=1.9.1

:parse_loop
if "%1" == "" goto :start
if /i "%1" == "--prefix" goto :prefix
if /i "%1" == "--enable-debug" goto :enable_debug
if /i "%1" == "--enable-gui-mod" goto :enable_gui_mod
if /i "%1" == "--help" goto :help
if /i "%1" == "-h" goto :help
goto :help
:continue
shift
goto :parse_loop

:help
  echo Usage: %0 [OPTION]... [VAR=VALUE]...
  echo;
  echo Configuration:
  echo   -h, --help          display this help and exit
  echo   --enable-debug      compile with debugging information
  echo   --enable-gui-mod    compile and link with QtGui module
  echo;
  echo Installation directories:
  echo   --prefix=PREFIX     install files in PREFIX [%TFDIR%]
  goto :exit

:prefix
  shift
  if "%1" == "" goto :help
  set TFDIR=%1
  goto :continue

:enable_debug
  set DEBUG=yes
  goto :continue

:enable_gui_mod
  set USE_GUI=use_gui=1
  goto :continue

:start
if "%DEBUG%" == "yes" (
  set OPT="CONFIG+=debug"
) else (
  set OPT="CONFIG+=release"
)

::
:: Generates tfenv.bat
::
for %%I in (qmake.exe) do if exist %%~$path:I set QMAKE=%%~$path:I
for %%I in (cl.exe) do if exist %%~$path:I set MSCOMPILER=%%~$path:I
for %%I in (g++.exe) do if exist %%~$path:I set GNUCOMPILER=%%~$path:I

if "%QMAKE%" == "" (
  echo Qt environment not found
  exit /b
)
if "%MSCOMPILER%" == "" if "%GNUCOMPILER%"  == "" (
  echo compiler not found
  exit /b
)

:: vcvarsall.bat setup
if not "%MSCOMPILER%" == "" (
  set MAKE=nmake
  if "%Platform%" == "X64" (
    set VCVARSOPT=amd64
    set ENVSTR=Environment to build for 64-bit executable  MSVC / Qt
  ) else if "%Platform%" == "x64" (
    set VCVARSOPT=amd64
    set ENVSTR=Environment to build for 64-bit executable  MSVC / Qt
  ) else (
    set VCVARSOPT=x86
    set ENVSTR=Environment to build for 32-bit executable  MSVC / Qt
  )
) else (
  set MAKE=mingw32-make -j%NUMBER_OF_PROCESSORS%
  set ENVSTR=Environment to build for executable MinGW / Qt
)
SET /P X="%ENVSTR%"<NUL
qtpaths.exe --qt-version

for %%I in (qtenv2.bat) do if exist %%~$path:I set QTENV=%%~$path:I
set TFENV=tfenv.bat
echo @echo OFF> %TFENV%
echo ::>> %TFENV%
echo :: This file is generated by configure.bat>> %TFENV%
echo ::>> %TFENV%
echo;>> %TFENV%
echo set TFDIR=%TFDIR%>> %TFENV%
echo set TreeFrog_DIR=%TFDIR%>> %TFENV%
echo set QTENV="%QTENV%">> %TFENV%
echo set QMAKESPEC=%QMAKESPEC%>> %TFENV%
echo if exist %%QTENV%% ( call %%QTENV%% )>> %TFENV%
if not "%VCVARSOPT%" == "" (
  echo if not "%%VS140COMNTOOLS%%" == "" ^(>> %TFENV%
  echo   set VCVARSBAT="%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat">> %TFENV%
  echo ^) else if not "%%VS120COMNTOOLS%%" == "" ^(>> %TFENV%
  echo   set VCVARSBAT="%%VS120COMNTOOLS%%..\..\VC\vcvarsall.bat">> %TFENV%
  echo ^) else ^(>> %TFENV%
  echo   set VCVARSBAT="">> %TFENV%
  echo ^)>> %TFENV%
  echo if exist %%VCVARSBAT%% ^(>> %TFENV%
  echo   echo Setting up environment for MSVC usage...>> %TFENV%
  echo   call %%VCVARSBAT%% %VCVARSOPT%>> %TFENV%
  echo ^)>> %TFENV%
)
echo set PATH=%%TFDIR^%%\bin;%%PATH%%>> %TFENV%
echo echo Setup a TreeFrog/Qt environment.>> %TFENV%
echo echo -- TFDIR set to %%TFDIR%%>> %TFENV%
echo cd /D %%HOMEDRIVE%%%%HOMEPATH%%>> %TFENV%

set TFDIR=%TFDIR:\=/%
del 3rdparty\mongo-c-driver\.qmake.stash src\.qmake.stash tools\.qmake.stash >nul 2>&1
:: Builds MongoDB driver
echo Compiling MongoDB driver library ...
cd 3rdparty\mongo-c-driver
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )

qmake -r %OPT%
%MAKE% >nul 2>&1
if ERRORLEVEL 1 (
  echo Compile failed.
  echo MongoDB driver not available.
  exit /b
)

:: Builds LZ4
cd ..
rd /s /q lz4 >nul 2>&1
del /f /q lz4 >nul 2>&1
mklink /d lz4 lz4-%LZ4_VERSION% >nul 2>&1
if not "%MSCOMPILER%" == "" (
  for /F %%i in ('qtpaths.exe --install-prefix') do echo %%i | find "msvc2015" >NUL
  if not ERRORLEVEL 1 (
    devenv lz4\visual\VS2015\lz4.sln /project liblz4 /rebuild "Release|%VCVARSOPT%"
  ) else (
    devenv lz4\visual\VS2017\lz4.sln /project liblz4 /rebuild "Release|%VCVARSOPT%"
  )
) else (
  cd lz4\lib
  qmake -o makefile.liblz4
  %MAKE% -f makefile.liblz4 clean
  %MAKE% -f makefile.liblz4
  cd ..\..
)
cd ..

cd src
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' %USE_GUI%
cd ..
cd tools
if exist Makefile ( %MAKE% -k distclean >nul 2>&1 )
qmake -recursive %OPT% target.path='%TFDIR%/bin' header.path='%TFDIR%/include' datadir='%TFDIR%'
%MAKE% qmake
cd ..

echo;
echo First, run "%MAKE% install" in src directory.
echo Next, run "%MAKE% install" in tools directory.

:exit
exit /b

update configure.bat

update configure.bat


@ECHO off
SETLOCAL EnableExtensions
SETLOCAL EnableDelayedExpansion

:: ### Version History -- X.Y.Z_YYYYMMDD-hhmm Author Description
SET version=1.0.0_20160616-0600 &: Peter Kirschner   downloading,extract,configure and launch eclipse-installer with jre
SET version=%version: =%
SET title=idefixInstaller script %~nx0 - version %version%
TITLE %title%
SET POWERSHELL_TITLE=$Host.UI.RawUI.WindowTitle='%title%'

IF "%1"=="" (
    SET BRANCH=master
) ELSE (
    SET BRANCH=%1
)

IF "%2"=="" (
    SET JAVA_WEB=http://www.klib.io/_archives/java/1.8
) ELSE (
    ::SET JAVA_WEB=https://s3-eu-west-1.amazonaws.com/klib.io/www/_archives/java/zipped/1.8
    SET JAVA_WEB=http://jazz01.rd.corpintra.net/web/repo/_archives/java/zipped/1.8
)
SET JAVA_ARCHIVE=win32.x86_64-jre1.8.0_74.zip
SET JAVA=%JAVA_ARCHIVE:~13,-4%

:: ###########################################################
SET SCRIPTNAME=%~n0
SET SCRIPT_PATH=%~dp0
SET SCRIPT_PATH=%SCRIPT_PATH:~0,-1%

SET ECL_INST_NAME=idefixInstaller
SET DL=%SCRIPT_PATH%\.download
:: folder must exists for powershell download requests
MKDIR %DL% 2>&1 > NUL

SET GITHUB_IO=http://peterkir.github.io/org.eclipse.oomph/
SET GITHUB_IO_LATEST=latest

SET GITHUB_IO_BOOT=http://peterkir.github.io/idefix/bootstrap/peterkir/win32

SET BUILD_SERVER_ROOT=https://dl.bintray.com/peterkir/generic/org.eclipse.oomph
SET BUILD_SERVER_ROOT=http://www.klib.io/org.eclipse.oomph
SET OOMPH_VERSION=1.6.0

SET CUSTOM=peterkir
SET PROD_CAT_FILTER=io\\.klib\\.products
SET PROD_FILTER=idefix\\.base
SET PROD_VERSION=osgi\\.idefix\\.neon\\.bndtools\\.3\\.3\\.0

::ECHO.
::ECHO # workaroung for NTLMv2 ProxyAuth - starting IE
::ECHO.
::SET IE_CMD="C:\Program Files (x86)\Internet Explorer\iexplore.exe www.google.de"
::SET IE_DIR="%TEMP%"
::FOR /F "tokens=2 delims=;=" %%a IN (
::  'WMIC process call create %IE_CMD%^, %IE_DIR% ^| find "ProcessId"'
::) DO (
::  SET IE_PID=%%a
::)
::ECHO browser launched with PID %IE_PID%
:: TODO search an kill the IE if not previously open WMIC process %IE_PID% delete

SET JAVA_CMD=setupJavaSDK.cmd
ECHO.
ECHO # downloading and configuring Java via %GITHUB_IO_BOOT%/%JAVA_CMD%
ECHO.
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path %DL%\%JAVA_CMD% ) { Write-Output 'skipping download, cause file exists - %DL%\%JAVA_CMD%' } else {(New-Object System.Net.WebClient).DownloadFile('%GITHUB_IO_BOOT%/%JAVA_CMD%','%DL%\%JAVA_CMD%')}"
IF "%ERRORLEVEL%"=="" (
    ECHO failing downloading file %GITHUB_IO_BOOT%/%JAVA_CMD%
    GOTO END
)

:: installing JDKs into %SCRIPT_PATH%/java
CALL %DL%\%JAVA_CMD% %SCRIPT_PATH%

FOR /F %%a IN ('DIR /B %SCRIPT_PATH%\java\1.8') DO SET JAVA8=%SCRIPT_PATH%\java\1.8\%%a

ECHO.
ECHO # download and extract into %SCRIPT_PATH%\%ECL_INST_NAME%
ECHO.

SET ECLIPSE_INSTALLER_WEB=%BUILD_SERVER_ROOT%/%OOMPH_VERSION%/
SET ECLIPSE_INSTALLER_ARCHIVE=org.eclipse.oomph.setup.installer.product-win32.win32.x86_64.zip
SET ECLIPSE_INSTALLER=%ECLIPSE_INSTALLER_ARCHIVE:~0,-4%

powershell -nologo -noprofile -command "%POWERSHELL_TITLE%;if ( Test-Path %DL%\%ECLIPSE_INSTALLER_ARCHIVE% ) { Write-Output '   - skipping download, cause file exists - %DL%\%ECLIPSE_INSTALLER_ARCHIVE%' } else { Write-Output '   - downloading archive %ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%';$browser = New-Object System.Net.WebClient; $browser.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials; $browser.DownloadFile('%ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%','%DL%\%ECLIPSE_INSTALLER_ARCHIVE%')}"
IF "%ERRORLEVEL%"=="" (
    ECHO failing downloading file %ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%
    GOTO END
)

powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path '%SCRIPT_PATH%\%ECL_INST_NAME%' -PathType Container )  { Write-Output '   - skipping extraction, cause folder exists - %SCRIPT_PATH%\%ECL_INST_NAME%' } else { Write-Output '   - extracting ECLIPSE_INSTALLER archive to %SCRIPT_PATH%\%ECL_INST_NAME%'; Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('%DL%\%ECLIPSE_INSTALLER_ARCHIVE%', '%SCRIPT_PATH%\%ECL_INST_NAME%')}"

ECHO    - copying latest java %JAVA8%\jre into %SCRIPT_PATH%\%ECL_INST_NAME%\jre
IF NOT EXIST %SCRIPT_PATH%\%ECL_INST_NAME%\jre\NUL (
    XCOPY /Y /I /E /H %JAVA8%\jre %SCRIPT_PATH%\%ECL_INST_NAME%\jre 2>&1 > NUL
)

SET ECL_INST_INI=%SCRIPT_PATH%\%ECL_INST_NAME%\eclipse-inst.ini

FINDSTR peterkir.github.io %ECL_INST_INI% 2>&1 > NUL
IF "%ERRORLEVEL%"=="" (
    ECHO    - skipping vmArgs addition, cause already inside
) ELSE (
    ECHO    - adding vmArgs to ini file
    :: allow installation of unsigned bundles
    ECHO -Declipse.p2.unsignedPolicy=allow >> %ECL_INST_INI%

    :: hidden p2 options (configured to default)
    ECHO -Declipse.p2.max.threads=4        >> %ECL_INST_INI%
    ECHO -Declipse.p2.force.threading=true >> %ECL_INST_INI%
    ECHO -Declipse.p2.mirrors=true         >> %ECL_INST_INI%

    :: filtering user displayed catalogs/products/versions
    ECHO -Doomph.setup.product.catalog.filter=%PROD_CAT_FILTER%>> %ECL_INST_INI%
    ECHO -Doomph.setup.product.filter=%PROD_FILTER%>>             %ECL_INST_INI%
    ECHO -Doomph.setup.product.version.filter=%PROD_VERSION%>>    %ECL_INST_INI%

    ECHO -Doomph.setup.jre.choice=false                          >> %ECL_INST_INI%
    ECHO -Doomph.installer.update.url=%BUILD_STORE%/p2/installer >> %ECL_INST_INI%
    ECHO -Doomph.update.url=%BUILD_STORE%/p2/oomph               >> %ECL_INST_INI%
    ECHO -Doomph.setup.installer.mode=advanced                   >> %ECL_INST_INI%
    ECHO -Doomph.redirection.klibProductCatalog=index:/redirectable.products.setup-^>https://peterkir.github.io/idefix/oomph/%CUSTOM%/productsCatalog.setup >> %ECL_INST_INI%
    ECHO -Doomph.redirection.klibProjectCatalog=index:/redirectable.projects.setup-^>https://peterkir.github.io/idefix/oomph/%CUSTOM%/projectsCatalog.setup >> %ECL_INST_INI%
)

ECHO.
ECHO # launching %ECL_INST_NAME%
ECHO.
START /B %SCRIPT_PATH%\%ECL_INST_NAME%\eclipse-inst.exe

::ECHO.
::ECHO # clean-up
::ECHO.
::RMDIR /Q /S %DL%

:END

@ECHO off
SETLOCAL EnableExtensions
SETLOCAL EnableDelayedExpansion

:: ### Version History -- X.Y.Z_YYYYMMDD-hhmm Author Description
SET version=1.0.0_20160616-0600 &: Peter Kirschner   downloading,extract,configure and launch eclipse-installer with jre
SET version=%version: =%
SET title=idefixInstaller script %~nx0 - version %version%
TITLE %title%
SET POWERSHELL_TITLE=$Host.UI.RawUI.WindowTitle='%title%'

IF "%1"=="" (
    SET BRANCH=master
) ELSE (
    SET BRANCH=%1
)

IF "%2"=="" (
    SET JAVA_WEB=http://www.klib.io/_archives/java/1.8
) ELSE (
    ::SET JAVA_WEB=https://s3-eu-west-1.amazonaws.com/klib.io/www/_archives/java/zipped/1.8
    SET JAVA_WEB=http://jazz01.rd.corpintra.net/web/repo/_archives/java/zipped/1.8
)
SET JAVA_ARCHIVE=win32.x86_64-jre1.8.0_74.zip
SET JAVA=%JAVA_ARCHIVE:~13,-4%

:: ###########################################################
SET SCRIPTNAME=%~n0
SET SCRIPT_PATH=%~dp0
SET SCRIPT_PATH=%SCRIPT_PATH:~0,-1%

SET ECL_INST_NAME=idefixInstaller
SET DL=%SCRIPT_PATH%\.download
:: folder must exists for powershell download requests
MKDIR %DL% 2>&1 > NUL

SET GITHUB_IO=http://peterkir.github.io/org.eclipse.oomph/
SET GITHUB_IO_LATEST=latest

SET GITHUB_IO_BOOT=http://peterkir.github.io/idefix/bootstrap/peterkir/win32

SET BUILD_SERVER_ROOT=https://dl.bintray.com/peterkir/generic/org.eclipse.oomph
SET BUILD_SERVER_ROOT=http://www.klib.io/org.eclipse.oomph
SET OOMPH_VERSION=1.6.0

SET CUSTOM=peterkir
SET PROD_CAT_FILTER=io\\.klib\\.products
SET PROD_FILTER=idefix\\.base
SET PROD_VERSION=osgi\\.idefix\\.neon\\.bndtools\\.3\\.3\\.0

::ECHO.
::ECHO # workaroung for NTLMv2 ProxyAuth - starting IE
::ECHO.
::SET IE_CMD="C:\Program Files (x86)\Internet Explorer\iexplore.exe www.google.de"
::SET IE_DIR="%TEMP%"
::FOR /F "tokens=2 delims=;=" %%a IN (
::  'WMIC process call create %IE_CMD%^, %IE_DIR% ^| find "ProcessId"'
::) DO (
::  SET IE_PID=%%a
::)
::ECHO browser launched with PID %IE_PID%
:: TODO search an kill the IE if not previously open WMIC process %IE_PID% delete

SET JAVA_CMD=setupJavaSDK.cmd
ECHO.
ECHO # downloading and configuring Java via %GITHUB_IO_BOOT%/%JAVA_CMD%
ECHO.
powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path %DL%\%JAVA_CMD% ) { Write-Output 'skipping download, cause file exists - %DL%\%JAVA_CMD%' } else {(New-Object System.Net.WebClient).DownloadFile('%GITHUB_IO_BOOT%/%JAVA_CMD%','%DL%\%JAVA_CMD%')}"
IF "%ERRORLEVEL%"=="" (
    ECHO failing downloading file %GITHUB_IO_BOOT%/%JAVA_CMD%
    GOTO END
)

:: installing JDKs into %SCRIPT_PATH%/java
CALL %DL%\%JAVA_CMD% %SCRIPT_PATH%

FOR /F %%a IN ('DIR /B %SCRIPT_PATH%\java\1.8') DO SET JAVA8=%SCRIPT_PATH%\java\1.8\%%a

ECHO.
ECHO # download and extract into %SCRIPT_PATH%\%ECL_INST_NAME%
ECHO.

SET ECLIPSE_INSTALLER_WEB=%BUILD_SERVER_ROOT%/%OOMPH_VERSION%/
SET ECLIPSE_INSTALLER_ARCHIVE=org.eclipse.oomph.setup.installer.product-win32.win32.x86_64.zip
SET ECLIPSE_INSTALLER=%ECLIPSE_INSTALLER_ARCHIVE:~0,-4%

powershell -nologo -noprofile -command "%POWERSHELL_TITLE%;if ( Test-Path %DL%\%ECLIPSE_INSTALLER_ARCHIVE% ) { Write-Output '   - skipping download, cause file exists - %DL%\%ECLIPSE_INSTALLER_ARCHIVE%' } else { Write-Output '   - downloading archive %ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%';$browser = New-Object System.Net.WebClient; $browser.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials; $browser.DownloadFile('%ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%','%DL%\%ECLIPSE_INSTALLER_ARCHIVE%')}"
IF "%ERRORLEVEL%"=="" (
    ECHO failing downloading file %ECLIPSE_INSTALLER_WEB%/%ECLIPSE_INSTALLER_ARCHIVE%
    GOTO END
)

powershell -nologo -noprofile  -command "%POWERSHELL_TITLE%;if ( Test-Path '%SCRIPT_PATH%\%ECL_INST_NAME%' -PathType Container )  { Write-Output '   - skipping extraction, cause folder exists - %SCRIPT_PATH%\%ECL_INST_NAME%' } else { Write-Output '   - extracting ECLIPSE_INSTALLER archive to %SCRIPT_PATH%\%ECL_INST_NAME%'; Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('%DL%\%ECLIPSE_INSTALLER_ARCHIVE%', '%SCRIPT_PATH%\%ECL_INST_NAME%')}"

ECHO    - copying latest java %JAVA8%\jre into %SCRIPT_PATH%\%ECL_INST_NAME%\jre
IF NOT EXIST %SCRIPT_PATH%\%ECL_INST_NAME%\jre\NUL (
    XCOPY /Y /I /E /H %JAVA8%\jre %SCRIPT_PATH%\%ECL_INST_NAME%\jre 2>&1 > NUL
)

SET ECL_INST_INI=%SCRIPT_PATH%\%ECL_INST_NAME%\eclipse-inst.ini

FINDSTR peterkir.github.io %ECL_INST_INI% 2>&1 > NUL
IF "%ERRORLEVEL%"=="" (
    ECHO    - skipping vmArgs addition, cause already inside
) ELSE (
    ECHO    - adding vmArgs to ini file
    :: allow installation of unsigned bundles
    ECHO -Declipse.p2.unsignedPolicy=allow >> %ECL_INST_INI%

    :: hidden p2 options (configured to default)
    ECHO -Declipse.p2.max.threads=4        >> %ECL_INST_INI%
    ECHO -Declipse.p2.force.threading=true >> %ECL_INST_INI%
    ECHO -Declipse.p2.mirrors=true         >> %ECL_INST_INI%

    :: filtering user displayed catalogs/products/versions
    ECHO -Doomph.setup.product.catalog.filter=%PROD_CAT_FILTER%>> %ECL_INST_INI%
    ECHO -Doomph.setup.product.filter=%PROD_FILTER%>>             %ECL_INST_INI%
    ECHO -Doomph.setup.product.version.filter=%PROD_VERSION%>>    %ECL_INST_INI%

    ECHO -Doomph.setup.jre.choice=false                          >> %ECL_INST_INI%
    ECHO -Doomph.installer.update.url=%BUILD_STORE%/p2/installer >> %ECL_INST_INI%
    ECHO -Doomph.update.url=%BUILD_STORE%/p2/oomph               >> %ECL_INST_INI%
    ECHO -Doomph.setup.installer.mode=advanced                   >> %ECL_INST_INI%
    ECHO -Doomph.redirection.klibProductCatalog=index:/redirectable.products.setup-^>https://peterkir.github.io/idefix/oomph/%CUSTOM%/catalogProducts.setup >> %ECL_INST_INI%
    ECHO -Doomph.redirection.klibProjectCatalog=index:/redirectable.projects.setup-^>https://peterkir.github.io/idefix/oomph/%CUSTOM%/catalogProjects.setup >> %ECL_INST_INI%
)

ECHO.
ECHO # launching %ECL_INST_NAME%
ECHO.
START /B %SCRIPT_PATH%\%ECL_INST_NAME%\eclipse-inst.exe

::ECHO.
::ECHO # clean-up
::ECHO.
::RMDIR /Q /S %DL%

:END

update peterkir to oomph 1.6.0

update peterkir to oomph 1.6.0


@echo off
ECHO ***** Starting tests using nd4j-native backend *****
call mvn clean site -Ddependency.locations.enabled=false -P test-nd4j-native -fn
ECHO ***** Constructing nd4j-native site at projectRootDirectory\site\nd4j-native_DATE-TIME *****
call mvn site:stage -DstagingDirectory=%cd%\site\nd4j-native_%DATE:/=-%_%TIME::=-%
ECHO ***** Starting tests using nd4j-cuda-8 backend *****
call mvn clean site -Ddependency.locations.enabled=false -P test-nd4j-native -fn
ECHO ***** Constructing nd4j-native site at projectRootDirectory\site\nd4j-cuda-8_DATE-TIME *****
call mvn site:stage -DstagingDirectory=%cd%\site\nd4j-cuda-8_%DATE:/=-%_%TIME::=-%

@echo off
if not exist %cd%\tests mkdir tests
set currTime=%DATE:/=-%_%TIME::=-%
set outputFile=tests\nd4j-native_%currTime%.log
ECHO ***** Starting tests using nd4j-native backend, piping output to %outputFile% *****
call mvn clean site -Ddependency.locations.enabled=false -P test-nd4j-native -fn > %cd%\%outputFile% 2>&1
ECHO ***** Constructing nd4j-native site at projectRootDirectory\tests\nd4j-native_DATE-TIME *****
call mvn site:stage -DstagingDirectory=%cd%\tests\nd4j-native_%currTime%
ECHO ***** Starting tests using nd4j-cuda-8 backend *****
set outputFile=tests\nd4j-cuda-8_%currTime%.log
call mvn clean site -Ddependency.locations.enabled=false -P test-nd4j-cuda-8 -fn > %cd%\%outputFile% 2>&1
ECHO ***** Constructing nd4j-native site at projectRootDirectory\tests\nd4j-cuda-8_DATE-TIME *****
call mvn site:stage -DstagingDirectory=%cd%\tests\nd4j-cuda-8_%currTime%

Update runWindowsTests.cmd script

Update runWindowsTests.cmd script

Former-commit-id: 1350e87e8211a99dcb9afee885faf3cc97955ff7


:: Copyright 2014 by SyneArt <sa@syneart.com>
@echo off&cls&title Install&color 0F&mode con cols=38 lines=10
setlocal enableextensions enabledelayedexpansion
echo.&echo.&echo.&echo.&echo Install Theme Now ..
set str=!PATH: =/!&set str=!str:(x86)=[x86]!&set MiKTeXPath=nul
FOR %%b in (!str!) DO (
	set nowStr=%%b&set MiKTeXStr=x!nowStr:MiKTeX=!
	if not !MiKTeXStr!==x!nowStr! set MiKTeXPath=!nowStr!
)
if !MiKTeXPath!==nul (
	cls&echo.&echo.&echo.&echo.&echo 請先安裝 MiKTeX, 再執行本安裝
	color E3&set /p=&goto exit
)
set MiKTeXPath=!MiKTeXPath:miktex\bin\=!&set MiKTeXPath=!MiKTeXPath:x64\=!&set MiKTeXPath=!MiKTeXPath:/= !&set MiKTeXPath=!MiKTeXPath:[x86]=(x86)!
if not exist "!MiKTeXPath!tex\latex\beamer\" (
	cls&echo.&echo.&echo.&echo.&echo 請先安裝 Beamer, 再執行本安裝
	color E3&set /p=&goto exit
)
call:copyFile .\themes, *.sty&call:copyFile .\art, *.jpg
initexmf --admin --update-fndb >nul
if !errorlevel!==1 (
	cls&echo.&echo.&echo.&echo.&echo 請先停止編譯 MiKTeX 專案, 再執行
	color 4C&set /p=&goto exit
)
cls&echo.&echo.&echo.&echo.&echo Install Theme Successful ^^!&color 2A&ping 127.0.0.1 -n 3 >nul&goto exit

:copyFile
FOR /R %~1 %%c in (%~2) DO (
	set themesFile=%%c&set themesFile=!themesFile:%~dp0=!
	copy /Y "%%c" "!MiKTeXPath!tex\latex\beamer\base\!themesFile!" >nul
)

:exit

:: Copyright 2014 by SyneArt <sa@syneart.com>
@echo off&cls&title Install&color 0F&mode con cols=38 lines=10
setlocal enableextensions enabledelayedexpansion
echo.&echo.&echo.&echo.&echo Install Theme Now ..
set str=!PATH: =/!&set str=!str:(x86)=[x86]!&set MiKTeXPath=nul
FOR %%b in (!str!) DO (
	set nowStr=%%b&set MiKTeXStr=x!nowStr:MiKTeX=!
	if not !MiKTeXStr!==x!nowStr! set MiKTeXPath=!nowStr!
)
if !MiKTeXPath!==nul (
	cls&echo.&echo.&echo.&echo.&echo 請先安裝 MiKTeX, 再執行本安裝
	color E3&set /p=&goto exit
)
set MiKTeXPath=!MiKTeXPath:miktex\bin\=!&set MiKTeXPath=!MiKTeXPath:x64\=!
set MiKTeXPath=!MiKTeXPath:/= !&set MiKTeXPath=!MiKTeXPath:[x86]=(x86)!
if not exist "!MiKTeXPath!tex\latex\beamer\" (
	cls&echo.&echo.&echo.&echo.&echo 請先安裝 Beamer, 再執行本安裝
	color E3&set /p=&goto exit
)
call:copyFile .\themes, *.sty&call:copyFile .\art, *.jpg
initexmf --admin --update-fndb >nul
if !errorlevel!==1 (
	cls&echo.&echo.&echo.&echo.&echo 請先停止編譯 MiKTeX 專案, 再執行
	color 4C&set /p=&goto exit
)
cls&echo.&echo.&echo.&echo.&echo Install Theme Successful ^^!&color 2A&ping 127.0.0.1 -n 3 >nul&goto exit

:copyFile
FOR /R %~1 %%c in (%~2) DO (
	set themesFile=%%c&set themesFile=!themesFile:%~dp0=!
	copy /Y "%%c" "!MiKTeXPath!tex\latex\beamer\base\!themesFile!" >nul
)

:exit

Fix MiKTeX x64 Path decide [Code sort]

Fix MiKTeX x64 Path decide [Code sort]


@echo off
set prev=%cd%
cd /D "%~dp0"

java -jar RoboViz.jar %*

cd %prev%

Allow calling roboviz.bat from anywhere

Allow calling roboviz.bat from anywhere


@echo off

if ERRORLEVEL 1 goto end
set Configuration=Debug

if /i "%1"=="Install" goto Install
if /i "%1"=="Package" goto Release
if /i "%1"=="run-perftester" goto Release
goto Build

:Release
set Configuration=Release
goto Build

:Install
.\Tools\nuget.exe restore Chutzpah.VS.sln
goto Build

:Build

powershell -NonInteractive -NoProfile -ExecutionPolicy unrestricted -Command "& {Import-Module %~dp0\packages\psake.4.6.0\Tools\psake.psm1; Invoke-psake default.ps1 -properties @{configuration='%Configuration%'} -parameters @{arg0='%1'; arg1='%2'; arg2='%3'; arg3='%4'} -framework '4.5.1' %1"}"

goto end

:end
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%

@echo off

if ERRORLEVEL 1 goto end
set Configuration=Debug

if /i "%1"=="Install" goto Install
if /i "%1"=="Package" goto Release
if /i "%1"=="run-perftester" goto Release
goto Build

:Release
set Configuration=Release
goto Build

:Install
.\Tools\nuget.exe restore Chutzpah.VS.sln
goto Build

:Build

powershell -NonInteractive -NoProfile -ExecutionPolicy unrestricted -Command "& {Import-Module %~dp0\packages\psake.4.6.0\Tools\psake.psm1; Invoke-psake default.ps1 -properties @{configuration='%Configuration%'} -parameters @{arg0='%1'; arg1='%2'; arg2='%3'; arg3='%4'} -framework '4.5.1x86' %1"}"

goto end

:end
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%

update build

update build


@ECHO OFF
REM NOTE: This file was auto-generated with `IB.exe prepare` from `IntelliFactory.Build`.

setlocal
set PATH=%PATH%;%ProgramFiles(x86)%\Microsoft SDKs\F#\3.1\Framework\v4.0
set PATH=%PATH%;%ProgramFiles(x86)%\Microsoft SDKs\F#\3.0\Framework\v4.0
set PATH=%PATH%;%ProgramFiles%\Microsoft SDKs\F#\3.1\Framework\v4.0
set PATH=%PATH%;%ProgramFiles%\Microsoft SDKs\F#\3.0\Framework\v4.0
set PATH=%PATH%;tools\NuGet
nuget install IntelliFactory.Build -nocache -pre -ExcludeVersion -o tools\packages
fsi.exe --exec build.fsx %*

@ECHO OFF
REM NOTE: This file was auto-generated with `IB.exe prepare` from `IntelliFactory.Build`.

setlocal
set PATH=%PATH%;%ProgramFiles(x86)%\Microsoft SDKs\F#\4.0\Framework\v4.0
set PATH=%PATH%;%ProgramFiles(x86)%\Microsoft SDKs\F#\3.1\Framework\v4.0
set PATH=%PATH%;%ProgramFiles(x86)%\Microsoft SDKs\F#\3.0\Framework\v4.0
set PATH=%PATH%;%ProgramFiles%\Microsoft SDKs\F#\3.1\Framework\v4.0
set PATH=%PATH%;%ProgramFiles%\Microsoft SDKs\F#\3.0\Framework\v4.0
set PATH=%PATH%;tools\NuGet
nuget install IntelliFactory.Build -nocache -pre -ExcludeVersion -o tools\packages
fsi.exe --exec build.fsx %*

Fix build for VS2015 only

Fix build for VS2015 only


@echo off

pushd %~dp0

SET PACKAGEPATH=.\packages\
SET NUGET=.\tools\nuget\NuGet.exe
SET NUGETOPTIONS=-ConfigFile .\tools\nuget\NuGet.Config -OutputDirectory %PACKAGEPATH% -ExcludeVersion

IF NOT EXIST %PACKAGEPATH%FAKE\Ver_4.25.4 (
  RD /S/Q %PACKAGEPATH%FAKE
  %NUGET% install FAKE -Version 4.25.4 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE\Ver_4.25.4
)

IF NOT EXIST %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.2 (
  RD /S/Q %PACKAGEPATH%FAKE.BuildLib
  %NUGET% install FAKE.BuildLib -Version 0.3.2 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.2
)

set encoding=utf-8
"%PACKAGEPATH%FAKE\tools\FAKE.exe" build.fsx %*

popd

@echo off

pushd %~dp0

SET PACKAGEPATH=.\packages\
SET NUGET=.\tools\nuget\NuGet.exe
SET NUGETOPTIONS=-ConfigFile .\tools\nuget\NuGet.Config -OutputDirectory %PACKAGEPATH% -ExcludeVersion

IF NOT EXIST %PACKAGEPATH%FAKE\Ver_4.25.4 (
  RD /S/Q %PACKAGEPATH%FAKE
  %NUGET% install FAKE -Version 4.25.4 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE\Ver_4.25.4
)

IF NOT EXIST %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.3 (
  RD /S/Q %PACKAGEPATH%FAKE.BuildLib
  %NUGET% install FAKE.BuildLib -Version 0.3.3 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.3
)

set encoding=utf-8
"%PACKAGEPATH%FAKE\tools\FAKE.exe" build.fsx %*

popd

Update BuildLib 0.3.3

Update BuildLib 0.3.3


REM   Copyright 2014 Bioinformatics Core, University of Michigan
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.
python %~dp0../jacquard/jacquard.py %*

Update jacquard.bat

Update jacquard.bat


berp.exe -g BerpGrammar\BerpGrammar.berp -t GeneratorTemplates\CSharp.razor -o ..\..\BerpGrammar\GrammarParser.cs

bin\Debug\net471\berp.exe -g BerpGrammar\BerpGrammar.berp -t GeneratorTemplates\CSharp.razor -o BerpGrammar\GrammarParser.cs

fix self-build script

fix self-build script


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

:: This batch file will try to sync the root directory.

setlocal

:: Windows freaks out if a file is overwritten while it's being executed.  Copy
:: this script off to a temporary location and reinvoke from there before
:: running any git commands.
IF "%~nx0"=="update_depot_tools.bat" (
  COPY /Y "%~dp0update_depot_tools.bat" "%TEMP%\update_depot_tools_tmp.bat" >nul
  if errorlevel 1 goto :EOF
  "%TEMP%\update_depot_tools_tmp.bat" "%~dp0" %*
)

set DEPOT_TOOLS_DIR=%~1
SHIFT

:: Shall skip automatic update?
IF EXIST "%DEPOT_TOOLS_DIR%.disable_auto_update" GOTO :EOF
IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF

set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git

:: Download git for the first time if it's not present.
call git --version > nul 2>&1
if %errorlevel% == 0 goto :GIT_UPDATE
call "%DEPOT_TOOLS_DIR%bootstrap\win_tools.bat"
if errorlevel 1 (
  echo Error updating depot_tools, no revision tool found.
  goto :EOF
)

:GIT_UPDATE
:: Now clear errorlevel so it can be set by other programs later.
set errorlevel=

cd /d "%DEPOT_TOOLS_DIR%."
call git config remote.origin.fetch > NUL
for /F %%x in ('git config --get remote.origin.url') DO (
  IF not "%%x" == "%GIT_URL%" (
    echo Your depot_tools checkout is configured to fetch from an obsolete URL
    choice /N /T 60 /D N /M "Would you like to update it? [y/N]: "
    IF not errorlevel 2 (
      call git config remote.origin.url "%GIT_URL%"
    )
  )
)
call git fetch -q origin > NUL
call git checkout -q origin/master > NUL
if errorlevel 1 (
  echo Failed to update depot_tools.
  goto :EOF
)

:: Sync CIPD and CIPD client tools.
call "%~dp0\cipd_bin_setup.bat"

:: Update git and python
call "%DEPOT_TOOLS_DIR%bootstrap\win_tools.bat"

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

:: This batch file will try to sync the root directory.

setlocal

:: Windows freaks out if a file is overwritten while it's being executed.  Copy
:: this script off to a temporary location and reinvoke from there before
:: running any git commands.
IF "%~nx0"=="update_depot_tools.bat" (
  COPY /Y "%~dp0update_depot_tools.bat" "%TEMP%\update_depot_tools_tmp.bat" >nul
  if errorlevel 1 goto :EOF
  REM Use call/exit to avoid leaving an orphaned window title.
  call "%TEMP%\update_depot_tools_tmp.bat" "%~dp0" %*
  exit /b
)

set DEPOT_TOOLS_DIR=%~1
SHIFT

:: Shall skip automatic update?
IF EXIST "%DEPOT_TOOLS_DIR%.disable_auto_update" GOTO :EOF
IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF

set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git

:: Download git for the first time if it's not present.
call git --version > nul 2>&1
if %errorlevel% == 0 goto :GIT_UPDATE
call "%DEPOT_TOOLS_DIR%bootstrap\win_tools.bat"
if errorlevel 1 (
  echo Error updating depot_tools, no revision tool found.
  goto :EOF
)

:GIT_UPDATE
:: Now clear errorlevel so it can be set by other programs later.
set errorlevel=

cd /d "%DEPOT_TOOLS_DIR%."
call git config remote.origin.fetch > NUL
for /F %%x in ('git config --get remote.origin.url') DO (
  IF not "%%x" == "%GIT_URL%" (
    echo Your depot_tools checkout is configured to fetch from an obsolete URL
    choice /N /T 60 /D N /M "Would you like to update it? [y/N]: "
    IF not errorlevel 2 (
      call git config remote.origin.url "%GIT_URL%"
    )
  )
)
call git fetch -q origin > NUL
call git checkout -q origin/master > NUL
if errorlevel 1 (
  echo Failed to update depot_tools.
  goto :EOF
)

:: Sync CIPD and CIPD client tools.
call "%~dp0\cipd_bin_setup.bat"

:: Update git and python
call "%DEPOT_TOOLS_DIR%bootstrap\win_tools.bat"

Fix command prompt title after update_depot_tools

Windows has a bug where it sometimes doesn't reset the command prompt
title when a batch file finishes executing. A simple repro is shown
here:

b1.bat:
echo In b1
if 1 == 1 (
  b2.bat
)

b2.bat:
echo In b2

If you run b1.bat then "b1" will stay as the title when the batch files
finish running. The solution is to use "call" followed by "exit".

This bug is particularly annoying when using tabs in the new Windows
Terminal. By working around the bug this makes it so that the tab titles
return to being useful indicators of when a batch file is completed.

A previous fix of this bug (in a different batch file) can be seen in
crrev.com/c/2133303.

Change-Id: Id563f3102751a91f46c5b25ce610af9ec7ab240a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2225340
Reviewed-by: Edward Lesmes <d05609f027dc667cc37492b1dc1bdea5d60fa82a@chromium.org>
Commit-Queue: Bruce Dawson <fe9e26f3989304bf7275ed139c57fd059c63d22d@chromium.org>


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

:default_value_python:
set pythonexe="c:\Python36_x64\python"
:custom_python:
%pythonexe% -u setup.py build_script
if %errorlevel% neq 0 exit /b %errorlevel%

@echo off
if "%1"=="" goto default_value_python:
set pythonexe="%1"
%pythonexe% setup.py write_version
goto custom_python:

:default_value_python:
set pythonexe="c:\Python363_x64\python"
if not exist %pythonexe% set pythonexe="c:\Python36_x64\python"
:custom_python:
@echo [python] %pythonexe%
%pythonexe% -u setup.py build_script
if %errorlevel% neq 0 exit /b %errorlevel%

update script

update script


Fix .bat

Fix .bat


echo OFF

set UPLOAD_TARGETS=python-parse python-pkgtk

if "%ANACONDA_USERNAME%" == "" (
  set /p ANACONDA_USERNAME="Username: "
) else (
  echo Username: %ANACONDA_USERNAME%;
)

if "%ANACONDA_PASSWORD%" == "" (
  set /p ANACONDA_USERNAME=%ANACONDA_USERNAME%%"'s password: "
) else (
  echo %ANACONDA_USERNAME%'s password: [secure];
)

set ANACONDA_UPLOAD_FLAGS=-c conda-forge %ANACONDA_UPLOAD_FLAGS%
if "%ANACONDA_CHANNEL%" == "" (
    set ANACONDA_CHANNEL=statiskit
) else (
    echo Using anaconda channel: %ANACONDA_CHANNEL%
    set ANACONDA_UPLOAD_FLAGS=-c statiskit "%ANACONDA_UPLOAD_FLAGS%
)

echo ON

conda install -n root anaconda-client
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo OFF

echo y|anaconda login --username %ANACONDA_USERNAME% --password %ANACONDA_PASSWORD%
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo ON

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
if %errorlevel% neq 0 (
  anaconda logout
  exit /b %errorlevel%
)
cd toolchain
call config.bat
if %errorlevel% neq 0 (
  cd ..
  anaconda logout
  rmdir toolchain /s /q
  exit /b %errorlevel%
)
cd ..
rmdir toolchain /s /q

for %%x in (%UPLOAD_TARGETS%) do (
  set UPLOAD_TARGET=%%x
  for /f %%i in ('conda build %UPLOAD_TARGET% -c %ANACONDA_CHANNEL% %ANACONDA_UPLOAD_FLAGS% --output') do (set UPLOAD_FILE=%%i)
)

anaconda logout

echo OFF

set UPLOAD_TARGETS=python-parse python-pkgtk

if "%ANACONDA_USERNAME%" == "" (
  set /p ANACONDA_USERNAME="Username: "
) else (
  echo Username: %ANACONDA_USERNAME%;
)

if "%ANACONDA_PASSWORD%" == "" (
  set /p ANACONDA_USERNAME=%ANACONDA_USERNAME%%"'s password: "
) else (
  echo %ANACONDA_USERNAME%'s password: [secure];
)

set ANACONDA_UPLOAD_FLAGS=-c conda-forge %ANACONDA_UPLOAD_FLAGS%
if "%ANACONDA_CHANNEL%" == "" (
    set ANACONDA_CHANNEL=statiskit
) else (
    echo Using anaconda channel: %ANACONDA_CHANNEL%
    set ANACONDA_UPLOAD_FLAGS=-c statiskit "%ANACONDA_UPLOAD_FLAGS%
)

echo ON

conda install -n root anaconda-client
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo OFF

echo y|anaconda login --username %ANACONDA_USERNAME% --password %ANACONDA_PASSWORD%
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo ON

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
if %errorlevel% neq 0 (
  anaconda logout
  exit /b %errorlevel%
)
cd toolchain
call config.bat
if %errorlevel% neq 0 (
  cd ..
  anaconda logout
  rmdir toolchain /s /q
  exit /b %errorlevel%
)
cd ..
rmdir toolchain /s /q

for %%x in (%UPLOAD_TARGETS%) do (
  set UPLOAD_TARGET=%%x
  for /f %%i in ('conda build '%UPLOAD_TARGET%' -c '%ANACONDA_CHANNEL%' '%ANACONDA_UPLOAD_FLAGS%' --output') do (set UPLOAD_FILE=%%i)
)

anaconda logout

Update upload.bat

Update upload.bat


@echo off
rem setup INCLUDE and LIB environment variables
set OPENSSL_DIR=d:\dev\openssl_static
set OPENSSL_LIB=%OPENSSL_DIR%\lib
set OPENSSL_INCLUDE=%OPENSSL_DIR%\include
set LIB=%CD%\3rdparty\icu\lib;%OPENSSL_LIB%;%LIB%
set INCLUDE=%CD%\3rdparty\icu\include;%OPENSSL_INCLUDE%;%INCLUDE%

cd qtbase

set QT_CONFIG=

set QT_CONFIG=%QT_CONFIG% -debug
set QT_CONFIG=%QT_CONFIG% -static
set QT_CONFIG=%QT_CONFIG% -opensource
set QT_CONFIG=%QT_CONFIG% -nomake tests
set QT_CONFIG=%QT_CONFIG% -nomake examples
set QT_CONFIG=%QT_CONFIG% -mp
set QT_CONFIG=%QT_CONFIG% -no-cetest
set QT_CONFIG=%QT_CONFIG% -no-iwmmxt
set QT_CONFIG=%QT_CONFIG% -no-vcproj
set QT_CONFIG=%QT_CONFIG% -no-angle
set QT_CONFIG=%QT_CONFIG% -no-opengl
set QT_CONFIG=%QT_CONFIG% -icu
set QT_CONFIG=%QT_CONFIG% -qt-zlib
set QT_CONFIG=%QT_CONFIG% -qt-libpng
set QT_CONFIG=%QT_CONFIG% -qt-libjpeg
set QT_CONFIG=%QT_CONFIG% -openssl-linked
set QT_CONFIG=%QT_CONFIG% -platform win32-msvc2010

set MAKE_TOOL=nmake

configure %QT_CONFIG%

call %MAKE_TOOL%

cd ..

@echo off
SETLOCAL EnableExtensions EnableDelayedExpansion

set BUILD_TYPE=release
if /i "%1" == "debug" (
    SET BUILD_TYPE=debug
)

echo:
echo Build type: %BUILD_TYPE%

:: setup INCLUDE and LIB environment variables
:: OpenSSL
set OPENSSL_DIR=d:\dev\openssl_static
set OPENSSL_LIB=%OPENSSL_DIR%\lib
set OPENSSL_INCLUDE=%OPENSSL_DIR%\include

:: ICU
set ICU_DIR=d:\Source\libicu
set ICU_LIB=%OPENSSL_DIR%\lib
set ICU_INCLUDE=%OPENSSL_DIR%\include

:: libxml
set LIBXML_DIR=d:\dev\libxml_build
set LIBXML_LIB=%LIBXML_DIR%\lib\
set LIBXML_INCLUDE=%LIBXML_DIR%\include\libxml2\

set LIB=%OPENSSL_LIB%;%ICU_LIB%;%LIBXML_LIB%;%LIB%
set INCLUDE=%OPENSSL_INCLUDE%;%ICU_INCLUDE%;%LIBXML_DIR%;%INCLUDE%

:: Build Qt5
cd qtbase

set QT_CONFIG=

set QT_CONFIG=%QT_CONFIG% -%BUILD_TYPE%
set QT_CONFIG=%QT_CONFIG% -static
set QT_CONFIG=%QT_CONFIG% -opensource
set QT_CONFIG=%QT_CONFIG% -nomake tests
set QT_CONFIG=%QT_CONFIG% -nomake examples
set QT_CONFIG=%QT_CONFIG% -mp
set QT_CONFIG=%QT_CONFIG% -no-cetest
set QT_CONFIG=%QT_CONFIG% -no-iwmmxt
set QT_CONFIG=%QT_CONFIG% -no-vcproj
set QT_CONFIG=%QT_CONFIG% -no-angle
set QT_CONFIG=%QT_CONFIG% -no-opengl
set QT_CONFIG=%QT_CONFIG% -icu
set QT_CONFIG=%QT_CONFIG% -qt-zlib
set QT_CONFIG=%QT_CONFIG% -qt-libpng
set QT_CONFIG=%QT_CONFIG% -qt-libjpeg
set QT_CONFIG=%QT_CONFIG% -openssl-linked
set QT_CONFIG=%QT_CONFIG% -platform win32-msvc2010

:: Build information
echo:
echo LIB: %LIB%
echo INCLUDE: %INCLUDE%
echo QT_CONFIG: %QT_CONFIG%

:: set MAKE_TOOL=jom
set MAKE_TOOL=nmake

configure %QT_CONFIG%

call %MAKE_TOOL%

cd ..

Update preconfig.cmd

Update preconfig.cmd


::..............................................................................
::
::  This file is part of the Doxyrest toolkit.
::
::  Doxyrest is distributed under the MIT license.
::  For details see accompanying license.txt file,
::  the public copy of which is also available at:
::  http://tibbo.com/downloads/archive/doxyrest/license.txt
::
::..............................................................................

@echo off

set DOWNLOAD_DIR=c:\downloads
set DOWNLOAD_DIR_CMAKE=%DOWNLOAD_DIR:\=/%

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Ragel

mkdir %DOWNLOAD_DIR%\ragel
appveyor DownloadFile %RAGEL_DOWNLOAD_URL% -FileName %DOWNLOAD_DIR%\ragel\%RAGEL_DOWNLOAD_FILE%
7z e -y %DOWNLOAD_DIR%\ragel\%RAGEL_DOWNLOAD_FILE% -o%DOWNLOAD_DIR%\ragel

echo set (RAGEL_EXE %DOWNLOAD_DIR_CMAKE%/ragel/ragel.exe) >> paths.cmake

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Lua

mkdir %DOWNLOAD_DIR%\lua
appveyor DownloadFile %LUA_DOWNLOAD_URL% -FileName %DOWNLOAD_DIR%\lua\%LUA_DOWNLOAD_FILE%
7z x -y %DOWNLOAD_DIR%\lua\%LUA_DOWNLOAD_FILE% -o%DOWNLOAD_DIR%\lua

echo set (LUA_INC_DIR %DOWNLOAD_DIR_CMAKE%/lua/include) >> paths.cmake
echo set (LUA_LIB_DIR %DOWNLOAD_DIR_CMAKE%/lua) >> paths.cmake
echo set (LUA_LIB_NAME %LUA_LIB_NAME%) >> paths.cmake

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Expat

appveyor DownloadFile %EXPAT_DOWNLOAD_URL% -FileName %DOWNLOAD_DIR%\%EXPAT_DOWNLOAD_FILE%
7z x -y %DOWNLOAD_DIR%\%EXPAT_DOWNLOAD_FILE% -o%DOWNLOAD_DIR%
7z x -y %DOWNLOAD_DIR%\expat-%EXPAT_VERSION%.tar -o%DOWNLOAD_DIR%
ren %DOWNLOAD_DIR%\expat-%EXPAT_VERSION% expat

:: patch CMakeLists.txt /MD => /MT

copy ci\appveyor\md-to-mt.cmake %DOWNLOAD_DIR%\expat
echo include (md-to-mt.cmake) >> %DOWNLOAD_DIR%\expat\CMakeLists.txt

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Get rid of Xamarin annoying build warnings

del "c:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
del "c:\Program Files (x86)\MSBuild\4.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"

::..............................................................................
::
::  This file is part of the Doxyrest toolkit.
::
::  Doxyrest is distributed under the MIT license.
::  For details see accompanying license.txt file,
::  the public copy of which is also available at:
::  http://tibbo.com/downloads/archive/doxyrest/license.txt
::
::..............................................................................

@echo off

set DOWNLOAD_DIR=c:\downloads
set DOWNLOAD_DIR_CMAKE=%DOWNLOAD_DIR:\=/%

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Ragel

mkdir %DOWNLOAD_DIR%\ragel
appveyor DownloadFile %RAGEL_DOWNLOAD_URL% -FileName %DOWNLOAD_DIR%\ragel\%RAGEL_DOWNLOAD_FILE%
7z e -y %DOWNLOAD_DIR%\ragel\%RAGEL_DOWNLOAD_FILE% -o%DOWNLOAD_DIR%\ragel

echo set (RAGEL_EXE %DOWNLOAD_DIR_CMAKE%/ragel/ragel.exe) >> paths.cmake

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Lua

mkdir %DOWNLOAD_DIR%\lua
appveyor DownloadFile %LUA_DOWNLOAD_URL% -FileName %DOWNLOAD_DIR%\lua\%LUA_DOWNLOAD_FILE%
7z x -y %DOWNLOAD_DIR%\lua\%LUA_DOWNLOAD_FILE% -o%DOWNLOAD_DIR%\lua

echo set (LUA_INC_DIR %DOWNLOAD_DIR_CMAKE%/lua/include) >> paths.cmake
echo set (LUA_LIB_DIR %DOWNLOAD_DIR_CMAKE%/lua) >> paths.cmake
echo set (LUA_LIB_NAME %LUA_LIB_NAME%) >> paths.cmake

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Expat

appveyor DownloadFile %EXPAT_DOWNLOAD_URL% -FileName %DOWNLOAD_DIR%\%EXPAT_DOWNLOAD_FILE%
7z x -y %DOWNLOAD_DIR%\%EXPAT_DOWNLOAD_FILE% -o%DOWNLOAD_DIR%
7z x -y %DOWNLOAD_DIR%\expat-%EXPAT_VERSION%.tar -o%DOWNLOAD_DIR%
ren %DOWNLOAD_DIR%\expat-%EXPAT_VERSION% expat

:: patch CMakeLists.txt /MD => /MT

copy %~dp0\md-to-mt.cmake %DOWNLOAD_DIR%\expat
echo include (md-to-mt.cmake) >> %DOWNLOAD_DIR%\expat\CMakeLists.txt

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:: Get rid of Xamarin annoying build warnings

del "c:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
del "c:\Program Files (x86)\MSBuild\4.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"

[appveyor] use %~dp0 to get the current script dir (ci/appveyor)

otherwise, it won't work when called from the bundle-repo


@echo off

:: Go to directory containing batch file
FOR /f %%i in ("%0") DO SET curpath=%%~dpi
CD /d %curpath%

:: Flags to determine which parts will be executed
SET doDev=0
SET doSelendroid=0
SET doAndroid=0
SET doVerbose=0
SET doForce=0
SET pigsFly=0

:: Read in command line switches
FOR %%A IN (%*) DO IF "%%A" == "--dev" SET doDev=1
FOR %%A IN (%*) DO IF "%%A" == "--android" SET doAndroid=1
FOR %%A IN (%*) DO IF "%%A" == "--selendroid" SET doSelendroid=1
FOR %%A IN (%*) DO IF "%%A" == "--verbose" SET doVerbose=1
FOR %%A IN (%*) DO IF "%%A" == "--force" SET doForce=1

:: If nothing is flagged do only android
IF %doDev% == 0 IF %doSelendroid% == 0 IF %doAndroid% == 0 SET doAndroid=1

:: Install Package and Dependencies
ECHO.
ECHO =====Installing dependencies with npm=====
ECHO.
CALL :runCmd "npm install ."

:: Install Dev Dependencies
if %doDev% == 1 (
  ECHO.
  ECHO =====Installing development dependencies with npm=====
  ECHO.
  CALL :runCmd "npm install . --dev"
  ECHO.
)

:: Reset Android
if %doAndroid% == 1 (
  ECHO.
  ECHO =====Resetting Android=====
  ECHO.
  CALL :runCmd "node_modules\.bin\grunt configAndroidBootstrap"
  CALL :runCmd "node_modules\.bin\grunt buildAndroidBootstrap"
  CALL :runCmd "node_modules\.bin\grunt setConfigVer:android"
  ECHO.
  ECHO =====Reset Android Complete=====

  ECHO.
  ECHO =====Resetting Unlock.apk=====
  ECHO.
  CALL :runCmd "RD /S /Q build\unlock_apk"
  CALL :runCmd "MKDIR build\unlock_apk"
  ECHO Building Unlock.apk
  CALL :runCmd "git submodule update --init submodules\unlock_apk"
  CALL :runCmd "PUSHD submodules\unlock_apk"
  CALL :runCmd "ant clean"
  CALL :runCmd "ant debug"
  CALL :runCmd "POPD"
  CALL :runCmd "COPY submodules\unlock_apk\bin\unlock_apk-debug.apk build\unlock_apk\unlock_apk-debug.apk"
  ECHO.
  ECHO =====Reset Unlock.apk Complete=====

  :: Reset Android Dev
  IF %doDev% == 1 (
    ECHO.
    ECHO =====Resetting API Demos=====
    ECHO.
    ECHO Cloning/updating Android test app: ApiDemos
    CALL :runCmd "git submodule update --init submodules\ApiDemos"
    CALL :runCmd "RD /S /Q sample-code\apps\ApiDemos | VER > NUL"
    CALL :runCmd "MKDIR sample-code\apps\ApiDemos"
    CALL :runCmd "XCOPY submodules\ApiDemos sample-code\apps\ApiDemos /E /Q"
    CALL :runCmd "node_modules\.bin\grunt configAndroidApp:ApiDemos"
    CALL :runCmd "node_modules\.bin\grunt buildAndroidApp:ApiDemos"
    ECHO.
    ECHO =====Reset API Demos Complete=====
  )
)

:: Reset Selendroid
IF %doSelendroid% == 1 (
  ECHO.
  ECHO =====Resetting Selendroid=====
  ECHO.
  ECHO Clearing out any old modified server apks
  CALL :runCmd "RD -/S /Q %windir%\Temp\selendroid*.apk | VER > NUL"
  ECHO Cloning/updating selendroid
  CALL :runCmd "RD -/S /Q submodules\selendroid\selendroid-server\target | VER > NUL"
  CALL :runCmd "git submodule update --init submodules\selendroid"
  CALL :runCmd "RD /S /Q selendroid | VER > NUL"
  ECHO Building selendroid server and supporting libraries
  CALL :runCmd "set MAVEN_OPTS=-Xss1024k"
  CALL :runCmd "node_modules\.bin\grunt buildSelendroidServer"
  CALL :runCmd "set MAVEN_OPTS="

  :: Reset Selendroid Dev
  IF %doDev% == 1 (
    ECHO.
    ECHO =====Resetting Selendroid - Dev=====
    ECHO.
    ECHO Linking selendroid test app: WebViewDemo
    CALL :runCmd "RD /S /Q sample-code\apps\WebViewDemo | VER > NUL"
    CALL :runCmd "MKDIR sample-code\apps\WebViewDemo"
    CALL :runCmd "XCOPY submodules\selendroid\selendroid-test-app sample-code\apps\WebViewDemo /E /Q"
    CALL :uninstallAndroidApp com.example.android.apis.selendroid
    CALL :uninstallAndroidApp io.selendroid.testapp
    CALL :uninstallAndroidApp io.selendroid.testapp.selendroid
    CALL :uninstallAndroidApp org.openqa.selendroid.testapp
    CALL :uninstallAndroidApp openqa.selendroid.testapp.selendroid
    ECHO.
    ECHO =====Reset Selendroid - Dev Complete=====
  )

  ECHO Setting Selendroid config to Appium's version
  CALL :runCmd "node_modules\.bin\grunt setConfigVer:selendroid"
  ECHO.
  ECHO =====Reset Selendroid Complete=====
)
:: Reset Gappium
IF %pigsFly% == 1 (
  ECHO.
  ECHO =====Resetting Gappium=====
  ECHO.
  ECHO Clearing out old links
  CALL :runCmd "RD /S /Q sample-code\apps\io.appium.gappium.sampleapp | VER > NUL"
  ECHO Cloning/updating Gappium
  CALL :runCmd "git submodule update --init submodules\io.appium.gappium.sampleapp"
  CALL :runCmd "PUSHD submodules\io.appium.gappium.sampleapp"
  ECHO Building Gappium test app
  CALL :runCmd "reset.bat"
  CALL :runCmd "POPD"
  ECHO Linking Gappium test app
  CALL :runCmd "XCOPY submodules\io.appium.gappium.sampleapp sample-code\apps\io.appium.gappium.sampleapp /E /Q"
  ECHO.
  ECHO =====Reset Gappium=====
)
GOTO :EOF

:: Function to uninstall an Android app
:uninstallAndroidApp
  ECHO Attempting to uninstall android app %~1
  CALL :runCmd "adb uninstall %~1 | VER > NUL"
GOTO :EOF

:: Function to run commands
:runCmd - function to run a command
  IF %doVerbose% == 1 ECHO %~1
  CALL %~1
  IF %ERRORLEVEL% NEQ 0 IF %doForce% == 0 (
    CD /D %curpath%
    ECHO.
    ECHO Stopping because there was an error and --force was not used
    CALL :halt 1
  )
GOTO :EOF

:: Sets the errorlevel and stops the batch immediately
:halt
CALL :__SetErrorLevel %1
CALL :__ErrorExit 2> NUL
GOTO :EOF

:__ErrorExit
REM Creates a syntax error, stops immediately
()
GOTO :EOF

:__SetErrorLevel
EXIT /B %TIME:~-2%
GOTO :EOF

@echo off

:: Go to directory containing batch file
FOR /f %%i in ("%0") DO SET curpath=%%~dpi
CD /d %curpath%

:: Flags to determine which parts will be executed
SET doDev=0
SET doSelendroid=0
SET doAndroid=0
SET doVerbose=0
SET doForce=0
SET pigsFly=0

:: Read in command line switches
FOR %%A IN (%*) DO IF "%%A" == "--dev" SET doDev=1
FOR %%A IN (%*) DO IF "%%A" == "--android" SET doAndroid=1
FOR %%A IN (%*) DO IF "%%A" == "--selendroid" SET doSelendroid=1
FOR %%A IN (%*) DO IF "%%A" == "--verbose" SET doVerbose=1
FOR %%A IN (%*) DO IF "%%A" == "--force" SET doForce=1

:: If nothing is flagged do only android
IF %doDev% == 0 IF %doSelendroid% == 0 IF %doAndroid% == 0 SET doAndroid=1

:: Install Package and Dependencies
ECHO.
ECHO =====Installing dependencies with npm=====
ECHO.
CALL :runCmd "npm install ."

:: Install Dev Dependencies
if %doDev% == 1 (
  ECHO.
  ECHO =====Installing development dependencies with npm=====
  ECHO.
  CALL :runCmd "npm install . --dev"
  ECHO.
)

:: Reset Android
if %doAndroid% == 1 (
  ECHO.
  ECHO =====Resetting Android=====
  ECHO.
  CALL :runCmd "node_modules\.bin\grunt configAndroidBootstrap"
  CALL :runCmd "node_modules\.bin\grunt buildAndroidBootstrap"
  CALL :runCmd "node_modules\.bin\grunt setConfigVer:android"
  ECHO.
  ECHO =====Reset Android Complete=====

  ECHO.
  ECHO =====Resetting Unlock.apk=====
  ECHO.
  CALL :runCmd "RD /S /Q build\unlock_apk | VER > NUL"
  CALL :runCmd "MKDIR build\unlock_apk"
  ECHO Building Unlock.apk
  CALL :runCmd "git submodule update --init submodules\unlock_apk"
  CALL :runCmd "PUSHD submodules\unlock_apk"
  CALL :runCmd "ant clean"
  CALL :runCmd "ant debug"
  CALL :runCmd "POPD"
  CALL :runCmd "COPY submodules\unlock_apk\bin\unlock_apk-debug.apk build\unlock_apk\unlock_apk-debug.apk"
  ECHO.
  ECHO =====Reset Unlock.apk Complete=====

  :: Reset Android Dev
  IF %doDev% == 1 (
    ECHO.
    ECHO =====Resetting API Demos=====
    ECHO.
    ECHO Cloning/updating Android test app: ApiDemos
    CALL :runCmd "git submodule update --init submodules\ApiDemos"
    CALL :runCmd "RD /S /Q sample-code\apps\ApiDemos | VER > NUL"
    CALL :runCmd "MKDIR sample-code\apps\ApiDemos"
    CALL :runCmd "XCOPY submodules\ApiDemos sample-code\apps\ApiDemos /E /Q"
    CALL :runCmd "node_modules\.bin\grunt configAndroidApp:ApiDemos"
    CALL :runCmd "node_modules\.bin\grunt buildAndroidApp:ApiDemos"
    ECHO.
    ECHO =====Reset API Demos Complete=====
  )
)

:: Reset Selendroid
IF %doSelendroid% == 1 (
  ECHO.
  ECHO =====Resetting Selendroid=====
  ECHO.
  ECHO Clearing out any old modified server apks
  CALL :runCmd "RD -/S /Q %windir%\Temp\selendroid*.apk | VER > NUL"
  ECHO Cloning/updating selendroid
  CALL :runCmd "RD -/S /Q submodules\selendroid\selendroid-server\target | VER > NUL"
  CALL :runCmd "git submodule update --init submodules\selendroid"
  CALL :runCmd "RD /S /Q selendroid | VER > NUL"
  ECHO Building selendroid server and supporting libraries
  CALL :runCmd "set MAVEN_OPTS=-Xss1024k"
  CALL :runCmd "node_modules\.bin\grunt buildSelendroidServer"
  CALL :runCmd "set MAVEN_OPTS="

  :: Reset Selendroid Dev
  IF %doDev% == 1 (
    ECHO.
    ECHO =====Resetting Selendroid - Dev=====
    ECHO.
    ECHO Linking selendroid test app: WebViewDemo
    CALL :runCmd "RD /S /Q sample-code\apps\WebViewDemo | VER > NUL"
    CALL :runCmd "MKDIR sample-code\apps\WebViewDemo"
    CALL :runCmd "XCOPY submodules\selendroid\selendroid-test-app sample-code\apps\WebViewDemo /E /Q"
    CALL :uninstallAndroidApp com.example.android.apis.selendroid
    CALL :uninstallAndroidApp io.selendroid.testapp
    CALL :uninstallAndroidApp io.selendroid.testapp.selendroid
    CALL :uninstallAndroidApp org.openqa.selendroid.testapp
    CALL :uninstallAndroidApp openqa.selendroid.testapp.selendroid
    ECHO.
    ECHO =====Reset Selendroid - Dev Complete=====
  )

  ECHO Setting Selendroid config to Appium's version
  CALL :runCmd "node_modules\.bin\grunt setConfigVer:selendroid"
  ECHO.
  ECHO =====Reset Selendroid Complete=====
)
:: Reset Gappium
IF %pigsFly% == 1 (
  ECHO.
  ECHO =====Resetting Gappium=====
  ECHO.
  ECHO Clearing out old links
  CALL :runCmd "RD /S /Q sample-code\apps\io.appium.gappium.sampleapp | VER > NUL"
  ECHO Cloning/updating Gappium
  CALL :runCmd "git submodule update --init submodules\io.appium.gappium.sampleapp"
  CALL :runCmd "PUSHD submodules\io.appium.gappium.sampleapp"
  ECHO Building Gappium test app
  CALL :runCmd "reset.bat"
  CALL :runCmd "POPD"
  ECHO Linking Gappium test app
  CALL :runCmd "XCOPY submodules\io.appium.gappium.sampleapp sample-code\apps\io.appium.gappium.sampleapp /E /Q"
  ECHO.
  ECHO =====Reset Gappium=====
)
GOTO :EOF

:: Function to uninstall an Android app
:uninstallAndroidApp
  ECHO Attempting to uninstall android app %~1
  CALL :runCmd "adb uninstall %~1 | VER > NUL"
GOTO :EOF

:: Function to run commands
:runCmd - function to run a command
  IF %doVerbose% == 1 ECHO %~1
  CALL %~1
  IF %ERRORLEVEL% NEQ 0 IF %doForce% == 0 (
    CD /D %curpath%
    ECHO.
    ECHO Stopping because there was an error and --force was not used
    CALL :halt 1
  )
GOTO :EOF

:: Sets the errorlevel and stops the batch immediately
:halt
CALL :__SetErrorLevel %1
CALL :__ErrorExit 2> NUL
GOTO :EOF

:__ErrorExit
REM Creates a syntax error, stops immediately
()
GOTO :EOF

:__SetErrorLevel
EXIT /B %TIME:~-2%
GOTO :EOF

Fix for #1364

Fix for #1364