Enable the use of spaces in paths for the Scala build on Windows.

Revert r25995 which was fixing it only partly and in the wrong place.
Properly encode argument files for scalac in scalac ant task.
Allow 'compilerarg' elements in scalac ant task (like in ant's built-in
javac task) to allow passing extra parameters like plugindir path with
proper encoding of spaces and file names, and use it in the Scala build.
Fix space handling in get-scala-revision.bat.

(Patch by Stefan Zeiger.) Closes SI-3047.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@26026 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2011-11-18 15:16:26 +00:00
parent efab22a395
commit 32d40a03dd
6 changed files with 43 additions and 23 deletions

View File

@ -634,11 +634,13 @@ QUICK BUILD (QUICK)
<scalacfork
destdir="${build-quick.dir}/classes/library"
compilerpathref="locker.classpath"
params="${scalac.args.quick} -Xpluginsdir ${build-quick.dir}/misc/scala-devel/plugins -Xplugin-require:continuations -P:continuations:enable"
params="${scalac.args.quick} -Xplugin-require:continuations -P:continuations:enable"
srcdir="${src.dir}/continuations/library"
jvmargs="${scalacfork.jvmargs}">
<include name="**/*.scala"/>
<compilationpath refid="quick.compilation.path"/>
<compilerarg value="-Xpluginsdir"/>
<compilerarg file="${build-quick.dir}/misc/scala-devel/plugins"/>
</scalacfork>
<touch file="${build-quick.dir}/plugins.complete" verbose="no"/>
<stopwatch name="quick.plugins.timer" action="total"/>
@ -1147,11 +1149,13 @@ BOOTSTRAPPING BUILD (STRAP)
<scalacfork
destdir="${build-strap.dir}/classes/library"
compilerpathref="pack.classpath"
params="${scalac.args.all} -Xpluginsdir ${build-strap.dir}/misc/scala-devel/plugins -Xplugin-require:continuations -P:continuations:enable"
params="${scalac.args.all} -Xplugin-require:continuations -P:continuations:enable"
srcdir="${src.dir}/continuations/library"
jvmargs="${scalacfork.jvmargs}">
<include name="**/*.scala"/>
<compilationpath refid="strap.compilation.path"/>
<compilerarg value="-Xpluginsdir"/>
<compilerarg file="${build-strap.dir}/misc/scala-devel/plugins"/>
</scalacfork>
<touch file="${build-strap.dir}/plugins.complete" verbose="no"/>
<stopwatch name="strap.plugins.timer" action="total"/>

View File

@ -21,7 +21,7 @@ class Make extends Task with TaskArgs {
if (!compTarget.isEmpty) settings.target = compTarget.get
if (!compilationPath.isEmpty) settings.classpath = compilationPath.get
if (!sourcePath.isEmpty) settings.sourcepath = sourcePath.get
if (!params.isEmpty) settings.more = params.get
settings.extraParams = extraArgsFlat
Compilers.make(id.get, (compilerPath.get.list.map{ path => new File(path).toURI.toURL }), settings)
}
}

View File

