diff --git a/ceylon b/ceylon new file mode 100644 index 0000000..6c274da --- /dev/null +++ b/ceylon @@ -0,0 +1,81 @@ +#!/bin/sh + +# resolve links - $0 may be a softlink +PRG="$0" +while [ -h "$PRG" ]; do + ls="$(ls -ld "$PRG")" + link="${ls##*-> }" # remove largest prefix: yields link target (behind ->) + if [ "$link" != "${link#/}" ]; then # remove prefix / if present + # path was absolute + PRG="$link" + else + # was not + PRG="$(dirname "$PRG")/$link" + fi +done + +DIR="$(dirname "$PRG")" + +# Check if we should use a distribution bootstrap +if [ -f "$DIR/.ceylon/bootstrap/ceylon-bootstrap.properties" ] && [ -f "$DIR/.ceylon/bootstrap/ceylon-bootstrap.jar" ]; then + # Using bootstrap + LIB="$DIR/.ceylon/bootstrap" +else + # Normal execution + CEYLON_HOME="$DIR/.." + LIB="$CEYLON_HOME/lib" + + if [ "$1" = "--show-home" ]; then + echo "$CEYLON_HOME" + exit + fi +fi + +if [ -z "$JAVA_HOME" ]; then + JAVA="java" +else + JAVA="$JAVA_HOME/bin/java" +fi + +# Make sure we have java installed +if ! hash java 2>&- +then + echo >&2 "Java not found, you must install Java in order to compile and run Ceylon programs" + echo >&2 "Go to http://www.java.com/getjava/ to download the latest version of Java" + exit 1 +fi + +#JAVA_DEBUG_OPTS="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y" + +if [ "$PRESERVE_JAVA_OPTS" != "true" ]; then + PREPEND_JAVA_OPTS="$JAVA_DEBUG_OPTS" + if [ -n "$COLUMNS" ]; then + CEYL_COLS="$COLUMNS" + elif stty size 2>/dev/null >/dev/null; then + CEYL_COLS="$(stty size 2>/dev/null | cut -d' ' -f2)" + else + CEYL_COLS="$(tput 2>/dev/null cols)" + fi + PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dorg.eclipse.ceylon.common.tool.terminal.width=$CEYL_COLS" + PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dorg.eclipse.ceylon.common.tool.progname=$(basename "$PRG")" +fi +for arg; do + case $arg in + --java=*) JAVA_OPTS="$JAVA_OPTS ${arg#--java=}";; + [!-]*) break;; + esac +done +JAVA_OPTS="$PREPEND_JAVA_OPTS $JAVA_OPTS" + +BOOTSTRAP="$LIB/ceylon-bootstrap.jar" + +# Check for cygwin, convert bootstrap path to Windows format +case "`uname`" in + CYGWIN*) [ -n "$LIB" ] && BOOTSTRAP=`cygpath -w "$BOOTSTRAP"` +esac + +exec "$JAVA" \ + $JAVA_OPTS \ + -jar "$BOOTSTRAP" \ + "$@" + diff --git a/ceylon-config.plugin b/ceylon-config.plugin new file mode 100644 index 0000000..08c77f8 --- /dev/null +++ b/ceylon-config.plugin @@ -0,0 +1,5 @@ +; Plugin definition for the "ceylon config" tool +summary=Manages Ceylon configuration files +module=org.eclipse.ceylon.cli/@ceylon-version@ +class=org.eclipse.ceylon.common.tools.config.CeylonConfigTool + diff --git a/ceylon-doc-tool.plugin b/ceylon-doc-tool.plugin new file mode 100644 index 0000000..9c594af --- /dev/null +++ b/ceylon-doc-tool.plugin @@ -0,0 +1,4 @@ +; Plugin definition for the "ceylon doc-tool" tool +summary=Generates documentation about a tool +module=org.eclipse.ceylon.cli/@ceylon-version@ +class=org.eclipse.ceylon.tools.help.CeylonDocToolTool diff --git a/ceylon-help.plugin b/ceylon-help.plugin new file mode 100644 index 0000000..6f4dee6 --- /dev/null +++ b/ceylon-help.plugin @@ -0,0 +1,4 @@ +; Plugin definition for the "ceylon help" tool +summary=Displays help information about other Ceylon tools +module=org.eclipse.ceylon.cli/@ceylon-version@ +class=org.eclipse.ceylon.tools.help.CeylonHelpTool diff --git a/ceylon-sh-setup b/ceylon-sh-setup new file mode 100644 index 0000000..effbc19 --- /dev/null +++ b/ceylon-sh-setup @@ -0,0 +1,18 @@ +for arg +do + if test "$arg" = "--_print-summary" + then + echo "$DESCRIPTION" + exit 0 + fi + if test "$arg" = "--_print-description" + then + echo "$LONG_USAGE" + exit 0 + fi + if test "$arg" = "--_print-usage" + then + echo "$USAGE" + exit 0 + fi +done diff --git a/ceylon-sh-setup.bat b/ceylon-sh-setup.bat new file mode 100644 index 0000000..7a41bff --- /dev/null +++ b/ceylon-sh-setup.bat @@ -0,0 +1,22 @@ +@echo off +setlocal enabledelayedexpansion + +:loop_args + if "%~1" == "" goto :done_args + + if "%~1" == "--_print-summary" ( + echo !DESCRIPTION! + exit /b 1 + ) + if "%~1" == "--_print-description" ( + echo !LONG_USAGE! + exit /b 1 + ) + if "%~1" == "--_print-usage" ( + echo !USAGE! + exit /b 1 + ) + shift + goto :loop_args +) +:done_args diff --git a/ceylon.bat b/ceylon.bat new file mode 100644 index 0000000..ccc7150 --- /dev/null +++ b/ceylon.bat @@ -0,0 +1,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%