From 80b0d241349f6463e814a8c1eca34f827ce24518 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 16 Feb 2010 21:22:10 +0000 Subject: Unix scripts pass -D options to the underlying ... Unix scripts pass -D options to the underlying JVM invocation. Closes #1222. Review by community. --- src/compiler/scala/tools/ant/templates/tool-unix.tmpl | 15 ++++++++++++++- src/compiler/scala/tools/nsc/Settings.scala | 7 +++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index ac50e3de54..b87463f0b9 100644 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -1,5 +1,5 @@ #!/bin/sh - +# ############################################################################## # Copyright 2002-2010, LAMP/EPFL # @@ -63,6 +63,19 @@ 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 + -D*) + JAVA_OPTS="$JAVA_OPTS $i" ;; + *) + ;; + esac +done + + if [ -z "$JAVACMD" -a -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then JAVACMD="$JAVA_HOME/bin/java" fi diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index 48292953c7..3d8e5d7258 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -746,6 +746,9 @@ object Settings { } } + private[Settings] 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 { @@ -757,8 +760,8 @@ object Settings { value map { case (k,v) => "-D" + k + (if (v == "") "" else "=" + v) } override def equals(that: Any) = that match { - case x: DefinesSetting => this isEq x - case _ => false + case x: DefinesSetting => this isEq x + case _ => false } /** Apply the specified properties to the current JVM and returns them. */ -- cgit v1.2.3