@ -23,14 +23,16 @@ import scala.tools.nsc.util.ScalaClassLoader
* - `failonerror`,
* - `timeout`,
* - `jvmargs`,
* - `argfile`.
* - `argfile`,
* - `params`.
*
* It also takes the following parameters as nested elements:
* - `src` (for `srcdir`),
* - `classpath`,
* - `sourcepath`,
* - `bootclasspath`,
* - `extdirs`.
* - `extdirs`,
* - `compilerarg`.
*
* @author Gilles Dubochet
*/
@ -99,7 +101,7 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs {
compTarget foreach (settings.target = _)
compilationPath foreach (settings.classpath = _)
sourcePath foreach (settings.sourcepath = _)
params foreach (settings.more = _)
settings.extraParams = extraArgsFlat
if (isMSIL)
settings.sourcedir = sourceDir
@ -132,10 +134,17 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs {
java setClasspath compilerPath
java setClassname MainClass
// Encode scalac/javac args for use in a file to be read back via "@file.txt"
def encodeScalacArgsFile(t: Traversable[String]) = t map { s =>
if(s.find(c => c <= ' ' || "\"'\\".contains(c)).isDefined)
"\"" + s.flatMap(c => (if(c == '"' || c == '\\') "\\" else "") + c ) + "\""
else s
} mkString "\n"
// dump the arguments to a file and do "java @file"
val tempArgFile = io.File.makeTemp("scalacfork")
val tokens = settings.toArgs ++ (includedFiles map (_.getPath))
tempArgFile writeAll (tokens mkString " ")
tempArgFile writeAll encodeScalacArgsFile(tokens)
val paths = List(Some(tempArgFile.toAbsolute.path), argfile).flatten map (_.toString)
val res = execWithArgFiles(java, paths)

View File

@ -58,16 +58,14 @@ class Settings {
def optimise = optimiseBf
def optimise_=(b: Boolean) { optimiseBf = b }
private var moreBf: Option[String] = None
def more = moreBf.get
def more_=(s: String): this.type = { moreBf = Some(s); this }
private var extraParamsBf: Seq[String] = Seq()
def extraParams = extraParamsBf
def extraParams_=(s: Seq[String]): this.type = { extraParamsBf = s; this }
private def q(o: AnyRef) = "\"" + o.toString.replace("""\""", """\\""") + "\""
def toArgs: List[String] =
(if (!gBf.isEmpty) "-g:"+g :: Nil else Nil) :::
(if (uncheckedBf) "-unchecked" :: Nil else Nil) :::
(if (!classpathBf.isEmpty) "-classpath" :: q(classpath) :: Nil else Nil) :::
(if (!classpathBf.isEmpty) "-classpath" :: classpath.toString :: Nil else Nil) :::
(if (!sourcepathBf.isEmpty) "-sourcepath" :: sourcepath.toString :: Nil else Nil) :::
(if (!sourcedirBf.isEmpty) "-Xsourcedir" :: sourcedir.toString :: Nil else Nil) :::
(if (!bootclasspathBf.isEmpty) "-bootclasspath" :: bootclasspath.toString :: Nil else Nil) :::
@ -76,7 +74,7 @@ class Settings {
(if (!encodingBf.isEmpty) "-encoding" :: encoding :: Nil else Nil) :::
(if (!targetBf.isEmpty) "-target:"+target :: Nil else Nil) :::
(if (optimiseBf) "-optimise" :: Nil else Nil) :::
(if (!moreBf.isEmpty) (more split ' ').toList else Nil)
extraParamsBf.toList
override def equals(that: Any): Boolean = that match {
case cs: Settings =>
@ -91,7 +89,7 @@ class Settings {
this.encodingBf == cs.encodingBf &&
this.targetBf == cs.targetBf &&
this.optimiseBf == cs.optimiseBf &&
this.moreBf == cs.moreBf
this.extraParamsBf == cs.extraParamsBf
case _ => false
}

View File

@ -12,6 +12,7 @@ package scala.tools.ant.sabbus
import java.io.File
import org.apache.tools.ant.Task
import org.apache.tools.ant.types.{Path, Reference}
import org.apache.tools.ant.types.Commandline.Argument
trait CompilationPathProperty {
this: Task =>
@ -41,12 +42,15 @@ trait TaskArgs extends CompilationPathProperty {
}
def setParams(input: String) {
params = params match {
case None => Some(input)
case Some(ps) => Some(ps + " " + input)
}
extraArgs ++= input.split(' ').map { s => val a = new Argument; a.setValue(s); a }
}
def createCompilerArg(): Argument = {
val a = new Argument
extraArgs :+= a
a
}
def setTarget(input: String) {
compTarget = Some(input)
}
@ -84,11 +88,16 @@ trait TaskArgs extends CompilationPathProperty {
}
protected var id: Option[String] = None
protected var params: Option[String] = None
protected var extraArgs: Seq[Argument] = Seq()
protected var compTarget: Option[String] = None
protected var sourcePath: Option[Path] = None
protected var compilerPath: Option[Path] = None
protected var destinationDir: Option[File] = None
def extraArgsFlat: Seq[String] = extraArgs flatMap { a =>
val parts = a.getParts
if(parts eq null) Seq[String]() else parts.toSeq
}
def isMSIL = compTarget exists (_ == "msil")
}

View File

@ -14,9 +14,9 @@ if "%OS%" NEQ "Windows_NT" (
set _DIR=
if "%*"=="" (
for /f %%i in ('cd') do set _DIR=%%i
for /f "delims=;" %%i in ('cd') do set "_DIR=%%i"
) else (
set _DIR=%~1
set "_DIR=%~1"
)
cd %_DIR%