1@echo off 2rem based on scalac.bat from the Scala distribution 3rem ########################################################################## 4rem # Copyright 2002-2011, LAMP/EPFL 5rem # Copyright 2011-2015, JetBrains 6rem # 7rem # This is free software; see the distribution for copying conditions. 8rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 9rem # PARTICULAR PURPOSE. 10rem ########################################################################## 11 12rem We adopt the following conventions: 13rem - System/user environment variables start with a letter 14rem - Local batch variables start with an underscore ('_') 15 16setlocal 17call :set_home 18 19if "%_KOTLIN_COMPILER%"=="" set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler 20 21if not "%JAVA_HOME%"=="" ( 22 if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe" 23) 24 25if "%_JAVACMD%"=="" set _JAVACMD=java 26 27rem We use the value of the JAVA_OPTS environment variable if defined 28if "%JAVA_OPTS%"=="" set JAVA_OPTS=-Xmx256M -Xms32M 29 30rem Iterate through arguments and split them into java and kotlin ones 31:loop 32set _arg=%~1 33if "%_arg%" == "" goto loopend 34 35if "%_arg:~0,2%"=="-J" ( 36 set JAVA_OPTS=%JAVA_OPTS% "%_arg:~2%" 37) else ( 38 if "%_arg:~0,2%"=="-D" ( 39 set JAVA_OPTS=%JAVA_OPTS% "%_arg%" 40 ) else ( 41 set KOTLIN_OPTS=%KOTLIN_OPTS% "%_arg%" 42 ) 43) 44shift 45goto loop 46:loopend 47 48if "%_KOTLIN_RUNNER%"=="1" ( 49 "%_JAVACMD%" %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^ 50 org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS% 51) else ( 52 setlocal EnableDelayedExpansion 53 SET _ADDITIONAL_CLASSPATH= 54 55 if not "%_KOTLIN_TOOL%"=="" ( 56 set _ADDITIONAL_CLASSPATH=;%_KOTLIN_HOME%\lib\%_KOTLIN_TOOL% 57 ) 58 59 "%_JAVACMD%" %JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^ 60 org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar!_ADDITIONAL_CLASSPATH!" ^ 61 %_KOTLIN_COMPILER% %KOTLIN_OPTS% 62) 63 64exit /b %ERRORLEVEL% 65goto end 66 67rem ########################################################################## 68rem # subroutines 69 70:set_home 71 set _BIN_DIR= 72 for %%i in (%~sf0) do set _BIN_DIR=%_BIN_DIR%%%~dpsi 73 set _KOTLIN_HOME=%_BIN_DIR%.. 74goto :eof 75 76:end 77endlocal 78 79