-
Notifications
You must be signed in to change notification settings - Fork 5
/
scalac.bat
124 lines (107 loc) · 3.69 KB
/
scalac.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@echo off
setlocal enabledelayedexpansion
@rem #########################################################################
@rem ## Environment setup
set _EXITCODE=0
for %%f in ("%~dp0.") do (
set "_PROG_HOME=%%~dpf"
@rem get rid of the trailing slash
set "_PROG_HOME=!_PROG_HOME:~0,-1!"
)
call "%_PROG_HOME%\bin\common.bat"
if not %_EXITCODE%==0 goto end
call :args %*
@rem #########################################################################
@rem ## Main
call :compilerJavaClasspathArgs
call "%_JAVACMD%" %_JAVA_ARGS% -classpath "%_JVM_CP_ARGS%" ^
"-Dscala.usejavacp=true" "-Dscala.home=%_PROG_HOME%" ^
dotty.tools.MainGenericCompiler %_SCALA_ARGS%
if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end )
goto end
@rem #########################################################################
@rem ## Subroutines
:args
set _JAVA_ARGS=
set _SCALA_ARGS=
set _SCALA_CPATH=
@rem replace inner while loop used in bash script
set _CONSUME_REMAINING=
:args_loop
if "%~1"=="" goto args_done
set "__ARG=%~1"
if defined _CONSUME_REMAINING (
set _SCALA_ARGS=!_SCALA_ARGS! "%__ARG%"
shift
) else if "%__ARG%"=="--" (
@rem pass all remaining arguments to scala, e.g. to avoid interpreting them here as -D or -J
set _CONSUME_REMAINING=1
set _SCALA_ARGS=!_SCALA_ARGS! "%__ARG%"
shift
) else if "%__ARG%"=="-script" (
@rem pass all remaining arguments to scala, e.g. to avoid interpreting them here as -D or -J
set _CONSUME_REMAINING=1
set _SCALA_ARGS=!_SCALA_ARGS! "%__ARG%"
shift
) else if "%__ARG%"=="-Oshort" (
@rem optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
set _JAVA_ARGS=!_JAVA_ARGS! "-XX:+TieredCompilation" "-XX:TieredStopAtLevel=1"
set _SCALA_ARGS=!_SCALA_ARGS! -Oshort
shift
) else if "%__ARG:~0,2%"=="-D" (
@rem pass to scala as well: otherwise we lose it sometimes when we
@rem need it, e.g. communicating with a server compiler.
set _JAVA_ARGS=!_JAVA_ARGS! "%__ARG%"
set _SCALA_ARGS=!_SCALA_ARGS! "%__ARG%"
) else if "%__ARG:~0,2%"=="-J" (
@rem as with -D, pass to scala even though it will almost
@rem never be used.
set _JAVA_ARGS=!_JAVA_ARGS! %__ARG:~2%
set _SCALA_ARGS=!_SCALA_ARGS! "%__ARG%"
) else if "%__ARG%"=="-classpath" (
set "_SCALA_CPATH=%~2"
shift
) else if "%__ARG%"=="-cp" (
set "_SCALA_CPATH=%~2"
shift
) else (
set _SCALA_ARGS=!_SCALA_ARGS! "%__ARG%"
)
shift
goto args_loop
:args_done
goto :eof
@rem output parameter: _JVM_CP_ARGS
:compilerJavaClasspathArgs
@rem echo scala3-compiler: %_SCALA3_COMP%
@rem echo scala3-interface: %_SCALA3_INTF%
@rem echo scala3-library: %_SCALA3_LIB%
@rem echo tasty-core: %_TASTY_CORE%
@rem echo scala-asm: %_SCALA_ASM%
@rem echo scala-lib: %_SCALA_LIB%
@rem echo sbt-intface: %_SBT_INTF%
set "__TOOLCHAIN=%_SCALA_LIB%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_LIB%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA_ASM%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SBT_INTF%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_INTF%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_COMP%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_TASTY_CORE%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_STAGING%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_SCALA3_TASTY_INSPECTOR%%_PSEP%"
@rem # jline
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_READER%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_TERMINAL%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_JLINE_TERMINAL_JNA%%_PSEP%"
set "__TOOLCHAIN=%__TOOLCHAIN%%_JNA%"
if defined _SCALA_CPATH (
set "_JVM_CP_ARGS=%__TOOLCHAIN%%_SCALA_CPATH%"
) else (
set "_JVM_CP_ARGS=%__TOOLCHAIN%"
)
goto :eof
@rem #########################################################################
@rem ## Cleanups
:end
exit /b %_EXITCODE%
endlocal