summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-08-14 08:14:49 +0000
committerpaltherr <paltherr@epfl.ch>2003-08-14 08:14:49 +0000
commitf91ce5d11023b4e7892122538c4da7f2f769992b (patch)
tree5bc2f4077d56c38c2dddd34f1d7dd20ccd70b459 /sources
parent5aefaf0289661ed3181704a061ba940c30381ac0 (diff)
downloadscala-f91ce5d11023b4e7892122538c4da7f2f769992b.tar.gz
scala-f91ce5d11023b4e7892122538c4da7f2f769992b.tar.bz2
scala-f91ce5d11023b4e7892122538c4da7f2f769992b.zip
- Implemented scala-info
- Removed some local variables
Diffstat (limited to 'sources')
-rw-r--r--sources/bin/.scala_wrapper.tmpl211
1 files changed, 170 insertions, 41 deletions
diff --git a/sources/bin/.scala_wrapper.tmpl b/sources/bin/.scala_wrapper.tmpl
index 2fbe0df78d..d33ef89c80 100644
--- a/sources/bin/.scala_wrapper.tmpl
+++ b/sources/bin/.scala_wrapper.tmpl
@@ -150,10 +150,9 @@ get_unix_pathlist() {
# otherwise does nothing.
configure_variable() {
[ $# = 1 ] || abort "internal error";
- name="$1"; shift 1;
- if set | grep "^SCALA_$name=" > /dev/null; then
- eval $name=\$SCALA_$name;
+ if set | grep "^SCALA_$1=" > /dev/null; then
+ eval $1=\$SCALA_$1;
fi;
}
@@ -163,49 +162,99 @@ configure_variable() {
# the variable $1 refers a non-existing path, exits with an error.
configure_path_variable() {
[ $# = 1 ] || abort "internal error";
- name="$1"; shift 1;
- if set | grep "^SCALA_$name=" > /dev/null; then
- path=`eval echo \\\$SCALA_\$name`;
+ if set | grep "^SCALA_$1=" > /dev/null; then
+ path=`eval echo \\\$SCALA_\$1`;
if [ -f "$path" -o -d "$path" ]; then
- eval $name=\$SCALA_$name;
+ eval $1=\$SCALA_$1;
else
- warning "File refered by SCALA_$name ($path) does not exist.";
- unset SCALA_$name;
+ warning "File refered by SCALA_$1 ($path) does not exist.";
+ unset SCALA_$1;
fi;
fi;
- path=`eval echo \\\$\$name`;
+ path=`eval echo \\\$\$1`;
if [ ! -f "$path" -a ! -d "$path" ]; then
- abort "File referred by $name ($path) does not exist." \
- "Please, fix the definition of $name in file $SOURCE." \
+ abort "File referred by $1 ($path) does not exist." \
+ "Please, fix the definition of $1 in file $SOURCE." \
"Alternatively you may also define the environment" \
- "variable SCALA_$name.";
+ "variable SCALA_$1.";
fi
}
##############################################################################
# Path list construction functions
-# Appends a named path to a named path list. Configures the path
-# variable $2 and updates the path list in variable $1 by appending
-# the path from variable $2.
+# Appends a named path to a named path list. First, computes variable
+# $2 and then updates the path list in variable $1 by appending the
+# path from variable $2.
append_path() {
[ $# = 2 ] || abort "internal error";
- configure_path_variable "$2";
- listname="$1"; shift 1;
- pathname="$1"; shift 1;
- list=`eval echo \\\$\$listname`;
+ compute_variable "$2";
- if [ -z "$list" ]; then
- eval $listname=\$$pathname;
+ if [ -z "`eval echo \\\$\$1`" ]; then
+ eval $1=\$$2;
else
- eval $listname=\$$listname:\$$pathname;
+ eval $1=\$$1:\$$2;
fi;
}
##############################################################################
+# Variable computation functions
+
+# Sets SCALA_CLASSPATH to its default value.
+compute_default_scala_classpath() {
+ SCALA_CLASSPATH=".";
+}
+
+# Computes SCALA_CLASSPATH.
+compute_scala_classpath() {
+ if [ -z "$SCALA_CLASSPATH" ]; then
+ if [ -n "$CLASSPATH" ]; then
+ SCALA_CLASSPATH=`get_unix_pathlist "$CLASSPATH"`;
+ else
+ compute_default_scala_classpath;
+ fi;
+ fi;
+}
+
+# Sets SCALA_BOOTCLASSPATH to its default value.
+compute_default_scala_bootclasspath() {
+ eval SCALA_BOOTCLASSPATH="";
+ append_path SCALA_BOOTCLASSPATH RUNTIME_CLASSES;
+ append_path SCALA_BOOTCLASSPATH RUNTIME_SOURCES;
+}
+
+
+# Computes SCALA_BOOTCLASSPATH.
+compute_scala_bootclasspath() {
+ if [ -z "$SCALA_BOOTCLASSPATH" ]; then
+ compute_default_scala_bootclasspath;
+ fi;
+}
+
+# Computes variable $1.
+compute_variable() {
+ [ $# = 1 ] || abort "internal error";
+
+ case "$1" in
+ SCALA_CLASSPATH ) compute_scala_classpath;;
+ SCALA_BOOTCLASSPATH ) compute_scala_bootclasspath;;
+ RUNTIME_SOURCES ) configure_path_variable "$1";;
+ RUNTIME_CLASSES ) configure_path_variable "$1";;
+ DTD2SCALA_CLASSES ) configure_path_variable "$1";;
+ FJBG_CLASSES ) configure_path_variable "$1";;
+ MSIL_CLASSES ) configure_path_variable "$1";;
+ BCEL_CLASSES ) configure_path_variable "$1";;
+ XERCES_CLASSES ) configure_path_variable "$1";;
+ JAVA_EXEC ) configure_variable "$1";;
+ JAVA_ARGS ) configure_variable "$1";;
+ EXEC ) configure_variable "$1";;
+ esac;
+}
+
+##############################################################################
# Java invocation functions
# Invokes Java with the given arguments (which must, at least, contain
@@ -218,9 +267,9 @@ exec_java() {
[ $# -gt 0 ] || abort "internal error";
# configure variables
- configure_variable EXEC;
- configure_variable JAVA_EXEC;
- configure_variable JAVA_ARGS;
+ compute_variable EXEC;
+ compute_variable JAVA_EXEC;
+ compute_variable JAVA_ARGS;
# append script-suffix-specific arguments
case "$SCRIPT" in
@@ -247,20 +296,8 @@ exec_compile() {
append_path JAVA_CLASSPATH FJBG_CLASSES;
append_path JAVA_CLASSPATH MSIL_CLASSES;
- # compute Scala classpath
- if [ -z "$SCALA_CLASSPATH" ]; then
- if [ -n "$CLASSPATH" ]; then
- SCALA_CLASSPATH=`get_unix_pathlist "$CLASSPATH"`;
- else
- SCALA_CLASSPATH=".";
- fi;
- fi;
-
- # compute Scala boot classpath
- if [ -z "$SCALA_BOOTCLASSPATH" ]; then
- append_path SCALA_BOOTCLASSPATH RUNTIME_CLASSES;
- append_path SCALA_BOOTCLASSPATH RUNTIME_SOURCES;
- fi;
+ compute_scala_classpath;
+ compute_scala_bootclasspath;
# invoke Java
exec_java \
@@ -286,8 +323,100 @@ exec_dtd2scala() {
##############################################################################
# Implementation of scala-info
+# Prints given error message, prints usage and exits with error code 1.
+scala_info_abort() {
+ error "$@";
+ scala_info_print_usage 1>&2;
+ exit 1;
+}
+
+# Prints value of $1.
+scala_info_print_variable() {
+ [ $# = 1 ] || abort "internal error";
+ eval echo \"\$$1\";
+}
+
+# Prints default value of $1.
+scala_info_print_variable_default() {
+ [ $# = 1 ] || abort "internal error";
+ case "$1" in
+ SCALA_CLASSPATH ) compute_default_scala_classpath;;
+ SCALA_BOOTCLASSPATH ) compute_default_scala_bootclasspath;;
+ esac;
+ scala_info_print_variable "$1";
+}
+
+# Prints current value of $1.
+scala_info_print_variable_current() {
+ [ $# = 1 ] || abort "internal error";
+ compute_variable "$1";
+ scala_info_print_variable "$1";
+}
+
+# Implements "scala-info --home".
+scala_info_option_home() {
+ [ $# -gt 0 ] && abort "too many arguments";
+ echo "$PREFIX";
+}
+
+# Implements "scala-info --$1 <variable>"
+scala_info_option_x_variable() {
+ [ $# -lt 2 ] && abort "missing variable name";
+ [ $# -gt 2 ] && abort "too many arguments";
+ case "$2" in
+ CLASSPATH ) variable=SCALA_$2;;
+ BOOTCLASSPATH ) variable=SCALA_$2;;
+ RUNTIME_SOURCES ) variable=$2;;
+ RUNTIME_CLASSES ) variable=$2;;
+ DTD2SCALA_CLASSES ) variable=$2;;
+ FJBG_CLASSES ) variable=$2;;
+ MSIL_CLASSES ) variable=$2;;
+ BCEL_CLASSES ) variable=$2;;
+ XERCES_CLASSES ) variable=$2;;
+ JAVA_EXEC ) variable=$2;;
+ JAVA_ARGS ) variable=$2;;
+ EXEC ) variable=$2;;
+ * ) abort "Unknown variable \`$1'";;
+ esac;
+ scala_info_print_variable_$1 $variable;
+}
+
+# Implements "scala-info --help".
+scala_info_option_help() {
+ echo "usage: $0 <option>";
+ echo "where possible options include:";
+ echo " --home Print Scala home directory";
+ echo " --default <variable> Print default value of variable";
+ echo " --current <variable> Print current value of variable";
+ echo " -? --help Print this help message";
+ echo "";
+ echo "valid variables include:";
+ echo " SCALA_CLASSPATH Default classpath";
+ echo " SCALA_BOOTCLASSPATH Default bootclasspath";
+ echo " RUNTIME_SOURCES Location of the Scala library sources";
+ echo " RUNTIME_CLASSES Location of the Scala library and tools";
+ echo " DTD2SCALA_CLASSES Location of the dtd2scala tool";
+ echo " FJBG_CLASSES Location of the fjbg library";
+ echo " MSIL_CLASSES Location of the msil library";
+ echo " BCEL_CLASSES Location of the bcel library";
+ echo " XERCES_CLASSES Location of the xerces library";
+ echo " JAVA_EXEC Command to start the Java VM";
+ echo " JAVA_ARGS Additional arguments to pass to the Java VM";
+ echo " EXEC Command to start subprocesses";
+}
+
+# Entry point of scala-info.
scala_info() {
- abort "!!! not yet implemented";
+ [ $# = 0 ] && abort "missing option";
+
+ case "$1" in
+ --home ) shift 1; scala_info_option_home "$@";;
+ --default ) shift 1; scala_info_option_x_variable default "$@";;
+ --current ) shift 1; scala_info_option_x_variable current "$@";;
+ -? | --help ) shift 1; scala_info_option_help "$@";;
+ -* ) abort "unrecognised option \`$1'";;
+ * ) abort "illegal argument \`$1'";;
+ esac;
}
##############################################################################