summaryrefslogtreecommitdiff
path: root/sources/bin
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-11-19 18:56:00 +0000
committerpaltherr <paltherr@epfl.ch>2003-11-19 18:56:00 +0000
commit0b4f31189a5bf5e7dca7218aee3089d5983831da (patch)
tree27e74aa3b71a797a476d1e6e99ebea9bc7389d73 /sources/bin
parentda7c6e4094e339047b7127fb08aaf44d201c1d00 (diff)
downloadscala-0b4f31189a5bf5e7dca7218aee3089d5983831da.tar.gz
scala-0b4f31189a5bf5e7dca7218aee3089d5983831da.tar.bz2
scala-0b4f31189a5bf5e7dca7218aee3089d5983831da.zip
- Rewrote exec_* functions
Diffstat (limited to 'sources/bin')
-rw-r--r--sources/bin/.scala_wrapper.tmpl180
1 files changed, 60 insertions, 120 deletions
diff --git a/sources/bin/.scala_wrapper.tmpl b/sources/bin/.scala_wrapper.tmpl
index 0b60f966d0..76bee4a0a8 100644
--- a/sources/bin/.scala_wrapper.tmpl
+++ b/sources/bin/.scala_wrapper.tmpl
@@ -175,10 +175,10 @@ configure_path_variable() {
##############################################################################
# Path list construction functions
-# Appends a named path to a named path list. First, computes variable
+# Prepends 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() {
+prepend_path() {
[ $# = 2 ] || abort "internal error";
compute_variable "$2";
@@ -186,7 +186,7 @@ append_path() {
if [ -z "`eval echo \\\$\$1`" ]; then
eval $1=\$$2;
else
- eval $1=\$$1:\$$2;
+ eval $1=\$$2:\$$1;
fi;
}
@@ -212,8 +212,8 @@ compute_scala_classpath() {
# 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;
+ prepend_path SCALA_BOOTCLASSPATH RUNTIME_SOURCES;
+ prepend_path SCALA_BOOTCLASSPATH RUNTIME_CLASSES;
}
@@ -245,12 +245,10 @@ compute_variable() {
##############################################################################
# Java invocation functions
-# Invokes Java with the given arguments (which must, at least, contain
-# the name of the main class) and the following additional arguments:
-# - arguments specified by variable JAVA_ARGS
+# Starts a Java program with the given arguments and the following
+# additional ones:
+# - arguments specified by the variable JAVA_ARGS
# - script-suffix-specific arguments
-# - definition of Java properties scala.product and scala.version
-# - classpath set to $JAVA_CLASSPATH
exec_java() {
[ $# -gt 0 ] || abort "internal error";
@@ -265,117 +263,67 @@ exec_java() {
esac;
# invoke Java
- $EXEC $JAVA_EXEC $JAVA_ARGS \
- -classpath "`get_os_pathlist "$JAVA_CLASSPATH"`" \
- -Dscala.product="$SCRIPT" \
- -Dscala.version="$VERSION" \
- "$@";
-}
-
-# Starts a Java program using the Scala compiler. The given arguments
-# are passed to exec_java. They must, at least, contain the name of
-# the main class.
-exec_compile() {
- [ $# -gt 0 ] || abort "internal error";
-
- # compute Java classpath
- append_path JAVA_CLASSPATH TOOLS_CLASSES;
- append_path JAVA_CLASSPATH FJBG_CLASSES;
- append_path JAVA_CLASSPATH MSIL_CLASSES;
-
- # compute Scala classpath and bootclasspath
- compute_scala_classpath;
- compute_scala_bootclasspath;
-
- # invoke Java
- exec_java \
- -Dscala.class.path=`get_os_pathlist "$SCALA_CLASSPATH"` \
- -Dscala.boot.class.path=`get_os_pathlist "$SCALA_BOOTCLASSPATH"` \
- "$@";
-}
-
-# Starts a Java program using the Scala interprter. The given
-# arguments are passed to exec_compile. They must, at least, contain
-# the name of the main class.
-exec_interpret() {
- [ $# -gt 0 ] || abort "internal error";
-
- # compute Java classpath
- # !!! this should not be needed
- append_path JAVA_CLASSPATH RUNTIME_CLASSES;
-
- # invoke Java
- exec_compile "$@";
-}
-
-# Starts a program using dtd2scala. The given arguments are passed to
-# exec_java. They must, at least, contain the name of the main class.
-exec_dtd2scala() {
- [ $# -gt 0 ] || abort "internal error";
-
- # compute Java classpath
- append_path JAVA_CLASSPATH RUNTIME_CLASSES;
- append_path JAVA_CLASSPATH TOOLS_CLASSES;
-
- # invoke Java
- exec_java \
- "$@";
-}
-
-# Starts a program using scaladoc. The given arguments are passed to
-# exec_java. They must, at least, contain the name of the main class.
-exec_scaladoc() {
- [ $# -gt 0 ] || abort "internal error";
-
- # compute Java classpath
- append_path JAVA_CLASSPATH RUNTIME_CLASSES;
- append_path JAVA_CLASSPATH TOOLS_CLASSES;
-
- # compute Scala classpath and bootclasspath
- compute_scala_classpath;
- compute_scala_bootclasspath;
+ $EXEC $JAVA_EXEC $JAVA_ARGS "$@";
+}
+
+# Starts a Scala tool. The first argument must be either "java" or
+# "scala". It tells whether the tool is written in Java or Scala. The
+# following arguments are passed to exec_java. They must, at least,
+# contain the name of the main class.
+exec_tool() {
+ [ $# -gt 1 ] || abort "internal error";
+ language="$1"; shift 1;
+
+ # augment Java classpath
+ prepend_path JAVA_CLASSPATH TOOLS_CLASSES;
+ case "$language" in
+ java ) true;;
+ scala ) prepend_path JAVA_CLASSPATH RUNTIME_CLASSES;;
+ * ) abort "internal error: found language='$language'";;
+ esac;
# invoke Java
exec_java \
- -Dscala.class.path=`get_os_pathlist "$SCALA_CLASSPATH"` \
- -Dscala.boot.class.path=`get_os_pathlist "$SCALA_BOOTCLASSPATH"` \
+ -classpath "`get_os_pathlist "$JAVA_CLASSPATH"`" \
+ -Dscala.home="$PREFIX" \
+ -Dscala.product="$SCRIPT" \
+ -Dscala.version="$VERSION" \
"$@";
}
-# Starts a program using scalap. The given arguments are passed to
-# exec_java. They must, at least, contain the name of the main class.
-exec_scalap() {
- [ $# -gt 0 ] || abort "internal error";
-
- # compute Java classpath
- append_path JAVA_CLASSPATH RUNTIME_CLASSES;
- append_path JAVA_CLASSPATH TOOLS_CLASSES;
+# Starts a Scala compile tool (one that uses properties
+# scala.class.path and scala.boot.class.path). The first argument must
+# be either "java" or "scala". It tells whether the tool is written in
+# Java or Scala. The following arguments are passed to exec_java. They
+# must, at least, contain the name of the main class.
+exec_compile_tool() {
+ [ $# -gt 1 ] || abort "internal error";
+ language="$1"; shift 1;
# compute Scala classpath and bootclasspath
compute_scala_classpath;
compute_scala_bootclasspath;
# invoke Java
- exec_java \
+ exec_tool "$language" \
-Dscala.class.path=`get_os_pathlist "$SCALA_CLASSPATH"` \
-Dscala.boot.class.path=`get_os_pathlist "$SCALA_BOOTCLASSPATH"` \
"$@";
}
-# Starts a program using scalatest. The given arguments are passed to
-# exec_java. They must, at least, contain the name of the main class.
-exec_scalatest() {
- [ $# -gt 0 ] || abort "internal error";
+# Starts a Scala compiler. The first argument must be either "java" or
+# "scala". It tells whether the tool is written in Java or Scala. The
+# following arguments are passed to exec_java. They must, at least,
+# contain the name of the main class.
+exec_compiler() {
+ [ $# -gt 1 ] || abort "internal error";
+ language="$1"; shift 1;
- # compute Java classpath
- append_path JAVA_CLASSPATH TOOLS_CLASSES;
+ # augment Java classpath
+ prepend_path JAVA_CLASSPATH MSIL_CLASSES;
+ prepend_path JAVA_CLASSPATH FJBG_CLASSES;
- # invoke Java
- exec_java \
- -Dscala.runtime=`get_os_pathlist "$RUNTIME_CLASSES"` \
- -Dscala.binpath=`get_os_pathlist "$PREFIX/bin"` \
- -Dscala.testpath=`get_os_pathlist "$PREFIX/test"` \
- "$@";
+ exec_compile_tool "$language" "$@";
}
##############################################################################
@@ -494,10 +442,10 @@ scala_has_bootclasspath() {
scala() {
compute_variable EXEC;
if scala_has_bootclasspath "$@"; then
- $EXEC java "$@";
+ exec_java "$@";
else
compute_variable RUNTIME_CLASSES;
- $EXEC java "-Xbootclasspath/a:$RUNTIME_CLASSES" "$@";
+ exec_java "-Xbootclasspath/a:$RUNTIME_CLASSES" "$@";
fi;
}
@@ -539,22 +487,14 @@ configure;
case "$SCRIPT" in
scala ) scala "$@";;
scala-info ) scala_info "$@";;
- scalac* ) exec_compile scalac.Main "$@";;
- scaladoc* ) exec_scaladoc scala.tools.scaladoc.Main "$@";;
- scalarun* ) exec_interpret scala.tools.scalai.Main "$@";;
- scalaint* ) exec_interpret scala.tools.scalai.Main -interactive "$@";;
- dtd2scala* ) exec_dtd2scala scala.tools.dtd2scala.Main "$@";;
- scalap* ) exec_scalap scala.tools.scalap.Main "$@";;
- scalatest* ) exec_scalatest scala.tools.scalatest.Main "$@";;
- socos* )
- warning "Deprecated command, use scalarun`expr "$SCRIPT" : 'socos\(.*\)'` instead.";
- exec_compile scalac.Main "$@";;
- surus* )
- warning "Deprecated command, use scalarun`expr "$SCRIPT" : 'surus\(.*\)'` instead.";
- exec_compile scalai.Main "$@";;
- siris* )
- warning "Deprecated command, use scalarun`expr "$SCRIPT" : 'siris\(.*\)'` instead.";
- exec_compile scalai.Main -interactive "$@";;
+ scalacboot*) exec_compiler java scalac.Main "$@";;
+ scalac* ) exec_compiler scala scala.tools.scalac.Main "$@";;
+ scalarun* ) exec_compiler java scala.tools.scalai.Main "$@";;
+ scalaint* ) exec_compiler java scala.tools.scalai.Main -interactive "$@";;
+ scaladoc* ) exec_compile_tool scala scala.tools.scaladoc.Main "$@";;
+ scalap* ) exec_compile_tool scala scala.tools.scalap.Main "$@";;
+ dtd2scala* ) exec_tool scala scala.tools.dtd2scala.Main "$@";;
+ scalatest* ) exec_tool java scala.tools.scalatest.Main "$@";;
* ) abort "Don't know what to do for $SCRIPT.";;
esac;