Skip to content

Commit b379ff4

Browse files
author
Aleksandar Prokopec
committed
Merge branch 'master' into issue/5846,4597,4027,4112
Conflicts: src/library/scala/collection/MapLike.scala src/library/scala/collection/SortedMapLike.scala
2 parents 2f0d94c + 6f08c06 commit b379ff4

File tree

271 files changed

+5060
-4900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+5060
-4900
lines changed

META-INF/MANIFEST.MF

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ Export-Package:
4040
scala.tools.nsc.util,
4141
scala.tools.util,
4242
scala.reflect.internal,
43+
scala.reflect.internal.pickling,
4344
scala.reflect.internal.settings,
45+
scala.reflect.internal.util,
46+
scala.reflect.makro,
4447
scala.reflect.runtime,
4548
scala.reflect.internal.transform,
49+
scala.reflect.api,
4650
ch.epfl.lamp.compiler.msil,
4751
ch.epfl.lamp.compiler.msil.emit,
4852
ch.epfl.lamp.compiler.msil.util,

classpath.SAMPLE

Lines changed: 0 additions & 12 deletions
This file was deleted.

project/Build.scala

Lines changed: 41 additions & 239 deletions
Large diffs are not rendered by default.

project/Packaging.scala

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import sbt._
2+
import Keys._
3+
import ScalaBuildKeys._
4+
5+
/** All the settings related to *packaging* the built scala software. */
6+
trait Packaging { self: ScalaBuild.type =>
7+
8+
// --------------------------------------------------------------
9+
// Packaging a distro
10+
// --------------------------------------------------------------
11+
lazy val scalaDistSettings: Seq[Setting[_]] = Seq(
12+
crossPaths := false,
13+
target <<= (baseDirectory, name) apply (_ / "target" / _),
14+
scalaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _),
15+
autoScalaLibrary := false,
16+
unmanagedJars in Compile := Seq(),
17+
genBinRunner <<= (fullClasspath in quickComp in Runtime) map (new ScalaToolRunner(_)),
18+
binDir <<= target(_/"bin"),
19+
genBin <<= genBinTask(genBinRunner, binDir, fullClasspath in Runtime, false),
20+
binDir in genBinQuick <<= baseDirectory apply (_ / "target" / "bin"),
21+
// Configure the classpath this way to avoid having .jar files and previous layers on the classpath.
22+
fullClasspath in Runtime in genBinQuick <<= Seq(quickComp,quickLib,scalap,actors,swing,fjbg,jline,forkjoin).map(classDirectory in Compile in _).join.map(Attributed.blankSeq),
23+
fullClasspath in Runtime in genBinQuick <++= (fullClasspath in Compile in jline),
24+
genBinQuick <<= genBinTask(genBinRunner, binDir in genBinQuick, fullClasspath in Runtime in genBinQuick, true),
25+
runManmakerMan <<= runManmakerTask(fullClasspath in Runtime in manmaker, runner in manmaker, "scala.tools.docutil.EmitManPage", "man1", ".1"),
26+
runManmakerHtml <<= runManmakerTask(fullClasspath in Runtime in manmaker, runner in manmaker, "scala.tools.docutil.EmitHtml", "doc", ".html"),
27+
// TODO - We could *really* clean this up in many ways. Let's look into making a a Seq of "direct jars" (scalaLibrary, scalaCompiler, jline, scalap)
28+
// a seq of "plugin jars" (continuationsPlugin) and "binaries" (genBin) and "documentation" mappings (genBin) that this can aggregate.
29+
// really need to figure out a better way to pull jline + jansi.
30+
makeDistMappings <<= (genBin,
31+
runManmakerMan,
32+
runManmakerHtml,
33+
packageBin in scalaLibrary in Compile,
34+
packageBin in scalaCompiler in Compile,
35+
packageBin in jline in Compile,
36+
packageBin in continuationsPlugin in Compile,
37+
managedClasspath in jline in Compile,
38+
packageBin in scalap in Compile) map {
39+
(binaries, man, html, lib, comp, jline, continuations, jlineDeps, scalap) =>
40+
val jlineDepMap: Seq[(File, String)] = jlineDeps.map(_.data).flatMap(_ x Path.flat) map { case(a,b) => a -> ("lib/"+b) }
41+
binaries ++ man ++ html ++ jlineDepMap ++ Seq(
42+
lib -> "lib/scala-library.jar",
43+
comp -> "lib/scala-compiler.jar",
44+
jline -> "lib/jline.jar",
45+
continuations -> "misc/scala-devel/plugins/continuations.jar",
46+
scalap -> "lib/scalap.jar"
47+
)
48+
},
49+
// Add in some more dependencies
50+
makeDistMappings <+= (packageBin in swing in Compile) map (s => s -> "lib/scala-swing.jar"),
51+
makeDistMappings <+= (packageBin in scalaReflect in Compile) map (s => s -> "lib/scala-reflect.jar"),
52+
makeDist <<= (makeDistMappings, baseDirectory, streams) map { (maps, dir, s) =>
53+
s.log.debug("Map = " + maps.mkString("\n"))
54+
val file = dir / "target" / "scala-dist.zip"
55+
IO.zip(maps, file)
56+
s.log.info("Created " + file.getAbsolutePath)
57+
file
58+
},
59+
makeExplodedDist <<= (makeDistMappings, target, streams) map { (maps, dir, s) =>
60+
def sameFile(f: File, f2: File) = f.getCanonicalPath == f2.getCanonicalPath
61+
IO.createDirectory(dir)
62+
IO.copy(for {
63+
(file, name) <- maps
64+
val file2 = dir / name
65+
if !sameFile(file,file2)
66+
} yield (file, file2))
67+
// Hack to make binaries be executable. TODO - Fix for JDK 5 and below...
68+
maps map (_._2) filter (_ startsWith "bin/") foreach (dir / _ setExecutable true)
69+
dir
70+
}
71+
)
72+
lazy val scaladist = (
73+
Project("dist", file("."))
74+
settings (scalaDistSettings: _*)
75+
)
76+
77+
78+
// Helpers to make a distribution
79+
80+
/** Generates runner scripts for distribution. */
81+
def genBinTask(
82+
runner: ScopedTask[ScalaToolRunner],
83+
outputDir: ScopedSetting[File],
84+
classpath: ScopedTask[Classpath],
85+
useClasspath: Boolean
86+
): Project.Initialize[sbt.Task[Seq[(File,String)]]] = {
87+
(runner, outputDir, classpath, streams) map { (runner, outDir, cp, s) =>
88+
IO.createDirectory(outDir)
89+
val classToFilename = Seq(
90+
"scala.tools.nsc.MainGenericRunner" -> "scala",
91+
"scala.tools.nsc.Main" -> "scalac",
92+
"scala.tools.nsc.ScalaDoc" -> "scaladoc",
93+
"scala.tools.nsc.CompileClient" -> "fsc",
94+
"scala.tools.scalap.Main" -> "scalap"
95+
)
96+
if (useClasspath) {
97+
val classpath = Build.data(cp).map(_.getCanonicalPath).distinct.mkString(",")
98+
s.log.debug("Setting classpath = " + classpath)
99+
runner setClasspath classpath
100+
}
101+
def genBinFiles(cls: String, dest: File) = {
102+
runner.setClass(cls)
103+
runner.setFile(dest)
104+
runner.execute()
105+
// TODO - Mark generated files as executable (755 or a+x) that is *not* JDK6 specific...
106+
dest.setExecutable(true)
107+
}
108+
def makeBinMappings(cls: String, binName: String): Seq[(File,String)] = {
109+
val file = outDir / binName
110+
val winBinName = binName + ".bat"
111+
genBinFiles(cls, file)
112+
Seq( file -> ("bin/"+binName), outDir / winBinName -> ("bin/"+winBinName) )
113+
}
114+
classToFilename.flatMap((makeBinMappings _).tupled)
115+
}
116+
}
117+
/** Creates man pages for distribution. */
118+
def runManmakerTask(classpath: ScopedTask[Classpath], scalaRun: ScopedTask[ScalaRun], mainClass: String, dir: String, ext: String): Project.Initialize[Task[Seq[(File,String)]]] =
119+
(classpath, scalaRun, streams, target) map { (cp, runner, s, target) =>
120+
val binaries = Seq("fsc", "scala", "scalac", "scaladoc", "scalap")
121+
binaries map { bin =>
122+
val file = target / "man" / dir / (bin + ext)
123+
val classname = "scala.man1." + bin
124+
IO.createDirectory(file.getParentFile)
125+
toError(runner.run(mainClass, Build.data(cp), Seq(classname, file.getAbsolutePath), s.log))
126+
file -> ("man/" + dir + "/" + bin + ext)
127+
}
128+
}
129+
}

