mirror of https://github.com/sbt/sbt.git
don't put scala-library.jar on the boot classpath unless it is on the classpath
This commit is contained in:
parent
a099754109
commit
9ee30636b3
|
|
@ -58,7 +58,7 @@ final class AnalyzingCompiler(val scalaInstance: xsbti.compile.ScalaInstance, va
|
||||||
{
|
{
|
||||||
val arguments = new CompilerArguments(scalaInstance, cp)
|
val arguments = new CompilerArguments(scalaInstance, cp)
|
||||||
val classpathString = CompilerArguments.absString(arguments.finishClasspath(classpath))
|
val classpathString = CompilerArguments.absString(arguments.finishClasspath(classpath))
|
||||||
val bootClasspath = if(cp.autoBoot) arguments.createBootClasspath else ""
|
val bootClasspath = if(cp.autoBoot) arguments.createBootClasspathFor(classpath) else ""
|
||||||
val (names, values) = bindings.unzip
|
val (names, values) = bindings.unzip
|
||||||
call("xsbt.ConsoleInterface", "run", log)(
|
call("xsbt.ConsoleInterface", "run", log)(
|
||||||
classOf[Array[String]], classOf[String], classOf[String], classOf[String], classOf[String], classOf[ClassLoader], classOf[Array[String]], classOf[Array[Any]], classOf[xLogger])(
|
classOf[Array[String]], classOf[String], classOf[String], classOf[String], classOf[String], classOf[ClassLoader], classOf[Array[String]], classOf[Array[Any]], classOf[xLogger])(
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ final class CompilerArguments(scalaInstance: xsbti.compile.ScalaInstance, cp: xs
|
||||||
val dummy = "dummy_" + Integer.toHexString(util.Random.nextInt)
|
val dummy = "dummy_" + Integer.toHexString(util.Random.nextInt)
|
||||||
val classpathOption = Seq("-classpath", if(cpWithCompiler.isEmpty) dummy else absString(cpWithCompiler))
|
val classpathOption = Seq("-classpath", if(cpWithCompiler.isEmpty) dummy else absString(cpWithCompiler))
|
||||||
val outputOption = Seq("-d", outputDirectory.getAbsolutePath)
|
val outputOption = Seq("-d", outputDirectory.getAbsolutePath)
|
||||||
options ++ outputOption ++ bootClasspathOption ++ classpathOption ++ abs(sources)
|
options ++ outputOption ++ bootClasspathOption(hasLibrary(classpath)) ++ classpathOption ++ abs(sources)
|
||||||
}
|
}
|
||||||
def finishClasspath(classpath: Seq[File]): Seq[File] =
|
def finishClasspath(classpath: Seq[File]): Seq[File] =
|
||||||
filterLibrary(classpath) ++ include(cp.compiler, scalaInstance.compilerJar) ++ include(cp.extra, scalaInstance.otherJars : _*)
|
filterLibrary(classpath) ++ include(cp.compiler, scalaInstance.compilerJar) ++ include(cp.extra, scalaInstance.otherJars : _*)
|
||||||
|
|
@ -36,11 +36,13 @@ final class CompilerArguments(scalaInstance: xsbti.compile.ScalaInstance, cp: xs
|
||||||
val scalaHome = System.getProperty("scala.home")
|
val scalaHome = System.getProperty("scala.home")
|
||||||
assert((scalaHome eq null) || scalaHome.isEmpty, "'scala.home' should not be set (was " + scalaHome + ")")
|
assert((scalaHome eq null) || scalaHome.isEmpty, "'scala.home' should not be set (was " + scalaHome + ")")
|
||||||
}
|
}
|
||||||
/** Add the correct Scala library jar to the boot classpath.*/
|
def createBootClasspathFor(classpath: Seq[File]) = createBootClasspath(hasLibrary(classpath))
|
||||||
def createBootClasspath =
|
|
||||||
|
/** Add the correct Scala library jar to the boot classpath if `addLibrary` is true.*/
|
||||||
|
def createBootClasspath(addLibrary: Boolean) =
|
||||||
{
|
{
|
||||||
val originalBoot = System.getProperty("sun.boot.class.path", "")
|
val originalBoot = System.getProperty("sun.boot.class.path", "")
|
||||||
if(cp.bootLibrary)
|
if(addLibrary)
|
||||||
{
|
{
|
||||||
val newBootPrefix = if(originalBoot.isEmpty) "" else originalBoot + File.pathSeparator
|
val newBootPrefix = if(originalBoot.isEmpty) "" else originalBoot + File.pathSeparator
|
||||||
newBootPrefix + scalaInstance.libraryJar.getAbsolutePath
|
newBootPrefix + scalaInstance.libraryJar.getAbsolutePath
|
||||||
|
|
@ -48,10 +50,15 @@ final class CompilerArguments(scalaInstance: xsbti.compile.ScalaInstance, cp: xs
|
||||||
else
|
else
|
||||||
originalBoot
|
originalBoot
|
||||||
}
|
}
|
||||||
def filterLibrary(classpath: Seq[File]) =
|
def filterLibrary(classpath: Seq[File]) = if(cp.filterLibrary) classpath filterNot isScalaLibrary else classpath
|
||||||
if(cp.filterLibrary) classpath.filterNot(_.getName contains ArtifactInfo.ScalaLibraryID) else classpath
|
def hasLibrary(classpath: Seq[File]) = classpath exists isScalaLibrary
|
||||||
def bootClasspathOption = if(cp.autoBoot) Seq(BootClasspathOption, createBootClasspath) else Nil
|
private[this] val isScalaLibrary: File => Boolean = file => {
|
||||||
def bootClasspath = if(cp.autoBoot) IO.parseClasspath(createBootClasspath) else Nil
|
val name = file.getName
|
||||||
|
(name contains ArtifactInfo.ScalaLibraryID) || file.getName == scalaInstance.libraryJar.getName
|
||||||
|
}
|
||||||
|
def bootClasspathOption(addLibrary: Boolean) = if(cp.autoBoot) Seq(BootClasspathOption, createBootClasspath(addLibrary)) else Nil
|
||||||
|
def bootClasspath(addLibrary: Boolean) = if(cp.autoBoot) IO.parseClasspath(createBootClasspath(addLibrary)) else Nil
|
||||||
|
def bootClasspathFor(classpath: Seq[File]) = bootClasspath(hasLibrary(classpath))
|
||||||
}
|
}
|
||||||
object CompilerArguments
|
object CompilerArguments
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class AggressiveCompile(cacheFile: File)
|
||||||
}
|
}
|
||||||
|
|
||||||
def withBootclasspath(args: CompilerArguments, classpath: Seq[File]): Seq[File] =
|
def withBootclasspath(args: CompilerArguments, classpath: Seq[File]): Seq[File] =
|
||||||
args.bootClasspath ++ args.finishClasspath(classpath)
|
args.bootClasspathFor(classpath) ++ args.finishClasspath(classpath)
|
||||||
|
|
||||||
def compile1(sources: Seq[File], classpath: Seq[File], setup: CompileSetup, store: AnalysisStore, analysis: File => Option[Analysis], definesClass: DefinesClass, compiler: AnalyzingCompiler, javac: xsbti.compile.JavaCompiler, maxErrors: Int, skip: Boolean, cache: GlobalsCache)(implicit log: Logger): Analysis =
|
def compile1(sources: Seq[File], classpath: Seq[File], setup: CompileSetup, store: AnalysisStore, analysis: File => Option[Analysis], definesClass: DefinesClass, compiler: AnalyzingCompiler, javac: xsbti.compile.JavaCompiler, maxErrors: Int, skip: Boolean, cache: GlobalsCache)(implicit log: Logger): Analysis =
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ object CompileTest extends Specification
|
||||||
val noCompiler = compiler(true, false)
|
val noCompiler = compiler(true, false)
|
||||||
val fullExplicit = compiler(false, false)
|
val fullExplicit = compiler(false, false)
|
||||||
|
|
||||||
val fullBoot = "-bootclasspath" :: fullExplicit.compilerArguments.createBootClasspath :: Nil
|
val fullBoot = "-bootclasspath" :: fullExplicit.compilerArguments.createBootClasspath(true) :: Nil
|
||||||
val withCompiler = noCompiler.scalaInstance.compilerJar :: Nil
|
val withCompiler = noCompiler.scalaInstance.compilerJar :: Nil
|
||||||
val withLibrary = noCompiler.scalaInstance.libraryJar :: Nil
|
val withLibrary = noCompiler.scalaInstance.libraryJar :: Nil
|
||||||
val withLibraryCompiler = withLibrary ++ withCompiler
|
val withLibraryCompiler = withLibrary ++ withCompiler
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue