summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl43
-rw-r--r--src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/MutableSettings.scala52
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala1
5 files changed, 34 insertions, 65 deletions
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index ceb6ec5ad4..25616c171a 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
##############################################################################
# Copyright 2002-2010, LAMP/EPFL
@@ -63,21 +63,44 @@ fi
# Reminder: substitution ${JAVA_OPTS:=-Xmx256M -Xms16M} DO NOT work on Solaris
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="@javaflags@"
-# break out -D options and add them to JAVA_OPTS as well so they reach the
-# underlying JVM in time to do some good.
-for i
-do
- case "$i" in
+# break out -D and -J options and add them to JAVA_OPTS as well
+# so they reach the underlying JVM in time to do some good. The
+# -D options will be available as system properties.
+declare -a java_args
+declare -a scala_args
+CPSWITCH="-cp \"$TOOL_CLASSPATH\""
+
+while [ $# -gt 0 ]; do
+ case "$1" in
-D*)
- JAVA_OPTS="$JAVA_OPTS $i" ;;
+ java_args=("${java_args[@@]}" "$1")
+ shift
+ ;;
+ -J*)
+ java_args=("${java_args[@@]}" "${1:2}")
+ shift
+ ;;
+ --usebootcp)
+ CPSWITCH="-Xbootclasspath/a:\"$TOOL_CLASSPATH\""
+ shift
+ ;;
*)
+ scala_args=("${scala_args[@@]}" "$1")
+ shift
;;
esac
-done
-
+done
+# reset "$@@" to the remaining args
+set -- "${scala_args[@@]}"
if [ -z "$JAVACMD" -a -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
JAVACMD="$JAVA_HOME/bin/java"
fi
-exec "${JAVACMD:=java}" $JAVA_OPTS -cp "$TOOL_CLASSPATH" -Dscala.usejavacp=true -Dscala.home="$SCALA_HOME" -Denv.emacs="$EMACS" @properties@ @class@ @toolflags@ "$@@"
+exec "${JAVACMD:=java}" \
+ "${java_args[@@]}" \
+ $CPSWITCH \
+ -Dscala.usejavacp=true \
+ -Dscala.home="$SCALA_HOME" \
+ -Denv.emacs="$EMACS" \
+ @properties@ @class@ @toolflags@ "$@@"
diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala
index c4e2e93235..3131c78bd0 100644
--- a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala
@@ -11,7 +11,6 @@ trait AbsScalaSettings {
type BooleanSetting <: AbsSetting { type T = Boolean }
type ChoiceSetting <: AbsSetting { type T = String }
- type DefinesSetting <: AbsSetting { type T = List[(String, String)] }
type IntSetting <: AbsSetting { type T = Int }
type MultiStringSetting <: AbsSetting { type T = List[String] }
type PathSetting <: AbsSetting { type T = String }
@@ -23,7 +22,6 @@ trait AbsScalaSettings {
def BooleanSetting(name: String, descr: String): BooleanSetting
def ChoiceSetting(name: String, helpArg: String, descr: String, choices: List[String], default: String): ChoiceSetting
- def DefinesSetting(): DefinesSetting
def IntSetting(name: String, descr: String, default: Int, range: Option[(Int, Int)], parser: String => Option[Int]): IntSetting
def MultiStringSetting(name: String, helpArg: String, descr: String): MultiStringSetting
def OutputSetting(outputDirs: OutputDirs, default: String): OutputSetting
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
index e4366b8758..a6499f0ca2 100644
--- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
@@ -107,16 +107,6 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal
// any non-Nil return value means failure and we return s unmodified
tryToSetIfExists(p, args split "," toList, (s: Setting) => s.tryToSetColon _)
}
- // if arg is of form -Dfoo=bar or -Dfoo (name = "-D")
- def isPropertyArg(s: String) = lookupSetting(s take 2) match {
- case Some(x: DefinesSetting) => true
- case _ => false
- }
- def parsePropertyArg(s: String): Option[List[String]] = {
- val (p, args) = (s take 2, s drop 2)
-
- tryToSetIfExists(p, List(args), (s: Setting) => s.tryToSetProperty _)
- }
// if arg is of form -Xfoo or -Xfoo bar (name = "-Xfoo")
def parseNormalArg(p: String, args: List[String]): Option[List[String]] =
@@ -181,11 +171,7 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal
//
// Internally we use Option[List[String]] to discover error,
// but the outside expects our arguments back unchanged on failure
- if (isPropertyArg(arg)) parsePropertyArg(arg) match {
- case Some(_) => rest
- case None => args
- }
- else if (arg contains ":") parseColonArg(arg) match {
+ if (arg contains ":") parseColonArg(arg) match {
case Some(_) => rest
case None => args
}
@@ -234,7 +220,6 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal
def BooleanSetting(name: String, descr: String) = add(new BooleanSetting(name, descr))
def ChoiceSetting(name: String, helpArg: String, descr: String, choices: List[String], default: String) =
add(new ChoiceSetting(name, helpArg, descr, choices, default))
- def DefinesSetting() = add(new DefinesSetting())
def IntSetting(name: String, descr: String, default: Int, range: Option[(Int, Int)], parser: String => Option[Int]) = add(new IntSetting(name, descr, default, range, parser))
def MultiStringSetting(name: String, arg: String, descr: String) = add(new MultiStringSetting(name, arg, descr))
def OutputSetting(outputDirs: OutputDirs, default: String) = add(new OutputSetting(outputDirs, default))
@@ -622,39 +607,4 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal
withHelpSyntax(name + ":<phase>")
}
-
- /** A setting for a -D style property definition */
- class DefinesSetting private[nsc] extends Setting("-D", "set a Java property") {
- type T = List[(String, String)]
- protected var v: T = Nil
- withHelpSyntax(name + "<prop>")
-
- // given foo=bar returns Some(foo, bar), or None if parse fails
- def parseArg(s: String): Option[(String, String)] = {
- if (s == "") return None
- val idx = s indexOf '='
-
- if (idx < 0) Some(s, "")
- else Some(s take idx, s drop (idx + 1))
- }
-
- protected[nsc] override def tryToSetProperty(args: List[String]): Option[List[String]] =
- tryToSet(args)
-
- def tryToSet(args: List[String]) =
- if (args.isEmpty) None
- else parseArg(args.head) match {
- case None => None
- case Some((a, b)) => value = value ++ List((a, b)) ; Some(args.tail)
- }
-
- def unparse: List[String] =
- value map { case (k,v) => "-D" + k + (if (v == "") "" else "=" + v) }
-
- /** Apply the specified properties to the current JVM and returns them. */
- def applyToJVM() = {
- value foreach { case (k, v) => System.getProperties.setProperty(k, v) }
- value
- }
- }
}
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 37e595fba1..360a19d54b 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -31,7 +31,6 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings {
val classpath = PathSetting ("-classpath", "Specify where to find user class files.", scalaUserClassPath) .
withAbbreviation ("-cp")
val d = OutputSetting (outputDirs, ".")
- val defines = DefinesSetting()
val optimise = BooleanSetting ("-optimise", "Generates faster bytecode by applying optimisations to the program") .
withAbbreviation("-optimize") .
withPostSetHook(set => List(inline, Xcloselim, Xdce) foreach (_.value = set.value))
diff --git a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala
index 118daed7ff..98a124b310 100644
--- a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala
@@ -49,5 +49,4 @@ trait StandardScalaSettings {
* nicely map to identifiers.
*/
val argfiles: BooleanSetting // exists only to echo help message, should be done differently
- val defines: DefinesSetting // not entirely clear that DefinesSetting makes sense as a Setting
}