@echo off

setLocal EnableExtensions EnableDelayedExpansion

set LEIN_VERSION=2.3.3

if "%LEIN_VERSION:~-9%" == "-SNAPSHOT" (
    set SNAPSHOT=YES
) else (
    set SNAPSHOT=NO
)

set ORIGINAL_PWD=%CD%
:: If ORIGINAL_PWD ends with a backslash (such as C:\),
:: we need to escape it with a second backslash.
if "%ORIGINAL_PWD:~-1%x" == "\x" set "ORIGINAL_PWD=%ORIGINAL_PWD%\"

call :FIND_DIR_CONTAINING_UPWARDS project.clj
if "%DIR_CONTAINING%" neq "" cd "%DIR_CONTAINING%"

:: LEIN_JAR and LEIN_HOME variables can be set manually.

if "x%LEIN_HOME%" == "x" (
    set LEIN_HOME=!USERPROFILE!\.lein
)

if "x%LEIN_JAR%" == "x" set "LEIN_JAR=!LEIN_HOME!\self-installs\leiningen-!LEIN_VERSION!-standalone.jar"

if "%1" == "self-install" goto SELF_INSTALL
if "%1" == "upgrade"      goto UPGRADE
if "%1" == "downgrade"    goto UPGRADE

if exist "%~dp0..\src\leiningen\version.clj" (
    :: Running from source checkout.
    call :SET_LEIN_ROOT "%~dp0.."

	set bootstrapfile="!LEIN_ROOT!\leiningen-core\.lein-bootstrap"
	rem in .lein-bootstrap there is only one line where each path is concatenated to each other via a semicolon, there's no semicolon at the end
	rem each path is NOT inside double quotes and may contain spaces (even semicolons but this is not supported here) in their names,
	rem  but they won't/cannot contain double quotes " or colons :  in their names (at least on windows it's not allowed/won't work)

	rem tested when folders contain spaces and when LEIN_ROOT contains semicolon

	if not "x%DEBUG%" == "x" echo LEIN_ROOT=!LEIN_ROOT!

	rem if not "%LEIN_ROOT:;=%" == "%LEIN_ROOT%" (

	rem oddly enough /G:/ should've worked but doesn't where / they say it's console
	rem findstr is C:\Windows\System32\findstr.exe
	echo !LEIN_ROOT! | findstr /C:";" /G:con >nul
	if not errorlevel 1 ( rem aka errorlevel is 0 aka the string ";" was found
		echo Your folder structure !LEIN_ROOT! contains at least one semicolon in its name
		echo This is not allowed and would break things with the generated bootstrap file
		echo Please correct this by renaming the folders to not contain semicolons in their name
		del !bootstrapfile! >nul 2>&1
		echo You'll also have to recreate the bootstrap file just to be sure it has semicolon-free names inside
		echo the bootstrap file^(which was just deleted^) is: !bootstrapfile!
		echo  and the info on how to do that is:
		goto :RUN_BOOTSTRAP
	)

	if not exist !bootstrapfile! goto NO_DEPENDENCIES

	findstr /C:^"\^"^" !bootstrapfile! >nul
	if not errorlevel 1 (
		set hasAtLeastOneDoubleQuote=1
	) ELSE (
		set hasAtLeastOneDoubleQuote=0
	)

	if !hasAtLeastOneDoubleQuote! == 1 (
		echo double quotes detected inside file: !bootstrapfile!
		echo this should not be happening
		goto :RUN_BOOTSTRAP
	)

rem will proceed to set LEIN_LIBS and surround each path from bootstrap file in double quotes and separate it from others with a semicolon
rem the paths inside the bootstrap file do not already contain double quotes but may contain spaces
	rem note worthy: the following won't work due to a hard 1022bytes limit truncation in the variable that was set
	rem set /p LEIN_LIBS=<!bootstrapfile!
	rem so this will work instead:
	rem for /f "usebackq delims=" %%j in (!bootstrapfile!) do set LEIN_LIBS=%%j
	rem just  set LEIN_LIBS="%%j"  is uglier/hacky but would also work here instead of the below:
	for /f "usebackq delims=" %%j in (!bootstrapfile!) do (
		set tmpline=%%j
		call :processPath
	)

	if not "x%DEBUG%" == "x" echo LEIN_LIBS=!LEIN_LIBS!

    if "x!LEIN_LIBS!" == "x" goto NO_DEPENDENCIES

	rem CLASSPATH must contain each path element double quoted and separated by semicolons ie. "c:\some folder";"c:\some other folder";"c:\semicolons;;;;in;name;work okay"
	rem (no end semicolon required)
    set CLASSPATH=!LEIN_LIBS!;"!LEIN_ROOT!\src";"!LEIN_ROOT!\resources"

    :: Apply context specific CLASSPATH entries
    if exist "%~dp0..\.lein-classpath" (
        for /f %%i in ("%~dp0...lein-classpath") do set CONTEXT_CP=%%i

        if NOT "x!CONTEXT_CP!"=="x" (
            set CLASSPATH=!CONTEXT_CP!;!CLASSPATH!
        )
    )

) else (
    :: Not running from a checkout.
    if not exist "%LEIN_JAR%" goto NO_LEIN_JAR
    set CLASSPATH=%LEIN_JAR%

    if exist ".lein-classpath" (
        for /f %%i in (.lein-classpath) do set CONTEXT_CP=%%i

        if NOT "x!CONTEXT_CP!"=="x" (
            set CLASSPATH=!CONTEXT_CP!;!CLASSPATH!
        )
    )
)

if not "x%DEBUG%" == "x" echo CLASSPATH=!CLASSPATH!
:: ##################################################

if "x!JAVA_CMD!" == "x" set JAVA_CMD=java
if "x!LEIN_JAVA_CMD!" == "x" set LEIN_JAVA_CMD=%JAVA_CMD%

rem remove quotes from around java commands
for /f "usebackq delims=" %%i in ('!JAVA_CMD!') do set JAVA_CMD=%%~i
for /f "usebackq delims=" %%i in ('!LEIN_JAVA_CMD!') do set LEIN_JAVA_CMD=%%~i

if "x%JVM_OPTS%" == "x" set JVM_OPTS=%JAVA_OPTS%
goto RUN

:DownloadFile
rem parameters: TargetFileName Address
if NOT "x%HTTP_CLIENT%" == "x" (
    %HTTP_CLIENT% %1 %2
    goto EOF
)
wget >nul 2>&1
if NOT ERRORLEVEL 9009 (
    wget --no-check-certificate -O %1 %2
    goto EOF
)
curl >nul 2>&1
if NOT ERRORLEVEL 9009 (
    rem We set CURL_PROXY to a space character below to pose as a no-op argument
    set CURL_PROXY=
    if NOT "x%HTTPS_PROXY%" == "x" set CURL_PROXY="-x %HTTPS_PROXY%"
    curl %CURL_PROXY% --insecure -f -L -o  %1 %2
    goto EOF
)
powershell -? >nul 2>&1
if NOT ERRORLEVEL 9009 (
    powershell -Command "& {param($a,$f) (new-object System.Net.WebClient).DownloadFile($a, $f)}" ""%2"" ""%1""
    goto EOF
)
goto NO_HTTP_CLIENT

:NO_LEIN_JAR
echo.
echo %LEIN_JAR% can not be found.
echo You can try running "lein self-install"
echo or change LEIN_JAR environment variable
echo or edit lein.bat to set appropriate LEIN_JAR path.
echo.
goto EOF

:NO_DEPENDENCIES
echo.
echo Leiningen is missing its dependencies.
:RUN_BOOTSTRAP
echo Please run "lein bootstrap" in the leiningen-core/ directory
echo with a stable release of Leiningen. See CONTRIBUTING.md for details.
echo.
goto EOF

:SELF_INSTALL
if exist "%LEIN_JAR%" (
    echo %LEIN_JAR% already exists. Delete and retry.
    goto EOF
)

for %%f in ("%LEIN_JAR%") do set LEIN_INSTALL_DIR="%%~dpf"
if not exist %LEIN_INSTALL_DIR% mkdir %LEIN_INSTALL_DIR%

echo Downloading Leiningen now...

set LEIN_JAR_URL=https://leiningen.s3.amazonaws.com/downloads/leiningen-%LEIN_VERSION%-standalone.jar
call :DownloadFile "%LEIN_JAR%.pending" "%LEIN_JAR_URL%"
if ERRORLEVEL 1 (
    del "%LEIN_JAR%.pending" >nul 2>&1
    goto DOWNLOAD_FAILED
)
move /y "%LEIN_JAR%.pending" "%LEIN_JAR%"
goto EOF

:DOWNLOAD_FAILED
echo.
echo Failed to download %LEIN_JAR_URL%
if %SNAPSHOT% == YES echo See README.md for SNAPSHOT build instructions.
echo.
goto EOF

:UPGRADE
set LEIN_BAT=%~dp0%~nx0
set TARGET_VERSION=%2
if "x%2" == "x" set TARGET_VERSION=stable
echo The script at %LEIN_BAT% will be upgraded to the latest %TARGET_VERSION% version.
set /P ANSWER=Do you want to continue (Y/N)?
if /i {%ANSWER%}=={y}   goto YES_UPGRADE
if /i {%ANSWER%}=={yes} goto YES_UPGRADE
echo Aborted.
exit /B 1

:YES_UPGRADE
echo Downloading latest Leiningen batch script...

set LEIN_BAT_URL=https://github.com/technomancy/leiningen/raw/%TARGET_VERSION%/bin/lein.bat
set TEMP_BAT=%~dp0temp-lein-%RANDOM%%RANDOM%.bat
call :DownloadFile "%LEIN_BAT%.pending" "%LEIN_BAT_URL%"
if ERRORLEVEL 1 (
    del "%LEIN_BAT%.pending" >nul 2>&1
    echo Failed to download %LEIN_BAT_URL%
    goto EOF
)
move /y "%LEIN_BAT%.pending" "%TEMP_BAT%"
echo.
echo Upgrading...
set LEIN_JAR=
call "%TEMP_BAT%" self-install
move /y "%TEMP_BAT%" "%LEIN_BAT%" && goto EOF
goto EOF

:NO_HTTP_CLIENT
echo.
echo ERROR: Neither PowerShell, Wget, or Curl could be found.
echo        Make sure at least one of these tools is installed
echo        and is in PATH. You can get them from URLs below:
echo.
echo PowerShell: "http://www.microsoft.com/powershell"
echo Wget:       "http://users.ugent.be/~bpuype/wget/"
echo Curl:       "http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=2000/XP"
echo.
goto EOF

:SET_LEIN_ROOT
set LEIN_ROOT=%~f1
goto EOF

:: Find directory containing filename supplied in first argument
:: looking in current directory, and looking up the parent
:: chain until we find it, or run out
:: returns result in %DIR_CONTAINING%
:: empty string if we don't find it
:FIND_DIR_CONTAINING_UPWARDS
set DIR_CONTAINING=%CD%
set LAST_DIR=

:LOOK_AGAIN
if "%DIR_CONTAINING%" == "%LAST_DIR%" (
    :: didn't find it
    set DIR_CONTAINING=
    goto EOF
)

if EXIST "%DIR_CONTAINING%\%1" (
    :: found it - use result in DIR_CONTAINING
    goto EOF
)

set LAST_DIR=%DIR_CONTAINING%
call :GET_PARENT_PATH "%DIR_CONTAINING%\.."
set DIR_CONTAINING=%PARENT_PATH%
goto LOOK_AGAIN

:GET_PARENT_PATH
set PARENT_PATH=%~f1
goto EOF

:RUN
:: We need to disable delayed expansion here because the %* variable
:: may contain bangs (as in test!). There may also be special
:: characters inside the TRAMPOLINE_FILE.
setLocal DisableDelayedExpansion

set "TRAMPOLINE_FILE=%TEMP%\lein-trampoline-%RANDOM%.bat"
del "%TRAMPOLINE_FILE%" 2>nul

"%LEIN_JAVA_CMD%" -client %LEIN_JVM_OPTS% ^
 -Dclojure.compile.path="%DIR_CONTAINING%/target/classes" ^
 -Dleiningen.original.pwd="%ORIGINAL_PWD%" ^
 -cp "%CLASSPATH%" clojure.main -m leiningen.core.main %*

if not exist "%TRAMPOLINE_FILE%" goto EOF
call "%TRAMPOLINE_FILE%"
del "%TRAMPOLINE_FILE%"
goto EOF

rem this label must reside here outside of ( ) from the if block, otherwise the ELSE ( ) block is also executed
:processPath
rem will surround each path with double quotes before appending it to LEIN_LIBS
	for /f "tokens=1* delims=;" %%a in ("%tmpline%") do (
		set LEIN_LIBS=!LEIN_LIBS!"%%a";
		set tmpline=%%b
	)
	if not "%tmpline%" == "" goto :processPath
	goto :eof

:EOF

@echo off

setLocal EnableExtensions EnableDelayedExpansion

set LEIN_VERSION=2.3.4

if "%LEIN_VERSION:~-9%" == "-SNAPSHOT" (
    set SNAPSHOT=YES
) else (
    set SNAPSHOT=NO
)

set ORIGINAL_PWD=%CD%
:: If ORIGINAL_PWD ends with a backslash (such as C:\),
:: we need to escape it with a second backslash.
if "%ORIGINAL_PWD:~-1%x" == "\x" set "ORIGINAL_PWD=%ORIGINAL_PWD%\"

call :FIND_DIR_CONTAINING_UPWARDS project.clj
if "%DIR_CONTAINING%" neq "" cd "%DIR_CONTAINING%"

:: LEIN_JAR and LEIN_HOME variables can be set manually.

if "x%LEIN_HOME%" == "x" (
    set LEIN_HOME=!USERPROFILE!\.lein
)

if "x%LEIN_JAR%" == "x" set "LEIN_JAR=!LEIN_HOME!\self-installs\leiningen-!LEIN_VERSION!-standalone.jar"

if "%1" == "self-install" goto SELF_INSTALL
if "%1" == "upgrade"      goto UPGRADE
if "%1" == "downgrade"    goto UPGRADE

if exist "%~dp0..\src\leiningen\version.clj" (
    :: Running from source checkout.
    call :SET_LEIN_ROOT "%~dp0.."

	set bootstrapfile="!LEIN_ROOT!\leiningen-core\.lein-bootstrap"
	rem in .lein-bootstrap there is only one line where each path is concatenated to each other via a semicolon, there's no semicolon at the end
	rem each path is NOT inside double quotes and may contain spaces (even semicolons but this is not supported here) in their names,
	rem  but they won't/cannot contain double quotes " or colons :  in their names (at least on windows it's not allowed/won't work)

	rem tested when folders contain spaces and when LEIN_ROOT contains semicolon

	if not "x%DEBUG%" == "x" echo LEIN_ROOT=!LEIN_ROOT!

	rem if not "%LEIN_ROOT:;=%" == "%LEIN_ROOT%" (

	rem oddly enough /G:/ should've worked but doesn't where / they say it's console
	rem findstr is C:\Windows\System32\findstr.exe
	echo !LEIN_ROOT! | findstr /C:";" /G:con >nul
	if not errorlevel 1 ( rem aka errorlevel is 0 aka the string ";" was found
		echo Your folder structure !LEIN_ROOT! contains at least one semicolon in its name
		echo This is not allowed and would break things with the generated bootstrap file
		echo Please correct this by renaming the folders to not contain semicolons in their name
		del !bootstrapfile! >nul 2>&1
		echo You'll also have to recreate the bootstrap file just to be sure it has semicolon-free names inside
		echo the bootstrap file^(which was just deleted^) is: !bootstrapfile!
		echo  and the info on how to do that is:
		goto :RUN_BOOTSTRAP
	)

	if not exist !bootstrapfile! goto NO_DEPENDENCIES

	findstr /C:^"\^"^" !bootstrapfile! >nul
	if not errorlevel 1 (
		set hasAtLeastOneDoubleQuote=1
	) ELSE (
		set hasAtLeastOneDoubleQuote=0
	)

	if !hasAtLeastOneDoubleQuote! == 1 (
		echo double quotes detected inside file: !bootstrapfile!
		echo this should not be happening
		goto :RUN_BOOTSTRAP
	)

rem will proceed to set LEIN_LIBS and surround each path from bootstrap file in double quotes and separate it from others with a semicolon
rem the paths inside the bootstrap file do not already contain double quotes but may contain spaces
	rem note worthy: the following won't work due to a hard 1022bytes limit truncation in the variable that was set
	rem set /p LEIN_LIBS=<!bootstrapfile!
	rem so this will work instead:
	rem for /f "usebackq delims=" %%j in (!bootstrapfile!) do set LEIN_LIBS=%%j
	rem just  set LEIN_LIBS="%%j"  is uglier/hacky but would also work here instead of the below:
	for /f "usebackq delims=" %%j in (!bootstrapfile!) do (
		set tmpline=%%j
		call :processPath
	)

	if not "x%DEBUG%" == "x" echo LEIN_LIBS=!LEIN_LIBS!

    if "x!LEIN_LIBS!" == "x" goto NO_DEPENDENCIES

	rem CLASSPATH must contain each path element double quoted and separated by semicolons ie. "c:\some folder";"c:\some other folder";"c:\semicolons;;;;in;name;work okay"
	rem (no end semicolon required)
    set CLASSPATH=!LEIN_LIBS!;"!LEIN_ROOT!\src";"!LEIN_ROOT!\resources"

    :: Apply context specific CLASSPATH entries
    if exist "%~dp0..\.lein-classpath" (
        for /f %%i in ("%~dp0...lein-classpath") do set CONTEXT_CP=%%i

        if NOT "x!CONTEXT_CP!"=="x" (
            set CLASSPATH=!CONTEXT_CP!;!CLASSPATH!
        )
    )

) else (
    :: Not running from a checkout.
    if not exist "%LEIN_JAR%" goto NO_LEIN_JAR
    set CLASSPATH=%LEIN_JAR%

    if exist ".lein-classpath" (
        for /f %%i in (.lein-classpath) do set CONTEXT_CP=%%i

        if NOT "x!CONTEXT_CP!"=="x" (
            set CLASSPATH=!CONTEXT_CP!;!CLASSPATH!
        )
    )
)

if not "x%DEBUG%" == "x" echo CLASSPATH=!CLASSPATH!
:: ##################################################

if "x!JAVA_CMD!" == "x" set JAVA_CMD=java
if "x!LEIN_JAVA_CMD!" == "x" set LEIN_JAVA_CMD=%JAVA_CMD%

rem remove quotes from around java commands
for /f "usebackq delims=" %%i in ('!JAVA_CMD!') do set JAVA_CMD=%%~i
for /f "usebackq delims=" %%i in ('!LEIN_JAVA_CMD!') do set LEIN_JAVA_CMD=%%~i

if "x%JVM_OPTS%" == "x" set JVM_OPTS=%JAVA_OPTS%
goto RUN

:DownloadFile
rem parameters: TargetFileName Address
if NOT "x%HTTP_CLIENT%" == "x" (
    %HTTP_CLIENT% %1 %2
    goto EOF
)
powershell -? >nul 2>&1
if NOT ERRORLEVEL 9009 (
    powershell -Command "& {param($a,$f) (new-object System.Net.WebClient).DownloadFile($a, $f)}" ""%2"" ""%1""
    goto EOF
)
wget >nul 2>&1
if NOT ERRORLEVEL 9009 (
    wget --no-check-certificate -O %1 %2
    goto EOF
)
curl >nul 2>&1
if NOT ERRORLEVEL 9009 (
    rem We set CURL_PROXY to a space character below to pose as a no-op argument
    set CURL_PROXY=
    if NOT "x%HTTPS_PROXY%" == "x" set CURL_PROXY="-x %HTTPS_PROXY%"
    curl %CURL_PROXY% --insecure -f -L -o  %1 %2
    goto EOF
)
goto NO_HTTP_CLIENT

:NO_LEIN_JAR
echo.
echo %LEIN_JAR% can not be found.
echo You can try running "lein self-install"
echo or change LEIN_JAR environment variable
echo or edit lein.bat to set appropriate LEIN_JAR path.
echo.
goto EOF

:NO_DEPENDENCIES
echo.
echo Leiningen is missing its dependencies.
:RUN_BOOTSTRAP
echo Please run "lein bootstrap" in the leiningen-core/ directory
echo with a stable release of Leiningen. See CONTRIBUTING.md for details.
echo.
goto EOF

:SELF_INSTALL
if exist "%LEIN_JAR%" (
    echo %LEIN_JAR% already exists. Delete and retry.
    goto EOF
)

for %%f in ("%LEIN_JAR%") do set LEIN_INSTALL_DIR="%%~dpf"
if not exist %LEIN_INSTALL_DIR% mkdir %LEIN_INSTALL_DIR%

echo Downloading Leiningen now...

set LEIN_JAR_URL=https://leiningen.s3.amazonaws.com/downloads/leiningen-%LEIN_VERSION%-standalone.jar
call :DownloadFile "%LEIN_JAR%.pending" "%LEIN_JAR_URL%"
if ERRORLEVEL 1 (
    del "%LEIN_JAR%.pending" >nul 2>&1
    goto DOWNLOAD_FAILED
)
move /y "%LEIN_JAR%.pending" "%LEIN_JAR%"
goto EOF

:DOWNLOAD_FAILED
echo.
echo Failed to download %LEIN_JAR_URL%
if %SNAPSHOT% == YES echo See README.md for SNAPSHOT build instructions.
echo.
goto EOF

:UPGRADE
set LEIN_BAT=%~dp0%~nx0
set TARGET_VERSION=%2
if "x%2" == "x" set TARGET_VERSION=stable
echo The script at %LEIN_BAT% will be upgraded to the latest %TARGET_VERSION% version.
set /P ANSWER=Do you want to continue (Y/N)?
if /i {%ANSWER%}=={y}   goto YES_UPGRADE
if /i {%ANSWER%}=={yes} goto YES_UPGRADE
echo Aborted.
exit /B 1

:YES_UPGRADE
echo Downloading latest Leiningen batch script...

set LEIN_BAT_URL=https://github.com/technomancy/leiningen/raw/%TARGET_VERSION%/bin/lein.bat
set TEMP_BAT=%~dp0temp-lein-%RANDOM%%RANDOM%.bat
call :DownloadFile "%LEIN_BAT%.pending" "%LEIN_BAT_URL%"
if ERRORLEVEL 1 (
    del "%LEIN_BAT%.pending" >nul 2>&1
    echo Failed to download %LEIN_BAT_URL%
    goto EOF
)
move /y "%LEIN_BAT%.pending" "%TEMP_BAT%"
echo.
echo Upgrading...
set LEIN_JAR=
call "%TEMP_BAT%" self-install
move /y "%TEMP_BAT%" "%LEIN_BAT%" && goto EOF
goto EOF

:NO_HTTP_CLIENT
echo.
echo ERROR: Neither PowerShell, Wget, or Curl could be found.
echo        Make sure at least one of these tools is installed
echo        and is in PATH. You can get them from URLs below:
echo.
echo PowerShell: "http://www.microsoft.com/powershell"
echo Wget:       "http://users.ugent.be/~bpuype/wget/"
echo Curl:       "http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=2000/XP"
echo.
goto EOF

:SET_LEIN_ROOT
set LEIN_ROOT=%~f1
goto EOF

:: Find directory containing filename supplied in first argument
:: looking in current directory, and looking up the parent
:: chain until we find it, or run out
:: returns result in %DIR_CONTAINING%
:: empty string if we don't find it
:FIND_DIR_CONTAINING_UPWARDS
set DIR_CONTAINING=%CD%
set LAST_DIR=

:LOOK_AGAIN
if "%DIR_CONTAINING%" == "%LAST_DIR%" (
    :: didn't find it
    set DIR_CONTAINING=
    goto EOF
)

if EXIST "%DIR_CONTAINING%\%1" (
    :: found it - use result in DIR_CONTAINING
    goto EOF
)

set LAST_DIR=%DIR_CONTAINING%
call :GET_PARENT_PATH "%DIR_CONTAINING%\.."
set DIR_CONTAINING=%PARENT_PATH%
goto LOOK_AGAIN

:GET_PARENT_PATH
set PARENT_PATH=%~f1
goto EOF

:RUN
:: We need to disable delayed expansion here because the %* variable
:: may contain bangs (as in test!). There may also be special
:: characters inside the TRAMPOLINE_FILE.
setLocal DisableDelayedExpansion

set "TRAMPOLINE_FILE=%TEMP%\lein-trampoline-%RANDOM%.bat"
del "%TRAMPOLINE_FILE%" 2>nul

"%LEIN_JAVA_CMD%" -client %LEIN_JVM_OPTS% ^
 -Dclojure.compile.path="%DIR_CONTAINING%/target/classes" ^
 -Dleiningen.original.pwd="%ORIGINAL_PWD%" ^
 -cp "%CLASSPATH%" clojure.main -m leiningen.core.main %*

if not exist "%TRAMPOLINE_FILE%" goto EOF
call "%TRAMPOLINE_FILE%"
del "%TRAMPOLINE_FILE%"
goto EOF

rem this label must reside here outside of ( ) from the if block, otherwise the ELSE ( ) block is also executed
:processPath
rem will surround each path with double quotes before appending it to LEIN_LIBS
	for /f "tokens=1* delims=;" %%a in ("%tmpline%") do (
		set LEIN_LIBS=!LEIN_LIBS!"%%a";
		set tmpline=%%b
	)
	if not "%tmpline%" == "" goto :processPath
	goto :eof

:EOF

upgrade to leiningen 2.3.4

upgrade to leiningen 2.3.4


@echo off
"C:\Program Files\NodeJS\node.exe" %~dp0\server\helpers\launcher.js %*

@echo off
node %~dp0\server\helpers\launcher.js %*

Fix accidental change in kiwi.bat

Fix accidental change in kiwi.bat


@rem if we don't have nmake in the path, we need to run setup
where nmake.exe 2> NUL
if %ERRORLEVEL% GTR 0 set need_setup=1

@rem if we don't have the include path set, we need to run setup
if not defined INCLUDE set need_setup=1

@rem backup of the path, otherwise we end up with an "input line is too long"
@rem error since the path env var is growing up at every call to vsvarsall.bat
@set PATH_BACKUP=%PATH%

@rem run setup if we need to
if %need_setup% == 1 call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64

@rem Allow python build to succeed:
@rem http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat
SET VS90COMNTOOLS=%VS120COMNTOOLS%

where python.exe 2> NUL
if %ERRORLEVEL% GTR 0 set PATH=c:\Python27;%PATH%

where php.exe 2> NUL
if %ERRORLEVEL% GTR 0 set PATH=c:\php;%PATH%

@rem finally, run make
nmake /nologo /s /f winbuild\Makefile %1

@rem restore the original path value
@set PATH=%PATH_BACKUP%

@rem "input line is too long" problem occur also with the INCLUDE environment variable
@rem We just wipe it since next call to the batch file will set back the right value
@set INCLUDE=
@set LIB=
@set LIBPATH=

@rem if we don't have nmake in the path, we need to run setup
where nmake.exe 2> NUL
if %ERRORLEVEL% GTR 0 set need_setup=1

@rem if we don't have the include path set, we need to run setup
if not defined INCLUDE set need_setup=1

@rem backup of the path, otherwise we end up with an "input line is too long"
@rem error since the path env var is growing up at every call to vsvarsall.bat
@set PATH_BACKUP=%PATH%

@rem run setup if we need to
if %need_setup% == 1 call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64

@rem Allow python build to succeed:
@rem http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat
SET VS90COMNTOOLS=%VS120COMNTOOLS%

where python.exe 2> NUL
if %ERRORLEVEL% GTR 0 set PATH=c:\Python27;%PATH%

where php.exe 2> NUL
if %ERRORLEVEL% GTR 0 set PATH=c:\php;%PATH%

@rem finally, run make
nmake /nologo /s /f winbuild\Makefile %1

SET RETURN_CODE=%ERRORLEVEL%

@rem restore the original path value
@set PATH=%PATH_BACKUP%

@rem "input line is too long" problem occur also with the INCLUDE environment variable
@rem We just wipe it since next call to the batch file will set back the right value
@set INCLUDE=
@set LIB=
@set LIBPATH=

EXIT /B %RETURN_CODE%

Fix Make.bat always returning 0

Fix Make.bat always returning 0


@setlocal
@set PROMPT=$$$S

@pushd "%~dp0"

if exist "%~dp0Misc\version.cmd" call "%~dp0Misc\version.cmd"

if exist goarch.txt for /F %%I in (goarch.txt) do set "GOARCH=%%I"
if "%GOARCH%" == "" for /F "delims=/ tokens=2" %%I in ('go version') do set "GOARCH=%%I"

if "%GOPATH%" == "" set "GOPATH=%USERPROFILE%\go"
for /F "delims=; tokens=1" %%I in ("%GOPATH%") do set "GOPATH1ST=%%I"

call :"%~1"
@popd
@endlocal
@exit /b

:""
        for /F %%I in ('git describe --tags') do set "X_VERSION=-X main.version=%%I"
        call :"build"
        @exit /b 0

:"debug"
        set "TAGS=-tags=debug"
        @exit /b

:"release"
        for /F %%I in (%~dp0Misc\version.txt) do set "VERSION=%%I"
        set "X_VERSION=-X main.version=%VERSION%"
        call :"build"
        @exit /b

:"build"
        call :"fmt"
        call :"goversioninfo"
        for /F %%I in ('dir /b /s /aa nyagos.d') do attrib -A "%%I" & if exist main\bindata.go del main\bindata.go
        if not exist main\bindata.go call :"bindata"
        for /F "delims=" %%V in ('git log -1 --date^=short --pretty^=format:"-X main.stamp=%%ad -X main.commit=%%H"') do go build -o nyagos.exe -ldflags "%%V %X_VERSION%" %TAGS% .\main
        @exit /b

:"fmt"
        for /F %%I IN ('dir /s /b /aa *.go') do go fmt "%%I" & attrib -A "%%I"
        @exit /b

:"vet"
        for /R %%I IN (*.go) do @go vet "%%I"
        @exit /b

:"status"
        nyagos -e "print(nyagos.version or 'Snapshot on '..nyagos.stamp)"
        @exit /b

:"clean"
        for %%I in (nyagos.exe main\nyagos.syso version.now main\bindata.go) do if exist %%I del %%I
        powershell "ls -R | ?{ $_ -match '\.go$' } | %%{ [System.IO.Path]::GetDirectoryName($_.FullName)} | Sort-Object | Get-Unique | %%{ Write-Host 'go clean on',$_ ;  pushd $_ ; go clean ; popd }"

:"sweep"
        for /R %%I in (*~ *.bak) do if exist %%I del %%I
        if exist main\main.exe del main\main.exe
        @exit /b

:"get"
        powershell "Get-ChildItem . -Recurse | ?{ $_.Extension -eq '.go' } | %%{  Get-Content $_.FullName | %%{ ($_ -replace '\s*//.*$','').Split()[-1] } | ?{ $_ -match 'github.com/' } } | Sort-Object | Get-Unique | %%{ Write-Host $_ ; go get -u $_ }"
        @exit /b

:getbindata
        go get "github.com/jteeuwen/go-bindata"
        pushd "%GOPATH1ST%\src\github.com\jteeuwen\go-bindata\go-bindata"
        go build
        copy go-bindata.exe "%~dp0\."
        popd
        @exit /b

:"bindata"
        if not exist go-bindata.exe call :getbindata
        go-bindata.exe -o "main\bindata.go" "nyagos.d/..."
        @exit /b

:getgoversioninfo
        go get "github.com/josephspurrier/goversioninfo"
        pushd "%GOPATH1ST%\src\github.com\josephspurrier\goversioninfo\cmd\goversioninfo"
        go build
        copy goversioninfo.exe "%~dp0\."
        popd
        @exit /b

:"goversioninfo"
        if not exist goversioninfo.exe call :getgoversioninfo
        powershell -ExecutionPolicy RemoteSigned -File "%~dp0main\makejson.ps1" > "%~dp0Misc\version.json"
        goversioninfo.exe -icon main\nyagos.ico -o main\nyagos.syso "%~dp0Misc\version.json"
        @exit /b

:"const"
        for /F %%I in ('dir /b /s makeconst.cmd') do pushd %%~dpI & call %%I & popd
        @exit /b

:"package"
        for /F %%I in ('nyagos -e "print(nyagos.version or (string.gsub(nyagos.stamp,[[/]],[[]])))"') do set VERSION=%%I
        zip -9 "nyagos-%VERSION%-%GOARCH%.zip" nyagos.exe lua53.dll nyagos.lua .nyagos makeicon.cmd nyagos.d\*.lua nyagos.d\catalog\*.lua license.txt readme_ja.md readme.md Doc\*.md
        @exit /b

:"install"
        if not "%2" == "" set "INSTALLDIR=%2" & echo @set "INSTALLDIR=%2" > "%~dp0Misc\version.cmd"
        if "%INSTALLDIR%" == "" (
            echo Please %0.cmd install PATH\TO\BIN, once
            @exit /b
        )
        if not exist "%INSTALLDIR%" (
            echo Please %0.cmd install EXIST\PATH\TO\BIN,  once
            @exit /b
        )

        robocopy nyagos.d "%INSTALLDIR%\nyagos.d" /E
        if not exist "%INSTALLDIR%\lua53.dll" copy lua53.dll "%INSTALLDIR%\."
        copy nyagos.lua "%INSTALLDIR%\."
        copy /-Y _nyagos "%INSTALLDIR%\."
        copy nyagos.exe "%INSTALLDIR%\."
        if errorlevel 1 (start "" "%~dpfx0" install_ & @exit /b)
        @exit /b

:"install_"
        taskkill /F /im nyagos.exe
        copy nyagos.exe "%INSTALLDIR%\."
        timeout /T 3
        @exit %ERRORLEVEL%

:"icon"
        makeicon.cmd
        @exit /b

:"help"
        echo Usage for make.cmd
        echo  %0          : Equals to '%0 build'
        echo  %0 build    : Build nyagos.exe as snapshot (ignore version.txt)
        echo  %0 release  : Build nyagos.exe as release  (see version.txt)
        echo  %0 fmt      : Format all source files with 'go fmt'
        echo  %0 clean    : Delete nyagos.exe and nyagos.syso
        echo  %0 package  : Make the package zip-file
        echo  %0 get      : Do 'go get' for each github library
        echo  %0 upgrade  : Do 'git pull' for each github library
        echo  %0 help     : Print help
        echo  %0 install INSTALLDIR
        echo     : Copy binaries to INSTALLDIR
        echo  %0 install
        echo     : Copy binaries to last INSTALLDIR
        @exit /b

@setlocal
@set PROMPT=$$$S

@pushd "%~dp0"

if exist "%~dp0Misc\version.cmd" call "%~dp0Misc\version.cmd"

if exist goarch.txt for /F %%I in (goarch.txt) do set "GOARCH=%%I"
if "%GOARCH%" == "" for /F "delims=/ tokens=2" %%I in ('go version') do set "GOARCH=%%I"

if "%GOPATH%" == "" set "GOPATH=%USERPROFILE%\go"
for /F "delims=; tokens=1" %%I in ("%GOPATH%") do set "GOPATH1ST=%%I"

call :"%~1"
@popd
@endlocal
@exit /b

:""
        for /F %%I in ('git describe --tags') do set "X_VERSION=-X main.version=%%I"
        call :"build"
        @exit /b 0

:"debug"
        set "TAGS=-tags=debug"
        @exit /b

:"release"
        for /F %%I in (%~dp0Misc\version.txt) do set "VERSION=%%I"
        set "X_VERSION=-X main.version=%VERSION%"
        call :"build"
        @exit /b

:"build"
        call :"fmt"
        call :"goversioninfo"
        for /F %%I in ('dir /b /s /aa nyagos.d') do attrib -A "%%I" & if exist main\bindata.go del main\bindata.go
        if not exist main\bindata.go call :"bindata"
        for /F "delims=" %%V in ('git log -1 --date^=short --pretty^=format:"-X main.stamp=%%ad -X main.commit=%%H"') do go build -o nyagos.exe -ldflags "%%V %X_VERSION%" %TAGS% .\main
        @exit /b

:"fmt"
        for /F %%I IN ('dir /s /b /aa *.go') do go fmt "%%I" & attrib -A "%%I"
        @exit /b

:"status"
        nyagos -e "print(nyagos.version or 'Snapshot on '..nyagos.stamp)"
        @exit /b

:eachdir
        powershell "ls -R | ?{ $_ -match '\.go$' } | %%{ [System.IO.Path]::GetDirectoryName($_.FullName)} | Sort-Object | Get-Unique | %%{ Write-Host 'go %~1 on',$_ ;  pushd $_ ; go %~1 ; popd }"
        exit /b

:"vet"
        call :eachdir vet
        exit /b

:"clean"
        for %%I in (nyagos.exe main\nyagos.syso version.now main\bindata.go) do if exist %%I del %%I
        call :eachdir clean

:"sweep"
        for /R %%I in (*~ *.bak) do if exist %%I del %%I
        if exist main\main.exe del main\main.exe
        @exit /b

:"get"
        powershell "Get-ChildItem . -Recurse | ?{ $_.Extension -eq '.go' } | %%{  Get-Content $_.FullName | %%{ ($_ -replace '\s*//.*$','').Split()[-1] } | ?{ $_ -match 'github.com/' } } | Sort-Object | Get-Unique | %%{ Write-Host $_ ; go get -u $_ }"
        @exit /b

:getbindata
        go get "github.com/jteeuwen/go-bindata"
        pushd "%GOPATH1ST%\src\github.com\jteeuwen\go-bindata\go-bindata"
        go build
        copy go-bindata.exe "%~dp0\."
        popd
        @exit /b

:"bindata"
        if not exist go-bindata.exe call :getbindata
        go-bindata.exe -o "main\bindata.go" "nyagos.d/..."
        @exit /b

:getgoversioninfo
        go get "github.com/josephspurrier/goversioninfo"
        pushd "%GOPATH1ST%\src\github.com\josephspurrier\goversioninfo\cmd\goversioninfo"
        go build
        copy goversioninfo.exe "%~dp0\."
        popd
        @exit /b

:"goversioninfo"
        if not exist goversioninfo.exe call :getgoversioninfo
        powershell -ExecutionPolicy RemoteSigned -File "%~dp0main\makejson.ps1" > "%~dp0Misc\version.json"
        goversioninfo.exe -icon main\nyagos.ico -o main\nyagos.syso "%~dp0Misc\version.json"
        @exit /b

:"const"
        for /F %%I in ('dir /b /s makeconst.cmd') do pushd %%~dpI & call %%I & popd
        @exit /b

:"package"
        for /F %%I in ('nyagos -e "print(nyagos.version or (string.gsub(nyagos.stamp,[[/]],[[]])))"') do set VERSION=%%I
        zip -9 "nyagos-%VERSION%-%GOARCH%.zip" nyagos.exe lua53.dll nyagos.lua .nyagos makeicon.cmd nyagos.d\*.lua nyagos.d\catalog\*.lua license.txt readme_ja.md readme.md Doc\*.md
        @exit /b

:"install"
        if not "%2" == "" set "INSTALLDIR=%2" & echo @set "INSTALLDIR=%2" > "%~dp0Misc\version.cmd"
        if "%INSTALLDIR%" == "" (
            echo Please %0.cmd install PATH\TO\BIN, once
            @exit /b
        )
        if not exist "%INSTALLDIR%" (
            echo Please %0.cmd install EXIST\PATH\TO\BIN,  once
            @exit /b
        )

        robocopy nyagos.d "%INSTALLDIR%\nyagos.d" /E
        if not exist "%INSTALLDIR%\lua53.dll" copy lua53.dll "%INSTALLDIR%\."
        copy nyagos.lua "%INSTALLDIR%\."
        copy /-Y _nyagos "%INSTALLDIR%\."
        copy nyagos.exe "%INSTALLDIR%\."
        if errorlevel 1 (start "" "%~dpfx0" install_ & @exit /b)
        @exit /b

:"install_"
        taskkill /F /im nyagos.exe
        copy nyagos.exe "%INSTALLDIR%\."
        timeout /T 3
        @exit %ERRORLEVEL%

:"icon"
        makeicon.cmd
        @exit /b

:"help"
        echo Usage for make.cmd
        echo  %0          : Equals to '%0 build'
        echo  %0 build    : Build nyagos.exe as snapshot (ignore version.txt)
        echo  %0 release  : Build nyagos.exe as release  (see version.txt)
        echo  %0 fmt      : Format all source files with 'go fmt'
        echo  %0 clean    : Delete nyagos.exe and nyagos.syso
        echo  %0 package  : Make the package zip-file
        echo  %0 get      : Do 'go get' for each github library
        echo  %0 upgrade  : Do 'git pull' for each github library
        echo  %0 help     : Print help
        echo  %0 install INSTALLDIR
        echo     : Copy binaries to INSTALLDIR
        echo  %0 install
        echo     : Copy binaries to last INSTALLDIR
        @exit /b

make vet: faster

make vet: faster


set RemoveCmd=rmdir /S /Q
%RemoveCmd% bin\
%RemoveCmd% Grammars\Bin\
%RemoveCmd% Grammars\CSharp\CSharp.Grammar\obj\
%RemoveCmd% Grammars\Json\Json.Grammar\obj\
%RemoveCmd% Grammars\Json\Tests\Sample.Json.Cs\bin\
%RemoveCmd% Grammars\Json\Tests\Sample.Json.Cs\obj\
%RemoveCmd% Grammars\Json\Tests\Sample.Json.Nemerle\bin\
%RemoveCmd% Grammars\Samples\Calculator\Sample.Calc\obj\
%RemoveCmd% Grammars\Samples\Calculator\Sample.Calc.App\bin\
%RemoveCmd% Grammars\Samples\Calculator\Sample.Calc.App\obj\
%RemoveCmd% Grammars\Samples\Calculator\Sample.Calc.Quotation\bin\
%RemoveCmd% Grammars\Samples\Calculator\Sample.Calc.Quotation\obj\
%RemoveCmd% Grammars\Samples\Calculator\Sample.Num\obj\
%RemoveCmd% Nitra\Nitra\bin\
%RemoveCmd% Nitra\Nitra\obj\
%RemoveCmd% Nitra\Nitra.Compiler\obj\
%RemoveCmd% Nitra\Nitra.Grammar\bin\
%RemoveCmd% Nitra\Nitra.Grammar\obj\
%RemoveCmd% Nitra\Nitra.Runtime\bin\
%RemoveCmd% Nitra\Nitra.Runtime\obj\
%RemoveCmd% Nitra\Nitra.Runtime.Macros\bin\
%RemoveCmd% Nitra\Nitra.Runtime.Macros\obj\
%RemoveCmd% Nitra.LanguageCompiler\bin\
%RemoveCmd% Nitra.LanguageCompiler\obj\
%RemoveCmd% Nitra.LanguageCompiler\Templates\XXLanguageXXVsPackage\bin\
%RemoveCmd% Nitra.LanguageCompiler\Templates\XXLanguageXXVsPackage\obj\
%RemoveCmd% Nitra.TestsLauncher\bin\
%RemoveCmd% Nitra.TestsLauncher\obj\
%RemoveCmd% Nitra.Visualizer\bin\
%RemoveCmd% Nitra.Visualizer\obj\
%RemoveCmd% Tests\Cpp.Grammar.Test\bin\
%RemoveCmd% Tests\CSharp.Grammar.Test\bin\
%RemoveCmd% Ide\Nitra.VisualStudio\bin\
%RemoveCmd% Ide\Nitra.VisualStudio\obj\
%RemoveCmd% Ide\Nitra.VisualStudio.Plugin\bin\
%RemoveCmd% Ide\Nitra.VisualStudio.Plugin\obj\
%RemoveCmd% Ide\CSharp.VisualStudio.Plugin\bin
%RemoveCmd% Ide\CSharp.VisualStudio.Plugin\obj
%RemoveCmd% Ide\NitraCSharpVsPackage
%RemoveCmd% Ide\NitraLangVsPackage
%RemoveCmd% packages\
%RemoveCmd% VisualStudioExtensions\NitraVsPackage\packages\

MKDIR bin\Debug\NuGetSource
MKDIR bin\Release\NuGetSource

IF "%NemerleBinPathRoot%" NEQ "" GOTO CopyNemerleNuGetPkgs
IF "%ProgramFiles(x86)%" == "" ( SET NemerleBinPathRoot=%ProgramFiles(x86)% ) ELSE ( SET NemerleBinPathRoot=%ProgramFiles% )
SET NemerleBinPathRoot=%NemerleBinPathRoot%\Nemerle\

:CopyNemerleNuGetPkgs

copy "%NemerleBinPathRoot%Net-4.0\*.nupkg" bin\Debug\NuGetSource\ /B
copy "%NemerleBinPathRoot%Net-4.0\*.nupkg" bin\Release\NuGetSource\ /B
@echo Done

Add to Clear.cmd initialize of NuGetSource dir


mkdir build
cd build

set BUILD_CONFIG=Release

REM Configure step
if "%ARCH%"=="32" (
    set CMAKE_GENERATOR=Visual Studio 16 2019
) else (
    set CMAKE_GENERATOR=Visual Studio 16 2019 Win64
)

set CMAKE_GENERATOR_TOOLSET=v141

REM llvm 8 needs the 64bit linker
set PreferredToolArchitecture=x64

REM Reduce build times and package size by removing unused stuff
REM BENCHMARKS (new for llvm8) don't build under Visual Studio 14 2015
set CMAKE_CUSTOM=-DLLVM_TARGETS_TO_BUILD="host;AMDGPU;NVPTX" ^
    -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_UTILS=ON -DLLVM_INCLUDE_DOCS=OFF ^
    -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=ON ^
    -DLLVM_USE_INTEL_JITEVENTS=ON ^
    -DLLVM_INCLUDE_BENCHMARKS=OFF ^
    -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly

REM the platform toolset host arch is set to x64 so as to use the 64bit linker,
REM the 32bit linker heap is too small for llvm8 so it tries and falls over to
REM the 64bit linker anyway
cmake -G "%CMAKE_GENERATOR%" -T "%CMAKE_GENERATOR_TOOLSET%" ^
    -DCMAKE_BUILD_TYPE="%BUILD_CONFIG%" -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% %CMAKE_CUSTOM% %SRC_DIR% ^
    -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=x64
if errorlevel 1 exit 1

REM Build step
cmake --build . --config "%BUILD_CONFIG%"
if errorlevel 1 exit 1

REM Install step
cmake --build . --config "%BUILD_CONFIG%" --target install
if errorlevel 1 exit 1

REM From: https://github.com/conda-forge/llvmdev-feedstock/pull/53
%BUILD_CONFIG%\bin\opt -S -vector-library=SVML -mcpu=haswell -O3 %RECIPE_DIR%\numba-3016.ll | %BUILD_CONFIG%\bin\FileCheck %RECIPE_DIR%\numba-3016.ll
if errorlevel 1 exit 1

REM This is technically how to run the suite, but it will only run in an
REM enhanced unix-like shell which has functions like `grep` available.
REM cd ..\test
REM %PYTHON% ..\build\%BUILD_CONFIG%\bin\llvm-lit.py -vv Transforms ExecutionEngine Analysis CodeGen/X86
REM if errorlevel 1 exit 1

mkdir build
cd build

set BUILD_CONFIG=Release

REM Configure step
REM Using VS2019 generator but using the VS2017 toolset (v141)
REM reference https://gitlab.kitware.com/cmake/cmake/issues/19157
if "%ARCH%"=="32" (
    set CMAKE_GENERATOR=Visual Studio 16 2019
) else (
    set CMAKE_GENERATOR=Visual Studio 16 2019 Win64
)
set CMAKE_GENERATOR_TOOLSET=v141

REM llvm 8 needs the 64bit linker
set PreferredToolArchitecture=x64

REM Reduce build times and package size by removing unused stuff
REM BENCHMARKS (new for llvm8) don't build under Visual Studio 14 2015
set CMAKE_CUSTOM=-DLLVM_TARGETS_TO_BUILD="host;AMDGPU;NVPTX" ^
    -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_UTILS=ON -DLLVM_INCLUDE_DOCS=OFF ^
    -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=ON ^
    -DLLVM_USE_INTEL_JITEVENTS=ON ^
    -DLLVM_INCLUDE_BENCHMARKS=OFF ^
    -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly

REM the platform toolset host arch is set to x64 so as to use the 64bit linker,
REM the 32bit linker heap is too small for llvm8 so it tries and falls over to
REM the 64bit linker anyway
cmake -G "%CMAKE_GENERATOR%" -T "%CMAKE_GENERATOR_TOOLSET%" ^
    -DCMAKE_BUILD_TYPE="%BUILD_CONFIG%" -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% %CMAKE_CUSTOM% %SRC_DIR% ^
    -DCMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=x64
if errorlevel 1 exit 1

REM Build step
cmake --build . --config "%BUILD_CONFIG%"
if errorlevel 1 exit 1

REM Install step
cmake --build . --config "%BUILD_CONFIG%" --target install
if errorlevel 1 exit 1

REM From: https://github.com/conda-forge/llvmdev-feedstock/pull/53
%BUILD_CONFIG%\bin\opt -S -vector-library=SVML -mcpu=haswell -O3 %RECIPE_DIR%\numba-3016.ll | %BUILD_CONFIG%\bin\FileCheck %RECIPE_DIR%\numba-3016.ll
if errorlevel 1 exit 1

REM This is technically how to run the suite, but it will only run in an
REM enhanced unix-like shell which has functions like `grep` available.
REM cd ..\test
REM %PYTHON% ..\build\%BUILD_CONFIG%\bin\llvm-lit.py -vv Transforms ExecutionEngine Analysis CodeGen/X86
REM if errorlevel 1 exit 1

Add comment

Add comment


java -jar FountainSim-1.2.jar -debug -gl-strict
PAUSE

Add launch bat

Add launch bat


fezc test\basics.fs
FOR %%f in (test\*.erl) DO erlc +clint -o test "%%f"
erl -noshell -pa ebin test -eval "eunit:test(basics_tests, [verbose])" -s init stop

dotnet run -p src/fez/fez.fsproj test\basics.fs
FOR %%f in (test\*.erl) DO erlc +clint -o test "%%f"
erl -noshell -pa .\ebin .\test -eval "eunit:test(basics_tests, [verbose])" -s init stop

fix run-tests.cmd

fix run-tests.cmd


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

@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM     e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------

@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%

@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")

@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre

@setlocal

set ERROR_CODE=0

@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal

@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome

echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error

:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init

echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error

@REM ==== END VALIDATION ====

:init

set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %*

@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.

set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir

set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir

:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir

:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"

:endDetectBaseDir

IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig

@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%

:endReadAdditionalConfig

SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"

set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar""
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain

@REM avoid using MAVEN_CMD_LINE_ARGS below since that would lose parameter escaping in %*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end

:error
set ERROR_CODE=1

:end
@endlocal & set ERROR_CODE=%ERROR_CODE%

if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost

@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause

if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%

exit /B %ERROR_CODE%

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

@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM     e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------

@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%

@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")

@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre

@setlocal

set ERROR_CODE=0

@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal

@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome

echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error

:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init

echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error

@REM ==== END VALIDATION ====

:init

set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %*

@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.

set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir

set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir

:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir

:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"

:endDetectBaseDir

IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig

@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%

:endReadAdditionalConfig

SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"

set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar""
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain

@REM avoid using MAVEN_CMD_LINE_ARGS below since that would lose parameter escaping in %*
"%MAVEN_JAVA_EXE%" %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end

:error
set ERROR_CODE=1

:end
@endlocal & set ERROR_CODE=%ERROR_CODE%

if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost

@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause

if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%

exit /B %ERROR_CODE%

Fix variable expansion issue in batch script


@echo off
pushd "%~dp0"
if not exist dist mkdir dist || goto :end
nuget pack -Symbols -OutputDirectory "dist" src\FakeLinqPad.csproj %*
:end
popd

@echo off
pushd "%~dp0"
call build || goto :end
if not exist dist mkdir dist || goto :end
nuget pack -Symbols -OutputDirectory "dist" src\FakeLinqPad.csproj %*
:end
popd

Build before packing

Build before packing


dotnet pack src/TurkishId --configuration Release -o .

dotnet pack src\TurkishId --configuration Release -o .
dotnet pack src\TurkishId.ModelBinder --configuration Release -o .

include TurkishId.ModelBinder in the build


@echo off
SetLocal EnableDelayedExpansion
echo build a msi installer using local cli sources and python executables. You need to have curl.exe, unzip.exe and msbuild.exe available under PATH
echo.

set "PATH=%PATH%;%ProgramFiles%\Git\bin;%ProgramFiles%\Git\usr\bin;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\MSBuild\14.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin;"

if "%CLI_VERSION%"=="" (
    echo Please set the CLI_VERSION environment variable, e.g. 2.0.13
    goto ERROR
)
set PYTHON_VERSION=3.6.6

set WIX_DOWNLOAD_URL="https://azurecliprod.blob.core.windows.net/msi/wix310-binaries-mirror.zip"
set PYTHON_DOWNLOAD_URL="https://azurecliprod.blob.core.windows.net/util/Python366-32.zip"

:: Set up the output directory and temp. directories
echo Cleaning previous build artifacts...
set OUTPUT_DIR=%~dp0..\out
if exist %OUTPUT_DIR% rmdir /s /q %OUTPUT_DIR%
mkdir %OUTPUT_DIR%

set ARTIFACTS_DIR=%~dp0..\artifacts
mkdir %ARTIFACTS_DIR%
set TEMP_SCRATCH_FOLDER=%ARTIFACTS_DIR%\cli_scratch
set BUILDING_DIR=%ARTIFACTS_DIR%\cli
set WIX_DIR=%ARTIFACTS_DIR%\wix
set PYTHON_DIR=%ARTIFACTS_DIR%\Python366-32

set REPO_ROOT=%~dp0..\..\..

::reset working folders
if exist %BUILDING_DIR% rmdir /s /q %BUILDING_DIR%
::rmdir always returns 0, so check folder's existence
if exist %BUILDING_DIR% (
    echo Failed to delete %BUILDING_DIR%.
    goto ERROR
)
mkdir %BUILDING_DIR%

if exist %TEMP_SCRATCH_FOLDER% rmdir /s /q %TEMP_SCRATCH_FOLDER%
if exist %TEMP_SCRATCH_FOLDER% (
    echo Failed to delete %TEMP_SCRATCH_FOLDER%.
    goto ERROR
)
mkdir %TEMP_SCRATCH_FOLDER%

if exist %REPO_ROOT%\privates (
    copy %REPO_ROOT%\privates\*.whl %TEMP_SCRATCH_FOLDER%
)

::ensure wix is available
if exist %WIX_DIR% (
    echo Using existing Wix at %WIX_DIR%
)
if not exist %WIX_DIR% (
    mkdir %WIX_DIR%
    pushd %WIX_DIR%
    echo Downloading Wix.
    curl -o wix-archive.zip %WIX_DOWNLOAD_URL% -k
    unzip -q wix-archive.zip
    if %errorlevel% neq 0 goto ERROR
    del wix-archive.zip
    echo Wix downloaded and extracted successfully.
    popd
)

::ensure Python is available
if exist %PYTHON_DIR% (
    echo Using existing Python at %PYTHON_DIR%
)
if not exist %PYTHON_DIR% (
    mkdir %PYTHON_DIR%
    pushd %PYTHON_DIR%
    echo Downloading Python.
    curl -o Python366-32.zip %PYTHON_DOWNLOAD_URL% -k
    unzip -q Python366-32.zip
    if %errorlevel% neq 0 goto ERROR
    del Python366-32.zip
    echo Python downloaded and extracted successfully.
    popd
)
set PYTHON_EXE=%PYTHON_DIR%\python.exe

robocopy %PYTHON_DIR% %BUILDING_DIR% /s /NFL /NDL

:: Build & install all the packages with bdist_wheel
%BUILDING_DIR%\python.exe -m pip install wheel
echo Building CLI packages...
set CLI_SRC=%REPO_ROOT%\src
for %%a in (%CLI_SRC%\azure-cli %CLI_SRC%\azure-cli-core %CLI_SRC%\azure-cli-nspkg %CLI_SRC%\azure-cli-telemetry) do (
   pushd %%a
   %BUILDING_DIR%\python.exe setup.py bdist_wheel -d %TEMP_SCRATCH_FOLDER%
   popd
)
pushd %CLI_SRC%\command_modules
for /D %%a in (*) do (
   pushd %CLI_SRC%\command_modules\%%a
   %BUILDING_DIR%\python.exe setup.py bdist_wheel -d %TEMP_SCRATCH_FOLDER%
   popd
)
popd
echo Built CLI packages successfully.

if %errorlevel% neq 0 goto ERROR

set ALL_MODULES=
for %%i in (%TEMP_SCRATCH_FOLDER%\*.whl) do (
    set ALL_MODULES=!ALL_MODULES! %%i
)
echo All modules: %ALL_MODULES%
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall pycparser==2.18
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --no-cache-dir %ALL_MODULES%
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall urllib3==1.24.2

pushd %BUILDING_DIR%
%BUILDING_DIR%\python.exe %~dp0\patch_models_v2.py
popd

echo Creating the wbin (Windows binaries) folder that will be added to the path...
mkdir %BUILDING_DIR%\wbin
copy %REPO_ROOT%\build_scripts\windows\scripts\az.cmd %BUILDING_DIR%\wbin\
if %errorlevel% neq 0 goto ERROR
copy %REPO_ROOT%\build_scripts\windows\resources\CLI_LICENSE.rtf %BUILDING_DIR%
copy %REPO_ROOT%\build_scripts\windows\resources\ThirdPartyNotices.txt %BUILDING_DIR%

:: Use universal files and remove Py3 only files
pushd %BUILDING_DIR%\Lib\site-packages\azure\mgmt
for /f %%a in ('dir /b /s *_py3.py') do (
    set PY3_FILE=%%a
    if exist !PY3_FILE! del !PY3_FILE!
)
for /f %%a in ('dir /b /s *_py3.*.pyc') do (
    set PY3_FILE=%%a
    if exist !PY3_FILE! del !PY3_FILE!
)
popd

:: Remove .py and only deploy .pyc files
pushd %BUILDING_DIR%\Lib\site-packages
for /f %%f in ('dir /b /s *.pyc') do (
    set PARENT_DIR=%%~df%%~pf..
    echo !PARENT_DIR! | findstr /C:\Lib\site-packages\pip\ 1>nul
    if !errorlevel! neq  0 (
        set FILENAME=%%~nf
        set BASE_FILENAME=!FILENAME:~0,-11!
        set pyc=!BASE_FILENAME!.pyc
        del !PARENT_DIR!\!BASE_FILENAME!.py
        copy %%~f !PARENT_DIR!\!pyc! >nul
        del %%~f
    ) ELSE (
        echo --SKIP !PARENT_DIR! under pip
    )
)
popd

for /d /r %BUILDING_DIR%\Lib\site-packages\pip %%d in (__pycache__) do (
    if exist %%d rmdir /s /q "%%d"
)

if %errorlevel% neq 0 goto ERROR

echo Building MSI...
msbuild /t:rebuild /p:Configuration=Release %REPO_ROOT%\build_scripts\windows\azure-cli.wixproj

start %OUTPUT_DIR%

goto END

:ERROR
echo Error occurred, please check the output for details.
exit /b 1

:END
exit /b 0
popd

@echo off
SetLocal EnableDelayedExpansion
echo build a msi installer using local cli sources and python executables. You need to have curl.exe, unzip.exe and msbuild.exe available under PATH
echo.

set "PATH=%PATH%;%ProgramFiles%\Git\bin;%ProgramFiles%\Git\usr\bin;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\MSBuild\14.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin;"

if "%CLI_VERSION%"=="" (
    echo Please set the CLI_VERSION environment variable, e.g. 2.0.13
    goto ERROR
)
set PYTHON_VERSION=3.6.6

set WIX_DOWNLOAD_URL="https://azurecliprod.blob.core.windows.net/msi/wix310-binaries-mirror.zip"
set PYTHON_DOWNLOAD_URL="https://azurecliprod.blob.core.windows.net/util/Python366-32.zip"

:: Set up the output directory and temp. directories
echo Cleaning previous build artifacts...
set OUTPUT_DIR=%~dp0..\out
if exist %OUTPUT_DIR% rmdir /s /q %OUTPUT_DIR%
mkdir %OUTPUT_DIR%

set ARTIFACTS_DIR=%~dp0..\artifacts
mkdir %ARTIFACTS_DIR%
set TEMP_SCRATCH_FOLDER=%ARTIFACTS_DIR%\cli_scratch
set BUILDING_DIR=%ARTIFACTS_DIR%\cli
set WIX_DIR=%ARTIFACTS_DIR%\wix
set PYTHON_DIR=%ARTIFACTS_DIR%\Python366-32

set REPO_ROOT=%~dp0..\..\..

::reset working folders
if exist %BUILDING_DIR% rmdir /s /q %BUILDING_DIR%
::rmdir always returns 0, so check folder's existence
if exist %BUILDING_DIR% (
    echo Failed to delete %BUILDING_DIR%.
    goto ERROR
)
mkdir %BUILDING_DIR%

if exist %TEMP_SCRATCH_FOLDER% rmdir /s /q %TEMP_SCRATCH_FOLDER%
if exist %TEMP_SCRATCH_FOLDER% (
    echo Failed to delete %TEMP_SCRATCH_FOLDER%.
    goto ERROR
)
mkdir %TEMP_SCRATCH_FOLDER%

if exist %REPO_ROOT%\privates (
    copy %REPO_ROOT%\privates\*.whl %TEMP_SCRATCH_FOLDER%
)

::ensure wix is available
if exist %WIX_DIR% (
    echo Using existing Wix at %WIX_DIR%
)
if not exist %WIX_DIR% (
    mkdir %WIX_DIR%
    pushd %WIX_DIR%
    echo Downloading Wix.
    curl -o wix-archive.zip %WIX_DOWNLOAD_URL% -k
    unzip -q wix-archive.zip
    if %errorlevel% neq 0 goto ERROR
    del wix-archive.zip
    echo Wix downloaded and extracted successfully.
    popd
)

::ensure Python is available
if exist %PYTHON_DIR% (
    echo Using existing Python at %PYTHON_DIR%
)
if not exist %PYTHON_DIR% (
    mkdir %PYTHON_DIR%
    pushd %PYTHON_DIR%
    echo Downloading Python.
    curl -o Python366-32.zip %PYTHON_DOWNLOAD_URL% -k
    unzip -q Python366-32.zip
    if %errorlevel% neq 0 goto ERROR
    del Python366-32.zip
    echo Python downloaded and extracted successfully.
    popd
)
set PYTHON_EXE=%PYTHON_DIR%\python.exe

robocopy %PYTHON_DIR% %BUILDING_DIR% /s /NFL /NDL

:: Build & install all the packages with bdist_wheel
%BUILDING_DIR%\python.exe -m pip install wheel
echo Building CLI packages...
set CLI_SRC=%REPO_ROOT%\src
for %%a in (%CLI_SRC%\azure-cli %CLI_SRC%\azure-cli-core %CLI_SRC%\azure-cli-nspkg %CLI_SRC%\azure-cli-telemetry) do (
   pushd %%a
   %BUILDING_DIR%\python.exe setup.py bdist_wheel -d %TEMP_SCRATCH_FOLDER%
   popd
)
echo Built CLI packages successfully.

if %errorlevel% neq 0 goto ERROR

set ALL_MODULES=
for %%i in (%TEMP_SCRATCH_FOLDER%\*.whl) do (
    set ALL_MODULES=!ALL_MODULES! %%i
)
echo All modules: %ALL_MODULES%
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall pycparser==2.18
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --no-cache-dir %ALL_MODULES%
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall urllib3==1.24.2

pushd %BUILDING_DIR%
%BUILDING_DIR%\python.exe %~dp0\patch_models_v2.py
popd

echo Creating the wbin (Windows binaries) folder that will be added to the path...
mkdir %BUILDING_DIR%\wbin
copy %REPO_ROOT%\build_scripts\windows\scripts\az.cmd %BUILDING_DIR%\wbin\
if %errorlevel% neq 0 goto ERROR
copy %REPO_ROOT%\build_scripts\windows\resources\CLI_LICENSE.rtf %BUILDING_DIR%
copy %REPO_ROOT%\build_scripts\windows\resources\ThirdPartyNotices.txt %BUILDING_DIR%

:: Use universal files and remove Py3 only files
pushd %BUILDING_DIR%\Lib\site-packages\azure\mgmt
for /f %%a in ('dir /b /s *_py3.py') do (
    set PY3_FILE=%%a
    if exist !PY3_FILE! del !PY3_FILE!
)
for /f %%a in ('dir /b /s *_py3.*.pyc') do (
    set PY3_FILE=%%a
    if exist !PY3_FILE! del !PY3_FILE!
)
popd

:: Remove .py and only deploy .pyc files
pushd %BUILDING_DIR%\Lib\site-packages
for /f %%f in ('dir /b /s *.pyc') do (
    set PARENT_DIR=%%~df%%~pf..
    echo !PARENT_DIR! | findstr /C:\Lib\site-packages\pip\ 1>nul
    if !errorlevel! neq  0 (
        set FILENAME=%%~nf
        set BASE_FILENAME=!FILENAME:~0,-11!
        set pyc=!BASE_FILENAME!.pyc
        del !PARENT_DIR!\!BASE_FILENAME!.py
        copy %%~f !PARENT_DIR!\!pyc! >nul
        del %%~f
    ) ELSE (
        echo --SKIP !PARENT_DIR! under pip
    )
)
popd

for /d /r %BUILDING_DIR%\Lib\site-packages\pip %%d in (__pycache__) do (
    if exist %%d rmdir /s /q "%%d"
)

if %errorlevel% neq 0 goto ERROR

echo Building MSI...
msbuild /t:rebuild /p:Configuration=Release %REPO_ROOT%\build_scripts\windows\azure-cli.wixproj

start %OUTPUT_DIR%

goto END

:ERROR
echo Error occurred, please check the output for details.
exit /b 1

:END
exit /b 0
popd

Remove independent command_module reference from MSI builder


@echo off

setlocal enabledelayedexpansion

set src=README.md
if not exist !src! goto :nosuchfile

set dst=README.docx
if "%~1" neq "" set "dst=%~1"

pandoc -f markdown_github -t docx !src! -o !dst!
goto :exit

:nosuchfile
echo README.md not found!
goto :eof

:exit
endlocal

@echo off

setlocal enabledelayedexpansion

:parse
if "%~x1" equ ".md" call :convert "%~1"
shift /1
goto :exit

:convert
set /p "ign=converting [%~1] to [%~dpn1.docx] ... " < nul
pandoc -f markdown_github -t docx "%~1" -o "%~dpn1.docx"
echo done
goto :eof

:nosuchfile
echo !src! or !dst! does not exist!
goto :eof

:exit
endlocal

add md2docx batch script

add md2docx batch script


set /p versionNumber=

REM clean up
del builds\im-only-resting-%versionNumber%.zip
rd /q /s builds\im-only-resting-%versionNumber%
rd /q /s builds\im-only-resting

REM preparing staging dir
mkdir staging
copy LICENSE staging
copy NOTICE staging
copy Ior\bin\Release\im-only-resting.exe staging
copy Ior\bin\Release\libtidy.dll staging
copy Ior\bin\Release\Newtonsoft.Json.dll staging
copy Ior\bin\Release\PropertyGridEx.dll staging
copy Ior\bin\Release\RestSharp.dll staging
copy Ior\bin\Release\TidyManaged.dll staging
copy Ior\bin\Release\Utils.dll staging
copy Ior\bin\Release\NLog.config staging
copy Ior\bin\Release\NLog.dll staging

REM zip staging files
cd staging
"..\tools\7z\7za.exe" a -tzip "..\builds\im-only-resting-%versionNumber%.zip" *
cd ..

REM extract build
"tools\7z\7za.exe" e "builds\im-only-resting-%versionNumber%.zip" -o"builds\im-only-resting-%versionNumber%"
"tools\7z\7za.exe" e "builds\im-only-resting-%versionNumber%.zip" -o"builds\im-only-resting"

REM clean up
rd /q /s staging

pause

set /p versionNumber=

REM clean up
del builds\im-only-resting-%versionNumber%.zip
rd /q /s builds\im-only-resting-%versionNumber%
rd /q /s builds\im-only-resting

REM preparing staging dir
mkdir staging
copy LICENSE staging
copy NOTICE staging
copy Ior\bin\Release\im-only-resting.exe staging
copy Ior\bin\Release\libtidy.dll staging
copy Ior\bin\Release\Newtonsoft.Json.dll staging
copy Ior\bin\Release\PropertyGridEx.dll staging
copy Ior\bin\Release\RestSharp.dll staging
copy Ior\bin\Release\TidyManaged.dll staging
copy Ior\bin\Release\Utils.dll staging
copy Ior\bin\Release\NLog.config staging
copy Ior\bin\Release\NLog.dll staging
copy Ior\bin\Release\System.Net.Http.dll staging
copy Ior\bin\Release\System.Net.Http.WebRequest.dll staging

REM zip staging files
cd staging
"..\tools\7z\7za.exe" a -tzip "..\builds\im-only-resting-%versionNumber%.zip" *
cd ..

REM extract build
"tools\7z\7za.exe" e "builds\im-only-resting-%versionNumber%.zip" -o"builds\im-only-resting-%versionNumber%"
"tools\7z\7za.exe" e "builds\im-only-resting-%versionNumber%.zip" -o"builds\im-only-resting"

REM clean up
rd /q /s staging

pause

update archive-release.bat

update archive-release.bat


start call "C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --dbpath C:\data\db
node server.js
pause

Add batch file for launching server

Add batch file for launching server


@ECHO OFF
rem ******************************************************************************
rem *
rem * Notepad2-mod
rem *
rem * build_wdk.bat
rem *   Batch file "wrapper" for makefile.mak, used to build Notepad2 with WDK
rem *
rem * See License.txt for details about distribution and modification.
rem *
rem *                                       (c) XhmikosR 2010-2013
rem *                                       https://github.com/XhmikosR/notepad2-mod
rem *
rem ******************************************************************************

SETLOCAL ENABLEEXTENSIONS
CD /D %~dp0

rem Set the WDK directory
IF NOT DEFINED WDKBASEDIR SET "WDKBASEDIR=C:\WinDDK\7600.16385.1"

rem Check the building environment
IF NOT EXIST "%WDKBASEDIR%" CALL :SUBMSG "ERROR" "Specify your WDK directory!"

rem Check for the help switches
IF /I "%~1" == "help"   GOTO SHOWHELP
IF /I "%~1" == "/help"  GOTO SHOWHELP
IF /I "%~1" == "-help"  GOTO SHOWHELP
IF /I "%~1" == "--help" GOTO SHOWHELP
IF /I "%~1" == "/?"     GOTO SHOWHELP

rem Check for the first switch
IF "%~1" == "" (
  SET "BUILDTYPE=Build"
) ELSE (
  IF /I "%~1" == "Build"     SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "/Build"    SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "-Build"    SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "--Build"   SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "Clean"     SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "/Clean"    SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "-Clean"    SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "--Clean"   SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "Rebuild"   SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
  IF /I "%~1" == "/Rebuild"  SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
  IF /I "%~1" == "-Rebuild"  SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
  IF /I "%~1" == "--Rebuild" SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG

  ECHO.
  ECHO Unsupported commandline switch!
  ECHO Run "%~nx0 help" for details about the commandline switches.
  CALL :SUBMSG "ERROR" "Compilation failed!"
)

:CHECKSECONDARG
rem Check for the second switch
IF "%~2" == "" (
  SET "ARCH=all"
) ELSE (
  IF /I "%~2" == "x86"   SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "/x86"  SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "-x86"  SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "--x86" SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "x64"   SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "/x64"  SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "-x64"  SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "--x64" SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "all"   SET "ARCH=all" & GOTO START
  IF /I "%~2" == "/all"  SET "ARCH=all" & GOTO START
  IF /I "%~2" == "-all"  SET "ARCH=all" & GOTO START
  IF /I "%~2" == "--all" SET "ARCH=all" & GOTO START

  ECHO.
  ECHO Unsupported commandline switch!
  ECHO Run "%~nx0 help" for details about the commandline switches.
  CALL :SUBMSG "ERROR" "Compilation failed!"
)

:START
IF "%ARCH%" == "x64" GOTO x64
IF "%ARCH%" == "x86" GOTO x86

:x86
SET "INCLUDE=%WDKBASEDIR%\inc\api;%WDKBASEDIR%\inc\api\crt\stl70;%WDKBASEDIR%\inc\crt;%WDKBASEDIR%\inc\ddk"
SET "LIB=%WDKBASEDIR%\lib\crt\i386;%WDKBASEDIR%\lib\win7\i386"
SET "PATH=%WDKBASEDIR%\bin\x86;%WDKBASEDIR%\bin\x86\x86;%PATH%"

TITLE Building Notepad2-mod x86 with WDK...
ECHO. & ECHO.

CALL :SUBNMAKE

IF "%ARCH%" == "x86" GOTO END

:x64
IF DEFINED PROGRAMFILES(x86) (SET build_type=amd64) ELSE (SET build_type=x86_amd64)

SET "INCLUDE=%WDKBASEDIR%\inc\api;%WDKBASEDIR%\inc\api\crt\stl70;%WDKBASEDIR%\inc\crt;%WDKBASEDIR%\inc\ddk"
SET "LIB=%WDKBASEDIR%\lib\crt\amd64;%WDKBASEDIR%\lib\win7\amd64"
SET "PATH=%WDKBASEDIR%\bin\x86;%WDKBASEDIR%\bin\x86\amd64;%PATH%"

TITLE Building Notepad2-mod x64 with WDK...
ECHO. & ECHO.

CALL :SUBNMAKE "x64=1"

:END
TITLE Building Notepad2-mod with WDK - Finished!
ENDLOCAL
EXIT /B

:SUBNMAKE
nmake /NOLOGO /f "makefile.mak" %BUILDTYPE% %1
IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!"
EXIT /B

:SHOWHELP
TITLE %~nx0 %1
ECHO. & ECHO.
ECHO Usage: %~nx0 [Clean^|Build^|Rebuild] [x86^|x64^|all]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO        The arguments are not case sensitive.
ECHO. & ECHO.
ECHO Edit %~nx0 and set your WDK directory or define %%WDKBASEDIR%%.
ECHO You shouldn't need to make any changes other than that.
ECHO. & ECHO.
ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 build all"
ECHO.
ECHO If you skip the second argument the default one will be used. Example:
ECHO "%~nx0 rebuild" is the same as "%~nx0 rebuild all"
ECHO.
ECHO WARNING: "%~nx0 x86" won't work.
ECHO.
ENDLOCAL
EXIT /B

:SUBMSG
ECHO. & ECHO ______________________________
ECHO [%~1] %~2
ECHO ______________________________ & ECHO.
IF /I "%~1" == "ERROR" (
  PAUSE
  EXIT
) ELSE (
  EXIT /B
)

@ECHO OFF
rem ******************************************************************************
rem *
rem * Notepad2-mod
rem *
rem * build_wdk.bat
rem *   Batch file "wrapper" for makefile.mak, used to build Notepad2 with WDK
rem *
rem * See License.txt for details about distribution and modification.
rem *
rem *                                       (c) XhmikosR 2010-2013
rem *                                       https://github.com/XhmikosR/notepad2-mod
rem *
rem ******************************************************************************

SETLOCAL ENABLEEXTENSIONS
CD /D %~dp0

rem Set the WDK directory
IF NOT DEFINED WDKBASEDIR   SET "WDKBASEDIR=C:\WinDDK\7600.16385.1"
rem My new WDK location
IF NOT EXIST "%WDKBASEDIR%" SET "WDKBASEDIR=H:\WinDDK\7600.16385.1"

rem Check the building environment
IF NOT EXIST "%WDKBASEDIR%" CALL :SUBMSG "ERROR" "Specify your WDK directory!"

rem Check for the help switches
IF /I "%~1" == "help"   GOTO SHOWHELP
IF /I "%~1" == "/help"  GOTO SHOWHELP
IF /I "%~1" == "-help"  GOTO SHOWHELP
IF /I "%~1" == "--help" GOTO SHOWHELP
IF /I "%~1" == "/?"     GOTO SHOWHELP

rem Check for the first switch
IF "%~1" == "" (
  SET "BUILDTYPE=Build"
) ELSE (
  IF /I "%~1" == "Build"     SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "/Build"    SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "-Build"    SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "--Build"   SET "BUILDTYPE=Build"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "Clean"     SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "/Clean"    SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "-Clean"    SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "--Clean"   SET "BUILDTYPE=Clean"   & GOTO CHECKSECONDARG
  IF /I "%~1" == "Rebuild"   SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
  IF /I "%~1" == "/Rebuild"  SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
  IF /I "%~1" == "-Rebuild"  SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG
  IF /I "%~1" == "--Rebuild" SET "BUILDTYPE=Rebuild" & GOTO CHECKSECONDARG

  ECHO.
  ECHO Unsupported commandline switch!
  ECHO Run "%~nx0 help" for details about the commandline switches.
  CALL :SUBMSG "ERROR" "Compilation failed!"
)

:CHECKSECONDARG
rem Check for the second switch
IF "%~2" == "" (
  SET "ARCH=all"
) ELSE (
  IF /I "%~2" == "x86"   SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "/x86"  SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "-x86"  SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "--x86" SET "ARCH=x86" & GOTO START
  IF /I "%~2" == "x64"   SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "/x64"  SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "-x64"  SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "--x64" SET "ARCH=x64" & GOTO START
  IF /I "%~2" == "all"   SET "ARCH=all" & GOTO START
  IF /I "%~2" == "/all"  SET "ARCH=all" & GOTO START
  IF /I "%~2" == "-all"  SET "ARCH=all" & GOTO START
  IF /I "%~2" == "--all" SET "ARCH=all" & GOTO START

  ECHO.
  ECHO Unsupported commandline switch!
  ECHO Run "%~nx0 help" for details about the commandline switches.
  CALL :SUBMSG "ERROR" "Compilation failed!"
)

:START
IF "%ARCH%" == "x64" GOTO x64
IF "%ARCH%" == "x86" GOTO x86

:x86
SET "INCLUDE=%WDKBASEDIR%\inc\api;%WDKBASEDIR%\inc\api\crt\stl70;%WDKBASEDIR%\inc\crt;%WDKBASEDIR%\inc\ddk"
SET "LIB=%WDKBASEDIR%\lib\crt\i386;%WDKBASEDIR%\lib\win7\i386"
SET "PATH=%WDKBASEDIR%\bin\x86;%WDKBASEDIR%\bin\x86\x86;%PATH%"

TITLE Building Notepad2-mod x86 with WDK...
ECHO. & ECHO.

CALL :SUBNMAKE

IF "%ARCH%" == "x86" GOTO END

:x64
IF DEFINED PROGRAMFILES(x86) (SET build_type=amd64) ELSE (SET build_type=x86_amd64)

SET "INCLUDE=%WDKBASEDIR%\inc\api;%WDKBASEDIR%\inc\api\crt\stl70;%WDKBASEDIR%\inc\crt;%WDKBASEDIR%\inc\ddk"
SET "LIB=%WDKBASEDIR%\lib\crt\amd64;%WDKBASEDIR%\lib\win7\amd64"
SET "PATH=%WDKBASEDIR%\bin\x86;%WDKBASEDIR%\bin\x86\amd64;%PATH%"

TITLE Building Notepad2-mod x64 with WDK...
ECHO. & ECHO.

CALL :SUBNMAKE "x64=1"

:END
TITLE Building Notepad2-mod with WDK - Finished!
ENDLOCAL
EXIT /B

:SUBNMAKE
nmake /NOLOGO /f "makefile.mak" %BUILDTYPE% %1
IF %ERRORLEVEL% NEQ 0 CALL :SUBMSG "ERROR" "Compilation failed!"
EXIT /B

:SHOWHELP
TITLE %~nx0 %1
ECHO. & ECHO.
ECHO Usage: %~nx0 [Clean^|Build^|Rebuild] [x86^|x64^|all]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO        The arguments are not case sensitive.
ECHO. & ECHO.
ECHO Edit %~nx0 and set your WDK directory or define %%WDKBASEDIR%%.
ECHO You shouldn't need to make any changes other than that.
ECHO. & ECHO.
ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 build all"
ECHO.
ECHO If you skip the second argument the default one will be used. Example:
ECHO "%~nx0 rebuild" is the same as "%~nx0 rebuild all"
ECHO.
ECHO WARNING: "%~nx0 x86" won't work.
ECHO.
ENDLOCAL
EXIT /B

:SUBMSG
ECHO. & ECHO ______________________________
ECHO [%~1] %~2
ECHO ______________________________ & ECHO.
IF /I "%~1" == "ERROR" (
  PAUSE
  EXIT
) ELSE (
  EXIT /B
)

build/build_wdk.bat: update for the new location on my machine


rem I want to see my commands when they go wrong...
echo on

mkdir %SCRIPTS%
if errorlevel 1 exit 1

rem inkscape.exe is the GUI, the .com is the commandline utility we need in other packages

rem compile using the MS compilers
cl -DGUI=0 -DDEBUG=0 "%RECIPE_DIR%\wrapper.c"
if errorlevel 1 exit 1

dumpbin /IMPORTS wrapper.exe

copy "wrapper.exe" "%SCRIPTS%\inkscape.exe"
if errorlevel 1 exit 1

del wrapper.exe
del wrapper.obj

rem last to see compile errors faster...
7za x Inkscape-0.91-1.7z -o%LIBRARY_PREFIX%
if errorlevel 1 exit 1

rem I want to see my commands when they go wrong...
echo on

if not exist %SCRIPTS% mkdir %SCRIPTS% || exit 1

rem inkscape.exe is the GUI, the .com is the commandline utility we need in other packages

rem compile using the MS compilers
cl -DGUI=0 -DDEBUG=0 "%RECIPE_DIR%\wrapper.c"
if errorlevel 1 exit 1

dumpbin /IMPORTS wrapper.exe

copy "wrapper.exe" "%SCRIPTS%\inkscape.exe"
if errorlevel 1 exit 1

del wrapper.exe
del wrapper.obj

rem last to see compile errors faster...
7za x Inkscape-0.91-1.7z -o%LIBRARY_PREFIX%
if errorlevel 1 exit 1

Fix SCRIPTS creation

Fix SCRIPTS creation


"%R%" CMD INSTALL --build . %R_ARGS%
IF %ERRORLEVEL% NEQ 0 exit /B 1

Update bld.bat

Update bld.bat


Bump version number.

Bump version number.


@call ..\tools\build.bat pvpanic.sln "Wlh Win7 Win8 Win10" %*
@call ..\tools\build.bat pvpanic\pvpanic.vcxproj "Win10_SDV"

add SDV run to engineering build

pvpanic: add SDV run to engineering build

Run the SDV from 'buildall' batch of the project.
It is not used by release build.

Signed-off-by: Yuri Benditovich <9668326cb042de5d91fd7679dac7ca5ea402812c@daynix.com>


Update connect.cmd

Update connect.cmd


@rem See notes.md for more information about all of this.

@rem Compile the launcher

@rem XXX: Should we build Rgui with -DGUI=1 -mwindows?  The only difference is
@rem that that it doesn't block the terminal, but we also can't get the return
@rem value for the conda build tests.

gcc -DGUI=0 -O -s -o launcher.exe "%RECIPE_DIR%\launcher.c"
if errorlevel 1 exit 1

@rem Install the launcher

if not exist "%PREFIX%\Scripts" mkdir "%PREFIX%\Scripts"
if errorlevel 1 exit 1

copy launcher.exe "%PREFIX%\Scripts\R.exe"
if errorlevel 1 exit 1

copy launcher.exe "%PREFIX%\Scripts\Rcmd.exe"
if errorlevel 1 exit 1

copy launcher.exe "%PREFIX%\Scripts\RSetReg.exe"
if errorlevel 1 exit 1

copy launcher.exe "%PREFIX%\Scripts\Rfe.exe"
if errorlevel 1 exit 1

copy launcher.exe "%PREFIX%\Scripts\Rgui.exe"
if errorlevel 1 exit 1

copy launcher.exe "%PREFIX%\Scripts\Rscript.exe"
if errorlevel 1 exit 1

copy launcher.exe "%PREFIX%\Scripts\Rterm.exe"
if errorlevel 1 exit 1

@rem XXX: Should we skip this one?
copy launcher.exe "%PREFIX%\Scripts\open.exe"
if errorlevel 1 exit 1

copy "%RECIPE_DIR%\build.sh" .
set PREFIX=%PREFIX:\=/%
set SRC_DIR=%SRC_DIR:\=/%
set MSYSTEM=MINGW%ARCH%
set MSYS2_PATH_TYPE=inherit
set CHERE_INVOKING=1
bash -lc "./build.sh"
if errorlevel 1 exit 1
exit 0

fix r bad stage [skip ci][skip appveyor]


update jars in release

ADAP-42: update jars in release


@ECHO off
SETLOCAL enabledelayedexpansion
cls
COLOR 1f

ECHO.
ECHO.
ECHO   ##############################################################
ECHO   #               ӭʹ SOUI                    #
ECHO   #                                 2014.10.31         #
ECHO   ##############################################################
ECHO.
ECHO.

SET cfg=
SET specs=
SET target=x86
SET selected=
rem ѡ汾
SET /p selected=1.ѡ汾[1=x86;2=x64]:
if %selected%==1 (
	SET target=x86
) else if %selected%==2 (
	SET target=x64
	SET cfg=!cfg! x64
) else (
	goto error
)

rem ѡ񿪷
SET /p selected=2.ѡ񿪷[1=vs2008;2=vs2010;3=vs2012;4=vs2013]:
if %selected%==1 (
	SET specs=win32-msvc2008
	call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else if %selected%==2 (
	SET specs=win32-msvc2010
	call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else if %selected%==3 (
	SET specs=win32-msvc2010
	call "%VS110COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else if %selected%==4 (
	SET specs=win32-msvc2010
	call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else (
	goto error
)

rem ѡ
SET /p selected=3.ѡSOUIģʽ[1=ȫģDLL;2=ȫģLIB;3=ںLIB,DLL(ʹLUAűģ)]:
if %selected%==1 (
	rem do nothing
) else if %selected%==2 (
	SET cfg=!cfg! LIB_ALL
) else if %selected%==3 (
	SET cfg=!cfg! CORE_LIB
) else (
	goto error
)

rem ѡַ
SET /p selected=4.ѡַ[1=UNICODE;2=MBCS]:
if %selected%==1 (
	rem do nothing
) else if %selected%==2 (
	SET cfg=!cfg! MBCS
) else (
	goto error
)

rem CLR
SET /p selected=5.ѡCLR[1=֧;2=֧]:
if %selected%==1 (
	rem do nothing
) else if %selected%==2 (
	SET cfg=!cfg! USING_CLR
) else (
	goto error
)

rem CRT
SET /p selected=6.ѡCRTģʽ[1=̬(MT);2=̬(MD)]:
if %selected%==1 (
	SET cfg=!cfg! USING_MT
) else if %selected%==2 (
	rem do nothing
) else (
	goto error
)

rem Ϊrelease汾ɵϢ
SET /p selected=7.ǷΪrelease汾ɵϢ[1=;2=]:
if %selected%==1 (
	SET cfg=!cfg! CAN_DEBUG
) else if %selected%==2 (
	rem do nothing
) else (
	goto error
)

rem

tools\qmake -tp vc -r -spec .\tools\mkspecs\%specs% "CONFIG += %cfg%"

SET /p selected=open[o], compile[c] "soui.sln" or quit(q) [o,c or q]?
if "%selected%" == "o" (
	soui.sln
) else if "%selected%" == "c" (
	call devenv soui.sln /Clean Debug
	call devenv soui.sln /build Debug
	call devenv soui.sln /Clean Release
	call devenv soui.sln /build Release
) else (
	goto final
)

goto final

:error
	ECHO ѡѡ

:final

rem pause

@ECHO off
SETLOCAL enabledelayedexpansion
cls
COLOR 1f

ECHO.
ECHO.
ECHO   ##############################################################
ECHO   #               ~{;6S-J9SC~} SOUI ~{9$3LEdVCOr5<~}                   #
ECHO   #                                ~{Ft3LHm<~~} 2014.10.31         #
ECHO   ##############################################################
ECHO.
ECHO.

SET cfg=
SET specs=
SET target=x86
SET selected=
rem ~{Q!Tq1`Rk0f1>~}
SET /p selected=1.~{Q!Tq1`Rk0f1>~}[1=x86;2=x64]:
if %selected%==1 (
	SET target=x86
) else if %selected%==2 (
	SET target=x64
	SET cfg=!cfg! x64
) else (
	goto error
)

rem ~{Q!Tq?*7";7>3~}
SET /p selected=2.~{Q!Tq?*7";7>3~}[1=vs2008;2=vs2010;3=vs2012;4=vs2013]:
if %selected%==1 (
	SET specs=win32-msvc2008
	call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else if %selected%==2 (
	SET specs=win32-msvc2010
	call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else if %selected%==3 (
	SET specs=win32-msvc2010
	call "%VS110COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else if %selected%==4 (
	SET specs=win32-msvc2010
	call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" %target%
) else (
	goto error
)

rem ~{Q!Tq1`Rk@`PM~}
SET /p selected=3.~{Q!Tq~}SOUI~{1`RkD#J=~}[1=~{H+D#?i~}DLL;2=~{H+D#?i~}LIB;3=~{DZ:K~}LIB,~{Wi<~~}DLL(~{2;D\J9SC~}LUA~{=E1>D#?i~})]:
if %selected%==1 (
	rem do nothing
) else if %selected%==2 (
	SET cfg=!cfg! LIB_ALL
) else if %selected%==3 (
	SET cfg=!cfg! CORE_LIB
) else (
	goto error
)

rem ~{Q!TqWV7{</~}
SET /p selected=4.~{Q!TqWV7{</~}[1=UNICODE;2=MBCS]:
if %selected%==1 (
	rem do nothing
) else if %selected%==2 (
	SET cfg=!cfg! MBCS
) else (
	goto error
)

rem CLR
rem SET /p selected=5.~{Q!Tq~}CLR~{?*9X~}[1=~{2;V'3V~};2=~{V'3V~}]:
rem if %selected%==1 (
rem 	rem do nothing
rem ) else if %selected%==2 (
rem 	SET cfg=!cfg! USING_CLR
rem ) else (
rem 	goto error
rem )

rem CRT
SET /p selected=6.~{Q!Tq~}CRT~{A4=SD#J=~}[1=~{>2L,A4=S~}(MT);2=~{6/L,A4=S~}(MD)]:
if %selected%==1 (
	SET cfg=!cfg! USING_MT
) else if %selected%==2 (
	rem do nothing
) else (
	goto error
)

rem ~{N*~}release~{0f1>Iz3I5wJTPEO"~}
SET /p selected=7.~{JG7qN*~}release~{0f1>Iz3I5wJTPEO"~}[1=~{Iz3I~};2=~{2;Iz3I~}]:
if %selected%==1 (
	SET cfg=!cfg! CAN_DEBUG
) else if %selected%==2 (
	rem do nothing
) else (
	goto error
)

rem ~{2NJ}EdVCMj3I~}

tools\qmake -tp vc -r -spec .\tools\mkspecs\%specs% "CONFIG += %cfg%"

SET /p selected=open[o], compile[c] "soui.sln" or quit(q) [o,c or q]?
if "%selected%" == "o" (
	soui.sln
) else if "%selected%" == "c" (
	call devenv soui.sln /Clean Debug
	call devenv soui.sln /build Debug
	call devenv soui.sln /Clean Release
	call devenv soui.sln /build Release
) else (
	goto final
)

goto final

:error
	ECHO ~{Q!Tq4mNs#,GkVXPBQ!Tq~}

:final

rem pause

remove clr option

remove clr option

git-svn-id: e73ed5729e8a80b2abdf7172f0ddcef20fd85307@828 5312f6f6-3d4f-41ab-b741-a9c9e676edf4


where timeout
timeout --help
@echo off

set python=%1
if "%1"=="" (
    set python=pypy --jit off -B
    goto START_TEST
)

REM download python from Single Binary Stackless Python
if EXIST C:\Ruby23\bin\ruby.exe (
    set RUBY_EXE=C:\Ruby23\bin\ruby.exe
) else (
    set RUBY_EXE=ruby.exe
)
if "%2"=="2" (
    %RUBY_EXE% test\download_python.rb %python% 2
) else if "%2"=="3" (
    %RUBY_EXE% test\download_python.rb %python% 3
)

:START_TEST
echo Using %python%

del test\test_result.txt teststate.bin command_after_test.txt test\test_result_info.txt test\test_result_simple.txt test\test_result_general.txt > NUL 2>&1

%python% test/test_pause_while_exception_handling.py >> test/test_result_general.txt
if NOT EXIST teststate.bin exit /b 1
%python% test/test_pause_while_exception_handling.py >> test/test_result_general.txt
if NOT EXIST teststate.bin exit /b 1
%python% test/test_pause_while_exception_handling.py >> test/test_result_general.txt
if EXIST teststate.bin exit /b 1

%python% test/check_general_result.py 2
if ERRORLEVEL 1 exit /b 1
del test\test_result_general.txt
set /P x=.<NUL

rem test.py
for /l %%i in (0, 1, 7) do (
    %python% test/test.py debug >> test/test_result.txt
    if ERRORLEVEL 1 exit /b 1
    timeout /T 1 /NOBREAK > NUL
)

for /l %%i in (0, 1, 7) do (
    %python% test/test.py >> test/test_result_info.txt
    if ERRORLEVEL 1 exit /b 1
    timeout /T 1 /NOBREAK > NUL
)

%python% test/check_result.py > NUL
if ERRORLEVEL 1 exit /b 1
set /P x=.<NUL

rem test_command_after_test.py
%python% test/test_command_after_test.py > NUL
if ERRORLEVEL 1 exit /b 1
if EXIST command_after_test.txt exit /b 1

%python% test/test_command_after_test.py > NUL
if ERRORLEVEL 1 exit /b 1
if NOT EXIST command_after_test.txt exit /b 1

set /P x=.<NUL

%python% test/test_pickle_handling.py > NUL
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

set /P x=.<NUL

%python% test/test_pauser.py > NUL
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

set /P x=.<NUL

%python% test/test_simple_runner.py >> test/test_result_simple.txt
if ERRORLEVEL 1 exit /b 1
if NOT EXIST teststate.bin exit /b 1

%python% test/test_simple_runner.py >> test/test_result_simple.txt
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

%python% test/check_simple_runner_result.py > NUL
if ERRORLEVEL 1 exit /b 1

set /P x=.<NUL

%python% test/test_failure_of_exec_for_reboot.py > NUL 2>&1
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

set /P x=.<NUL

%python% test/test_exec_callback.py > test/test_result_general.txt
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1
%python% test/check_general_result.py 1
if ERRORLEVEL 1 exit /b 1

set /P x=.<NUL

echo.
echo OK
exit /b 0

Add debug code.

Add debug code.


@echo off

set python=%1
if "%1"=="" (
    set python=pypy --jit off -B
)
echo Using %python%

del test\test_result.txt teststate.bin command_after_test.txt test\test_result_info.txt test\test_result_simple.txt > NUL 2>&1

rem test.py
for /l %%i in (0, 1, 7) do (
    %python% test/test.py debug >> test/test_result.txt
    if ERRORLEVEL 1 exit /b 1
    timeout /T 1 /NOBREAK > NUL
)

for /l %%i in (0, 1, 7) do (
    %python% test/test.py >> test/test_result_info.txt
    if ERRORLEVEL 1 exit /b 1
    timeout /T 1 /NOBREAK > NUL
)

%python% test/check_result.py > NUL
if ERRORLEVEL 1 exit /b 1
set /P x=.<NUL

rem test_command_after_test.py
%python% test/test_command_after_test.py > NUL
if ERRORLEVEL 1 exit /b 1
if EXIST command_after_test.txt exit /b 1

%python% test/test_command_after_test.py > NUL
if ERRORLEVEL 1 exit /b 1
if NOT EXIST command_after_test.txt exit /b 1

set /P x=.<NUL

%python% test/test_pickle_handling.py > NUL
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

set /P x=.<NUL

%python% test/test_pauser.py > NUL
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

set /P x=.<NUL

%python% test/test_simple_runner.py >> test/test_result_simple.txt
if ERRORLEVEL 1 exit /b 1
if NOT EXIST teststate.bin exit /b 1

%python% test/test_simple_runner.py >> test/test_result_simple.txt
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

%python% test/check_simple_runner_result.py > NUL
if ERRORLEVEL 1 exit /b 1

set /P x=.<NUL

%python% test/test_failure_of_exec_for_reboot.py > NUL 2>&1
if ERRORLEVEL 1 exit /b 1
if EXIST teststate.bin exit /b 1

set /P x=.<NUL

echo.
echo OK
exit /b 0

Exit with 0.

Exit with 0.


@echo off

:: This script parses args, installs required libraries (miniconda, MKL,
:: Magma), and then delegates to cpu.bat, cuda80.bat, etc.

IF NOT "%CUDA_VERSION%" == "" IF NOT "%TORCHVISION_BUILD_VERSION%" == "" if NOT "%TORCHVISION_BUILD_NUMBER%" == "" goto env_end
if "%~1"=="" goto arg_error
if "%~2"=="" goto arg_error
if "%~3"=="" goto arg_error
if NOT "%~4"=="" goto arg_error
goto arg_end

:arg_error

echo Illegal number of parameters. Pass cuda version, pytorch version, build number
echo CUDA version should be Mm with no dot, e.g. '80'
echo DESIRED_PYTHON should be M.m, e.g. '2.7'
exit /b 1

:arg_end

set CUDA_VERSION=%~1
set TORCHVISION_BUILD_VERSION=%~2
set TORCHVISION_BUILD_NUMBER=%~3

set BUILD_VERSION=%TORCHVISION_BUILD_VERSION%

:env_end

if NOT "%CUDA_VERSION%" == "cpu" (
    set CUDA_PREFIX=cuda%CUDA_VERSION%
    set CUVER=cu%CUDA_VERSION%
    set FORCE_CUDA=1
) else (
    set CUDA_PREFIX=cpu
    set CUVER=cpu
)

set BUILD_VISION=1
REM set TORCH_WHEEL=torch -f https://download.pytorch.org/whl/%CUVER%/stable.html --no-index

IF "%DESIRED_PYTHON%" == "" set DESIRED_PYTHON=3.5;3.6;3.7
set DESIRED_PYTHON_PREFIX=%DESIRED_PYTHON:.=%
set DESIRED_PYTHON_PREFIX=py%DESIRED_PYTHON_PREFIX:;=;py%

set SRC_DIR=%~dp0
pushd %SRC_DIR%

:: Install Miniconda3
set "CONDA_HOME=%CD%\conda"
set "tmp_conda=%CONDA_HOME%"
set "miniconda_exe=%CD%\miniconda.exe"
rmdir /s /q conda
del miniconda.exe
curl -k https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe -o "%miniconda_exe%"
call ..\conda\install_conda.bat
IF ERRORLEVEL 1 exit /b 1
set "ORIG_PATH=%PATH%"
set "PATH=%CONDA_HOME%;%CONDA_HOME%\scripts;%CONDA_HOME%\Library\bin;%PATH%"

:: Create a new conda environment
setlocal EnableDelayedExpansion
FOR %%v IN (%DESIRED_PYTHON%) DO (
    set PYTHON_VERSION_STR=%%v
    set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
    conda remove -n py!PYTHON_VERSION_STR! --all -y || rmdir %CONDA_HOME%\envs\py!PYTHON_VERSION_STR! /s
    conda create -n py!PYTHON_VERSION_STR! -y -q -c defaults -c conda-forge numpy>=1.11 mkl>=2018 python=%%v ca-certificates scipy av
)

:: Uncomment for stable releases
:: FOR %%v IN (%DESIRED_PYTHON%) DO (
::     set PYTHON_VERSION_STR=%%v
::     set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
::     set "PATH=%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\scripts;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\Library\bin;%ORIG_PATH%"

::     if "%CUDA_VERSION%" == "100" (
::         set TORCH_WHEEL=https://download.pytorch.org/whl/%CUVER%/torch-1.2.0-cp!PYTHON_VERSION_STR!-cp!PYTHON_VERSION_STR!m-win_amd64.whl
::     ) else (
::         set TORCH_WHEEL=https://download.pytorch.org/whl/%CUVER%/torch-1.2.0%%2B%CUVER%-cp!PYTHON_VERSION_STR!-cp!PYTHON_VERSION_STR!m-win_amd64.whl
::     )
::     echo Installing !TORCH_WHEEL!...
::     pip install "!TORCH_WHEEL!"
:: )

:: Uncomment for nightly releases
FOR %%v IN (%DESIRED_PYTHON%) DO (
    set PYTHON_VERSION_STR=%%v
    set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
    set "PATH=%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\scripts;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\Library\bin;%ORIG_PATH%"

    set TORCH_WHEEL=torch --pre -f https://download.pytorch.org/whl/nightly/%CUVER%/torch_nightly.html
    echo Installing !TORCH_WHEEL!...
    pip install !TORCH_WHEEL!
)

endlocal

if "%DEBUG%" == "1" (
    set BUILD_TYPE=debug
) ELSE (
    set BUILD_TYPE=release
)

:: Install sccache
if "%USE_SCCACHE%" == "1" (
    mkdir %CD%\tmp_bin
    curl -k https://s3.amazonaws.com/ossci-windows/sccache.exe --output %CD%\tmp_bin\sccache.exe
    if not "%CUDA_VERSION%" == "" (
        copy %CD%\tmp_bin\sccache.exe %CD%\tmp_bin\nvcc.exe

        set CUDA_NVCC_EXECUTABLE=%CD%\tmp_bin\nvcc
        set "PATH=%CD%\tmp_bin;%PATH%"
    )
)

for %%v in (%DESIRED_PYTHON_PREFIX%) do (
    :: Activate Python Environment
    set PYTHON_PREFIX=%%v
    set "PATH=%CONDA_HOME%\envs\%%v;%CONDA_HOME%\envs\%%v\scripts;%CONDA_HOME%\envs\%%v\Library\bin;%ORIG_PATH%"
    @setlocal
    :: Set Flags
    if NOT "%CUDA_VERSION%"=="cpu" (
        set CUDNN_VERSION=7
    )
    call %CUDA_PREFIX%.bat
    IF ERRORLEVEL 1 exit /b 1
    call internal\test.bat
    IF ERRORLEVEL 1 exit /b 1
    @endlocal
)

set "PATH=%ORIG_PATH%"
popd

IF ERRORLEVEL 1 exit /b 1

@echo off

:: This script parses args, installs required libraries (miniconda, MKL,
:: Magma), and then delegates to cpu.bat, cuda80.bat, etc.

IF NOT "%CUDA_VERSION%" == "" IF NOT "%TORCHVISION_BUILD_VERSION%" == "" if NOT "%TORCHVISION_BUILD_NUMBER%" == "" goto env_end
if "%~1"=="" goto arg_error
if "%~2"=="" goto arg_error
if "%~3"=="" goto arg_error
if NOT "%~4"=="" goto arg_error
goto arg_end

:arg_error

echo Illegal number of parameters. Pass cuda version, pytorch version, build number
echo CUDA version should be Mm with no dot, e.g. '80'
echo DESIRED_PYTHON should be M.m, e.g. '2.7'
exit /b 1

:arg_end

set CUDA_VERSION=%~1
set TORCHVISION_BUILD_VERSION=%~2
set TORCHVISION_BUILD_NUMBER=%~3

set BUILD_VERSION=%TORCHVISION_BUILD_VERSION%

:env_end

if NOT "%CUDA_VERSION%" == "cpu" (
    set CUDA_PREFIX=cuda%CUDA_VERSION%
    set CUVER=cu%CUDA_VERSION%
    set FORCE_CUDA=1
) else (
    set CUDA_PREFIX=cpu
    set CUVER=cpu
)

set BUILD_VISION=1
REM set TORCH_WHEEL=torch -f https://download.pytorch.org/whl/%CUVER%/stable.html --no-index

IF "%DESIRED_PYTHON%" == "" set DESIRED_PYTHON=3.5;3.6;3.7
set DESIRED_PYTHON_PREFIX=%DESIRED_PYTHON:.=%
set DESIRED_PYTHON_PREFIX=py%DESIRED_PYTHON_PREFIX:;=;py%

set SRC_DIR=%~dp0
pushd %SRC_DIR%

:: Install Miniconda3
set "CONDA_HOME=%CD%\conda"
set "tmp_conda=%CONDA_HOME%"
set "miniconda_exe=%CD%\miniconda.exe"
rmdir /s /q conda
del miniconda.exe
curl -k https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe -o "%miniconda_exe%"
call ..\conda\install_conda.bat
IF ERRORLEVEL 1 exit /b 1
set "ORIG_PATH=%PATH%"
set "PATH=%CONDA_HOME%;%CONDA_HOME%\scripts;%CONDA_HOME%\Library\bin;%PATH%"

:: Create a new conda environment
setlocal EnableDelayedExpansion
FOR %%v IN (%DESIRED_PYTHON%) DO (
    set PYTHON_VERSION_STR=%%v
    set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
    conda remove -n py!PYTHON_VERSION_STR! --all -y || rmdir %CONDA_HOME%\envs\py!PYTHON_VERSION_STR! /s
    conda create -n py!PYTHON_VERSION_STR! -y -q -c defaults -c conda-forge numpy>=1.11 mkl>=2018 python=%%v ca-certificates scipy av
)

:: Uncomment for stable releases
:: FOR %%v IN (%DESIRED_PYTHON%) DO (
::     set PYTHON_VERSION_STR=%%v
::     set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
::     set "PATH=%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\scripts;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\Library\bin;%ORIG_PATH%"

::     if "%CUDA_VERSION%" == "100" (
::         set TORCH_WHEEL=https://download.pytorch.org/whl/%CUVER%/torch-1.2.0-cp!PYTHON_VERSION_STR!-cp!PYTHON_VERSION_STR!m-win_amd64.whl
::     ) else (
::         set TORCH_WHEEL=https://download.pytorch.org/whl/%CUVER%/torch-1.2.0%%2B%CUVER%-cp!PYTHON_VERSION_STR!-cp!PYTHON_VERSION_STR!m-win_amd64.whl
::     )
::     echo Installing !TORCH_WHEEL!...
::     pip install "!TORCH_WHEEL!"
:: )

:: Uncomment for nightly releases
FOR %%v IN (%DESIRED_PYTHON%) DO (
    set PYTHON_VERSION_STR=%%v
    set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
    set "PATH=%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\scripts;%CONDA_HOME%\envs\py!PYTHON_VERSION_STR!\Library\bin;%ORIG_PATH%"

    set TORCH_WHEEL=torch --pre -f https://download.pytorch.org/whl/nightly/%CUVER%/torch_nightly.html
    echo Installing !TORCH_WHEEL!...
    pip install !TORCH_WHEEL!
)

endlocal

if "%DEBUG%" == "1" (
    set BUILD_TYPE=debug
) ELSE (
    set BUILD_TYPE=release
)

:: Install sccache
if "%USE_SCCACHE%" == "1" (
    mkdir %CD%\tmp_bin
    curl -k https://s3.amazonaws.com/ossci-windows/sccache.exe --output %CD%\tmp_bin\sccache.exe
    if not "%CUDA_VERSION%" == "" (
        copy %CD%\tmp_bin\sccache.exe %CD%\tmp_bin\nvcc.exe

        set CUDA_NVCC_EXECUTABLE=%CD%\tmp_bin\nvcc
        set "PATH=%CD%\tmp_bin;%PATH%"
    )
)

for %%v in (%DESIRED_PYTHON_PREFIX%) do (
    :: Activate Python Environment
    set PYTHON_PREFIX=%%v
    set "PATH=%CONDA_HOME%\envs\%%v;%CONDA_HOME%\envs\%%v\scripts;%CONDA_HOME%\envs\%%v\Library\bin;%ORIG_PATH%"
    if defined INCLUDE (
        set "INCLUDE=%INCLUDE%;%CONDA_HOME%\envs\%%v\Library\include"
    ) else (
        set "INCLUDE=%CONDA_HOME%\envs\%%v\Library\include"
    )
    if defined LIB (
        set "LIB=%LIB%;%CONDA_HOME%\envs\%%v\Library\lib"
    ) else (
        set "LIB=%CONDA_HOME%\envs\%%v\Library\lib"
    )
    @setlocal
    :: Set Flags
    if NOT "%CUDA_VERSION%"=="cpu" (
        set CUDNN_VERSION=7
    )
    call %CUDA_PREFIX%.bat
    IF ERRORLEVEL 1 exit /b 1
    call internal\test.bat
    IF ERRORLEVEL 1 exit /b 1
    @endlocal
)

set "PATH=%ORIG_PATH%"
popd

IF ERRORLEVEL 1 exit /b 1

Fix nightly wheels builds for Windows (#1358)


docker-compose up --force-recreate --build -d

Add rebuild script

Add rebuild script