diff options
author | Paul Phillips <paulp@improving.org> | 2011-02-22 05:01:06 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-02-22 05:01:06 +0000 |
commit | be9a1788b58bdf3ba70e5a39fbab2a30c082ca27 (patch) | |
tree | e4233915b40d00e7e90dcd55b3224c92e0ef52db /src | |
parent | a7c77669bd605127c99a40ce77a70ffc382d8639 (diff) | |
download | scala-be9a1788b58bdf3ba70e5a39fbab2a30c082ca27.tar.gz scala-be9a1788b58bdf3ba70e5a39fbab2a30c082ca27.tar.bz2 scala-be9a1788b58bdf3ba70e5a39fbab2a30c082ca27.zip |
Changes to startup.
default. The -toolcp option now works. -D and -J options are passed
as arguments to the runner program as well as to the underlying JVM,
because they may be needed for such things as fsc talking to a server
compiler. Added a new Settings type for -D and -J options. Deleted some
dead settings code.
There are dummy settings for -toolcp and -nobootcp so they can be seen
in the help output, which needs a big cleanup.
No review.
Diffstat (limited to 'src')
5 files changed, 50 insertions, 24 deletions
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index 21b0bd7b39..3280796878 100644 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -99,22 +99,31 @@ fi declare -a java_args declare -a scala_args +# default to the boot classpath for speed. +CPSELECT="-Xbootclasspath/a:" + while [ $# -gt 0 ]; do case "$1" in -D*) + # pass to scala as well: otherwise we lose it sometimes when we + # need it, e.g. communicating with a server compiler. java_args=("${java_args[@@]}" "$1") - shift - ;; - -toolcp) - TOOL_CLASSPATH="$TOOL_CLASSPATH:$2" + scala_args=("${scala_args[@@]}" "$1") shift ;; -J*) + # as with -D, pass to scala even though it will almost + # never be used. java_args=("${java_args[@@]}" "${1:2}") + scala_args=("${scala_args[@@]}" "$1") shift ;; - --usebootcp) - CPSWITCH="-Xbootclasspath/a:$TOOL_CLASSPATH" + -toolcp) + TOOL_CLASSPATH="$TOOL_CLASSPATH:$2" + shift 2 + ;; + -nobootcp) + CPSELECT="-classpath " shift ;; *) @@ -124,8 +133,6 @@ while [ $# -gt 0 ]; do esac done -: ${CPSWITCH:="-cp $TOOL_CLASSPATH"} - # reset "$@@" to the remaining args set -- "${scala_args[@@]}" @@ -136,7 +143,7 @@ fi "${JAVACMD:=java}" \ $JAVA_OPTS \ "${java_args[@@]}" \ - $CPSWITCH \ + ${CPSELECT}${TOOL_CLASSPATH} \ -Dscala.usejavacp=true \ -Dscala.home="$SCALA_HOME" \ -Denv.emacs="$EMACS" \ diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala index 47d308853a..80183791ed 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala @@ -16,6 +16,7 @@ trait AbsScalaSettings { type PathSetting <: AbsSetting { type T = String } type PhasesSetting <: AbsSetting { type T = List[String] } type StringSetting <: AbsSetting { type T = String } + type MapSetting <: AbsSetting { type T = Map[String, String] } type OutputDirs type OutputSetting <: AbsSetting @@ -28,6 +29,7 @@ trait AbsScalaSettings { def PathSetting(name: String, descr: String, default: String): PathSetting def PhasesSetting(name: String, descr: String): PhasesSetting def StringSetting(name: String, helpArg: String, descr: String, default: String): StringSetting + def MapSetting(name: String, prefix: String, descr: String): MapSetting /** **/ abstract class SettingGroup(val prefix: String) extends AbsSetting { diff --git a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala index 2e065a936c..0cc3be6e64 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala @@ -106,15 +106,6 @@ trait AbsSettings { protected[nsc] def tryToSetColon(args: List[String]): Option[ResultOfTryToSet] = errorAndValue("'%s' does not accept multiple arguments" format name, None) - /** Commands which take properties in form -Dfoo=bar or -Dfoo - */ - protected[nsc] def tryToSetProperty(args: List[String]): Option[ResultOfTryToSet] = - errorAndValue("'%s' does not accept property style arguments" format name, None) - - /** Attempt to set from a properties file style property value. - */ - def tryToSetFromPropertyValue(s: String): Unit = tryToSet(s :: Nil) - /** These categorizations are so the help output shows -X and -P among * the standard options and -Y among the advanced options. */ diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index a5cc9ef3c7..11b4a2510c 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -231,6 +231,7 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal add(new PathSetting(name, descr, default, prepend, append)) } + def MapSetting(name: String, prefix: String, descr: String): MapSetting = add(new MapSetting(name, prefix, descr)) // basically this is a value which remembers if it's been modified trait SettingValue extends AbsSettingValue { @@ -446,8 +447,33 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal def tryToSet(args: List[String]) = { value = true ; Some(args) } def unparse: List[String] = if (value) List(name) else Nil - override def tryToSetFromPropertyValue(s : String) { - value = s.equalsIgnoreCase("true") + } + + /** A special setting for accumulating arguments like -Dfoo=bar. */ + class MapSetting private[nsc]( + name: String, + prefix: String, + descr: String) + extends Setting(name, descr) { + type T = Map[String, String] + protected var v: Map[String, String] = Map() + + def tryToSet(args: List[String]) = { + val (xs, rest) = args partition (_ startsWith prefix) + val pairs = xs map (_ stripPrefix prefix) map { x => + (x indexOf '=') match { + case -1 => (x, "") + case idx => (x take idx, x drop (idx + 1)) + } + } + v = v ++ pairs + Some(rest) + } + + override def respondsTo(label: String) = label startsWith prefix + def unparse: List[String] = v.toList map { + case (k, "") => prefix + k + case (k, v) => prefix + k + "=" + v } } @@ -518,7 +544,6 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal Some(rest) } override def tryToSetColon(args: List[String]) = tryToSet(args) - override def tryToSetFromPropertyValue(s: String) = tryToSet(s.trim.split(" +").toList) def unparse: List[String] = value map { name + ":" + _ } withHelpSyntax(name + ":<" + arg + ">") @@ -548,7 +573,6 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal } def unparse: List[String] = if (value == default) Nil else List(name + ":" + value) - override def tryToSetFromPropertyValue(s: String) = tryToSetColon(s::Nil) withHelpSyntax(name + ":<" + helpArg + ">") } diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 9940134b7d..16289f11d9 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -23,8 +23,10 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings { /** Disable a setting */ def disable(s: Setting) = allSettings -= s - BooleanSetting("-J<flag>", "Pass <flag> directly to runtime system") - BooleanSetting("-Dprop=value", "Pass -Dprop=value directly to runtime system") + val jvmargs = MapSetting("-J<flag>", "-J", "Pass <flag> directly to the runtime system.") + val defines = MapSetting("-Dproperty=value", "-D", "Pass -Dproperty=value directly to the runtime system.") + val toolcp = PathSetting("-toolcp", "Add to the runner classpath.", "") + val nobootcp = BooleanSetting("-nobootcp", "Do not use the boot classpath for the scala jars.") /** * Standard settings |