project/Release.scala

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@ object Release {
55

66
// TODO - Just make the STARR artifacts and dump the sha1 files.
77

8+
val starrLibs = Seq("scala-library.jar", "scala-reflect.jar", "scala-compiler.jar", "jline.jar")
89

9-
lazy val pushStarr = Command.command("push-starr") { (state: State) =>
10-
// TODO do something
11-
// Revert to previous project state.
12-
state
13-
}
14-
10+
val pushStarr = Command.command("new-starr") { (state: State) =>
11+
/*val extracted = Project.extract(state)
12+
import extracted._
13+
// First run tests
14+
val (s1, result) = runTask(test in Test, state)
15+
// If successful, package artifacts
16+
val (s2, distDir) = runTask(makeExplodedDist, s1)
17+
// Then copy new libs in place
18+
val bd = extracted get baseDirectory
19+
for {
20+
jarName <- starrLibs
21+
jar = distDir / "lib" / jarName
22+
if jar.exists
23+
} IO.copyFile(jar, bd / "lib" / jarName)
24+
// Invalidate SHA1 files.
25+
ShaResolve.removeInvalidShaFiles(bd)
26+
// Now run tests *again*?
27+
s2*/
28+
state
29+
}
1530
}

project/RemoteDependencies.scala

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import sbt._
2+
import Keys._
3+
import ScalaBuildKeys._
4+
5+
6+
object RemoteDependencies {
7+
def buildSettings(externalProjects: Set[URI], localScala: Setting[_]): Seq[Setting[_]] = Seq(
8+
commands += Command.command("fix-uri-projects") { (state: State) =>
9+
if(state.get(buildFixed) getOrElse false) state
10+
else {
11+
// TODO -fix up scalacheck's dependencies!
12+
val extracted = Project.extract(state)
13+
import extracted._
14+
val scalaVersionString = extracted get version
15+
16+
def fix(s: Setting[_]): Setting[_] = s match {
17+
case ScopedExternalSetting(p, scalaInstance.key, setting) if externalProjects(p) => localScala mapKey Project.mapScope(_ => s.key.scope)
18+
// TODO - Fix Actors dependency...
19+
//case ScopedExternalSetting(p, libraryDependencies.key, setting) if externalProjects(p) => fixProjectDeps(s)
20+
case s => s
21+
}
22+
val transformed = session.mergeSettings map ( s => fix(s) )
23+
val scopes = transformed collect { case ScopedExternalSetting(p, _, s) if externalProjects(p) => s.key.scope } toSet
24+
// Create some fixers so we don't download scala or rely on it.
25+
// Also add dependencies that disappear in 2.10 for now...
26+
val fixers = for { scope <- scopes
27+
setting <- Seq(autoScalaLibrary := false,
28+
crossPaths := false,
29+
scalaVersion := scalaVersionString)
30+
} yield setting mapKey Project.mapScope(_ => scope)
31+
val newStructure = Load.reapply(transformed ++ fixers, structure)
32+
Project.setProject(session, newStructure, state).put(buildFixed, true)
33+
}
34+
},
35+
onLoad in Global <<= (onLoad in Global) apply (_ andThen { (state: State) =>
36+
"fix-uri-projects" :: state
37+
})
38+
)
39+
}
40+
41+
42+
43+
/** Matcher to make updated remote project references easier. */
44+
object ScopedExternalSetting {
45+
def unapply[T](s: Setting[_]): Option[(URI, AttributeKey[_], Setting[_])] =
46+
s.key.scope.project match {
47+
case Select(p @ ProjectRef(uri, _)) => Some((uri, s.key.key, s))
48+
case _ => None
49+
}
50+
}
51+
52+
53+

