forked from JetBrains/kotlin-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_konan.bat
105 lines (84 loc) · 3.04 KB
/
run_konan.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@echo off
rem based on scalac.bat from the Scala distribution
rem ##########################################################################
rem # Copyright 2002-2011, LAMP/EPFL
rem # Copyright 2011-2017, JetBrains
rem #
rem # This is free software; see the distribution for copying conditions.
rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
rem # PARTICULAR PURPOSE.
rem ##########################################################################
setlocal enabledelayedexpansion
call :set_home
call :set_path
set "TOOL_NAME=%1"
shift
if "%_TOOL_CLASS%"=="" set _TOOL_CLASS=org.jetbrains.kotlin.cli.utilities.MainKt
if not "%JAVA_HOME%"=="" (
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
)
if "%_JAVACMD%"=="" set _JAVACMD=java
set JAVA_ARGS=
set KONAN_ARGS=
:again
set "ARG=%1"
if not "!ARG!" == "" (
if "!ARG:~0,2!" == "-D" (
set "JAVA_ARGS=%JAVA_ARGS% %ARG%"
goto next
)
if "!ARG:~0,2!" == "-J" (
set "JAVA_ARGS=%JAVA_ARGS% !ARG:~2!"
goto next
)
if "!ARG:~0,2!" == "-X" (
echo "TODO: need to pass arguments to all the tools somehow."
goto next
)
if "!ARG!" == "--time" (
set "KONAN_ARGS=%KONAN_ARGS% --time"
set "JAVA_ARGS=%JAVA_ARGS% -agentlib:hprof=cpu=samples -Dkonan.profile=true"
goto next
)
set "KONAN_ARGS=%KONAN_ARGS% %ARG%"
:next
shift
goto again
)
set "NATIVE_LIB=%_KONAN_HOME%\konan\nativelib"
set "KONAN_LIB=%_KONAN_HOME%\konan\lib"
set "SHARED_JAR=%KONAN_LIB%\shared.jar"
set "INTEROP_INDEXER_JAR=%KONAN_LIB%\Indexer.jar"
set "INTEROP_RUNTIME_JAR=%KONAN_LIB%\Runtime.jar"
set "KLIB_JAR=%KONAN_LIB%\klib.jar"
set "KONAN_JAR=%KONAN_LIB%\backend.native.jar"
set "KOTLIN_JAR=%KONAN_LIB%\kotlin-compiler.jar"
set "KOTLIN_STDLIB_JAR=%KONAN_LIB%\kotlin-stdlib.jar"
set "KOTLIN_REFLECT_JAR=%KONAN_LIB%\kotlin-stdlib.jar"
set "KOTLIN_SCRIPT_RUNTIME_JAR=%KONAN_LIB%\kotlin-script-runtime.jar"
set "STUB_GENERATOR_JAR=%KONAN_LIB%\StubGenerator.jar"
set "UTILITIES_JAR=%KONAN_LIB%\utilities.jar"
set "KONAN_CLASSPATH=%KOTLIN_JAR%;%KOTLIN_STDLIB_JAR%;%KOTLIN_REFLECT_JAR%;%KOTLIN_SCRIPT_RUNTIME_JAR%;%INTEROP_RUNTIME_JAR%;%KONAN_JAR%;%STUB_GENERATOR_JAR%;%INTEROP_INDEXER_JAR%;%SHARED_JAR%;%KLIB_JAR%;%UTILITIES_JAR%"
set JAVA_OPTS=-ea ^
-Xmx3G ^
"-Djava.library.path=%NATIVE_LIB%" ^
"-Dkonan.home=%_KONAN_HOME%" ^
-Dfile.encoding=UTF-8
set LIBCLANG_DISABLE_CRASH_RECOVERY=1
"%_JAVACMD%" %JAVA_OPTS% %JAVA_ARGS% -cp "%KONAN_CLASSPATH%" %_TOOL_CLASS% %TOOL_NAME% %KONAN_ARGS%
exit /b %ERRORLEVEL%
goto end
rem ##########################################################################
rem # subroutines
:set_home
set _BIN_DIR=
for %%i in (%~sf0) do set _BIN_DIR=%_BIN_DIR%%%~dpsi
set _KONAN_HOME=%_BIN_DIR%..
goto :eof
:set_path
rem libclang.dll is dynamically linked and thus requires correct PATH to be loaded.
rem TODO: remove this hack.
set "PATH=%_KONAN_HOME%\dependencies\msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64\bin;%PATH%"
goto :eof
:end
endlocal