-
Notifications
You must be signed in to change notification settings - Fork 1
/
ceylonb.bat
executable file
·132 lines (103 loc) · 3.31 KB
/
ceylonb.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
125
126
127
128
129
130
131
132
@echo off
setlocal ENABLEDELAYEDEXPANSION
:: Check if we should use a distribution bootstrap
pushd "%~dp0"
set "DIR=%CD%"
popd
if NOT exist "%DIR%\.ceylon\bootstrap\ceylon-bootstrap.properties" (
goto :normal
)
if NOT exist "%DIR%\.ceylon\bootstrap\ceylon-bootstrap.jar" (
goto :normal
)
:: Using bootstrap
set "LIB=%DIR%\.ceylon\bootstrap"
goto :endbs
:normal
:: Normal execution
:: Find CEYLON_HOME
pushd "%~dp0.."
set "CEYLON_HOME=%CD%"
popd
set "LIB=%CEYLON_HOME%\lib"
if "%~1" == "--show-home" (
@echo %CEYLON_HOME%
exit /b 1
)
:endbs
:: Find Java
:: Only check the registry if JAVA_HOME is not already set
IF NOT "%JAVA_HOME%" == "" (
goto :javaend
)
:: Find Java in the registry
set "KEY_NAME=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
set "KEY_NAME2=HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment"
:: get the current version
FOR /F "usebackq skip=2 tokens=3" %%A IN (`REG QUERY "%KEY_NAME%" /v CurrentVersion 2^>nul`) DO (
set "ValueValue=%%A"
)
if "%ValueValue%" NEQ "" (
set "JAVA_CURRENT=%KEY_NAME%\%ValueValue%"
) else (
rem Try again for 64bit systems
FOR /F "usebackq skip=2 tokens=3" %%A IN (`REG QUERY "%KEY_NAME2%" /v CurrentVersion 2^>nul`) DO (
set "JAVA_CURRENT=%KEY_NAME2%\%%A"
)
)
if "%ValueValue%" NEQ "" (
set "JAVA_CURRENT=%KEY_NAME%\%ValueValue%"
) else (
rem Try again for 64bit systems from a 32-bit process
FOR /F "usebackq skip=2 tokens=3" %%A IN (`REG QUERY "%KEY_NAME%" /v CurrentVersion /reg:64 2^>nul`) DO (
set "JAVA_CURRENT=%KEY_NAME%\%%A"
)
)
if "%JAVA_CURRENT%" == "" (
@echo Java not found, you must install Java in order to compile and run Ceylon programs
@echo Go to http://www.java.com/getjava/ to download the latest version of Java
exit /b 1
)
:: get the javahome
FOR /F "usebackq skip=2 tokens=3*" %%A IN (`REG QUERY "%JAVA_CURRENT%" /v JavaHome 2^>nul`) DO (
set "JAVA_HOME=%%A %%B"
)
if "%JAVA_HOME%" EQU "" (
rem Try again for 64bit systems from a 32-bit process
FOR /F "usebackq skip=2 tokens=3*" %%A IN (`REG QUERY "%JAVA_CURRENT%" /v JavaHome /reg:64 2^>nul`) DO (
set "JAVA_HOME=%%A %%B"
)
)
:javaend
set "JAVA=%JAVA_HOME%\bin\java.exe"
:: Check that Java executable actually exists
if not exist "%JAVA%" (
@echo "Cannot find java.exe at %JAVA%, check that your JAVA_HOME variable is pointing to the right place"
exit /b 1
)
rem set JAVA_DEBUG_OPTS="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
if NOT "%PRESERVE_JAVA_OPTS%" == "true" (
set PREPEND_JAVA_OPTS=%JAVA_DEBUG_OPTS%
rem Other java opts go here
)
rem Find any --java options and add their values to JAVA_OPTS
for %%x in (%*) do (
set ARG=%%~x
if "!ARG:~0,7!" EQU "--java=" (
set OPT=!ARG:~7!
set "JAVA_OPTS=!JAVA_OPTS! !OPT!"
) else if "!ARG!" EQU "--java" (
@echo Error: use --java options with an equal sign and quotes, eg: "--java=-Xmx500m"
exit /b 1
) else if "!ARG:~0,1!" NEQ "-" (
goto :breakloop
)
)
:breakloop
set "JAVA_OPTS=%PREPEND_JAVA_OPTS% %JAVA_OPTS%"
"%JAVA%" ^
%JAVA_OPTS% ^
-jar "%LIB%\ceylon-bootstrap.jar" ^
%*
endlocal
if %errorlevel% neq 0 exit /B %errorlevel%