project/Sametest.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import Keys._
55

66
// This code is adapted from scala.tools.ant.Same by Gilles Dubochet.
77
object SameTest {
8-
lazy val checkSame: TaskKey[Unit] = TaskKey("check-same-binaries", "checks whether or not the class files generated by scala are the same.")
9-
lazy val checkSameLibrary: TaskKey[Unit] = TaskKey("check-same-lib-binaries", "checks whether or not the librayr class files generated by scala are the same.")
10-
lazy val checkSameCompiler: TaskKey[Unit] = TaskKey("check-same-comp-binaries", "checks whether or not the compiler class files generated by scala are the same.")
118

129
def checkSameBinaryProjects(lhs: Project, rhs: Project): Project.Initialize[Task[Unit]] =
1310
(classDirectory in Compile in lhs, classDirectory in Compile in rhs,

project/ScalaBuildKeys.scala

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ import sbt._
22
import Keys._
33

44
object ScalaBuildKeys {
5-
val lockerLock: TaskKey[Unit] = TaskKey("locker-lock",
6-
"Locks the locker layer of the compiler build such that it won't rebuild on changed source files.")
7-
val lockerUnlock: TaskKey[Unit] = TaskKey("locker-unlock",
8-
"Unlocks the locker layer of the compiler so that it will be recompiled on changed source files.")
9-
val lockFile: SettingKey[File] = SettingKey("lock-file",
10-
"Location of the lock file compiling this project.")
11-
// New tasks/settings specific to the scala build.
12-
val lock: TaskKey[Unit] = TaskKey("lock", "Locks this project so it won't be recompiled.")
13-
val unlock: TaskKey[Unit] = TaskKey("unlock", "Unlocks this project so it will be recompiled.")
14-
val makeDist: TaskKey[File] = TaskKey("make-dist",
15-
"Creates a mini-distribution (scala home directory) for this build in a zip file.")
16-
val makeExplodedDist: TaskKey[File] = TaskKey("make-exploded-dist",
17-
"Creates a mini-distribution (scala home directory) for this build in a directory.")
18-
val makeDistMappings: TaskKey[Map[File, String]] = TaskKey("make-dist-mappings",
19-
"Creates distribution mappings for creating zips,jars,directorys,etc.")
20-
val buildFixed = AttributeKey[Boolean]("build-uri-fixed")
21-
5+
val lockerLock = TaskKey[Unit]("locker-lock", "Locks the locker layer of the compiler build such that it won't rebuild on changed source files.")
6+
val lockerUnlock = TaskKey[Unit]("locker-unlock", "Unlocks the locker layer of the compiler so that it will be recompiled on changed source files.")
7+
val lockFile = SettingKey[File]("lock-file", "Location of the lock file compiling this project.")
8+
val lock = TaskKey[Unit]("lock", "Locks this project so it won't be recompiled.")
9+
val unlock = TaskKey[Unit]("unlock", "Unlocks this project so it will be recompiled.")
10+
val makeDist = TaskKey[File]("make-dist", "Creates a mini-distribution (scala home directory) for this build in a zip file.")
11+
val makeExplodedDist = TaskKey[File]("make-exploded-dist", "Creates a mini-distribution (scala home directory) for this build in a directory.")
12+
val makeDistMappings = TaskKey[Seq[(File, String)]]("make-dist-mappings", "Creates distribution mappings for creating zips,jars,directorys,etc.")
13+
val buildFixed = AttributeKey[Boolean]("build-uri-fixed")
14+
val genBinRunner = TaskKey[ScalaToolRunner]("gen-bin-runner", "Creates a utility to generate script files for Scala.")
15+
val genBin = TaskKey[Seq[(File,String)]]("gen-bin", "Creates script files for Scala distribution.")
16+
val binDir = SettingKey[File]("binaries-directory", "Directory where binary scripts will be located.")
17+
val genBinQuick = TaskKey[Seq[(File,String)]]("gen-quick-bin", "Creates script files for testing against current Scala build classfiles (not local dist).")
18+
val runManmakerMan = TaskKey[Seq[(File,String)]]("make-man", "Runs the man maker project to generate man pages")
19+
val runManmakerHtml = TaskKey[Seq[(File,String)]]("make-html", "Runs the man maker project to generate html pages")
20+
val checkSame = TaskKey[Unit]("check-same-binaries", "checks whether or not the class files generated by scala are the same.")
21+
val checkSameLibrary = TaskKey[Unit]("check-same-lib-binaries", "checks whether or not the librayr class files generated by scala are the same.")
22+
val checkSameCompiler = TaskKey[Unit]("check-same-comp-binaries", "checks whether or not the compiler class files generated by scala are the same.")
2223
}

project/ScalaToolRunner.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sbt._
2+
import Keys._
3+
4+
/** Reflection helper that runs ScalaTool.
5+
* TODO - When SBT is on 2.10.x try to use Dynamic + Reflection. COULD BE FUN.
6+
*/
7+
class ScalaToolRunner(classpath: Classpath) {
8+
// TODO - Don't use the ant task directly...
9+
lazy val classLoader = new java.net.URLClassLoader(classpath.map(_.data.toURI.toURL).toArray, null)
10+
lazy val mainClass = classLoader.loadClass("scala.tools.ant.ScalaTool")
11+
lazy val executeMethod = mainClass.getMethod("execute")
12+
lazy val setFileMethod = mainClass.getMethod("setFile", classOf[java.io.File])
13+
lazy val setClassMethod = mainClass.getMethod("setClass", classOf[String])
14+
lazy val setClasspathMethod = mainClass.getMethod("setClassPath", classOf[String])
15+
lazy val instance = mainClass.newInstance()
16+
17+
def setClass(cls: String): Unit = setClassMethod.invoke(instance, cls)
18+
def setFile(file: File): Unit = setFileMethod.invoke(instance, file)
19+
def setClasspath(cp: String): Unit = setClasspathMethod.invoke(instance, cp)
20+
def execute(): Unit = executeMethod.invoke(instance)
21+
}

0 commit comments

Comments
 (0)