Skip to content

Commit

Permalink
2.8.x compatibility issues. Needs to use at least 2.8.3-SNAPSHOT as i…
Browse files Browse the repository at this point in the history
…t provides MurmurHash which is then used for hashing API and reducing memory footprint. Also cannot use sys package as it wasn't ported to 2.8.x
  • Loading branch information
hubertp authored and dragos committed Jan 20, 2012
1 parent 26273c0 commit 7905d05
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 15 deletions.
19 changes: 18 additions & 1 deletion compile/api/HashAPI.scala
Expand Up @@ -89,6 +89,23 @@ final class HashAPI(tags: TypeVars, includePrivate: Boolean, includeParamNames:
}
final def hashSymmetric[T](ts: TraversableOnce[T], hashF: T => Unit)
{
class Compat[A](underlying: List[A]) {
def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3)): (List[A1], List[A2], List[A3]) = {
val b1 = underlying.genericBuilder[A1]
val b2 = underlying.genericBuilder[A2]
val b3 = underlying.genericBuilder[A3]
for (xyz <- underlying) {
val (x, y, z) = asTriple(xyz)
b1 += x
b2 += y
b3 += z
}
(b1.result, b2.result, b3.result)
}
}

implicit def unzip3Compat[A](a: List[A]) = new Compat(a)

val current = hash
val mA = magicA
val mB = magicB
Expand All @@ -98,7 +115,7 @@ final class HashAPI(tags: TypeVars, includePrivate: Boolean, includeParamNames:
magicB = startMagicB
hashF(t)
(finalizeHash(hash), magicA, magicB)
} unzip3;
}.unzip3
hash = current
magicA = mA
magicB = mB
Expand Down
2 changes: 1 addition & 1 deletion compile/inc/Relations.scala
Expand Up @@ -114,7 +114,7 @@ private class MRelations(val srcProd: Relation[File, File], val binaryDep: Relat
new MRelations(srcProd -- sources, binaryDep -- sources, internalSrcDep -- sources, externalDep -- sources, classes -- sources)

/** Making large Relations a little readable. */
private val userDir = sys.props("user.dir").stripSuffix("/") + "/"
private val userDir = System.getProperty("user.dir").stripSuffix("/") + "/" // be dumm and don't use sys package, sorry not ported to 2.8
private def nocwd(s: String) = s stripPrefix userDir
private def line_s(kv: (Any, Any)) = " " + nocwd("" + kv._1) + " -> " + nocwd("" + kv._2) + "\n"
private def relation_s(r: Relation[_, _]) = (
Expand Down
3 changes: 2 additions & 1 deletion main/Defaults.scala
Expand Up @@ -15,7 +15,6 @@ package sbt
import inc.{FileValueCache, Locate}
import org.scalatools.testing.{AnnotatedFingerprint, SubclassFingerprint}

import sys.error
import scala.xml.{Node => XNode,NodeSeq}
import org.apache.ivy.core.module.{descriptor, id}
import descriptor.ModuleDescriptor, id.ModuleRevisionId
Expand All @@ -31,6 +30,8 @@ package sbt

object Defaults extends BuildCommon
{
def error(message: String): Nothing = throw new RuntimeException(message) // For 2.8 compatibility, don't use sys.error

def configSrcSub(key: SettingKey[File]): Initialize[File] = (key in ThisScope.copy(config = Global), configuration) { (src, conf) => src / nameForSrc(conf.name) }
def nameForSrc(config: String) = if(config == "compile") "main" else config
def prefix(config: String) = if(config == "compile") "" else config + "-"
Expand Down
2 changes: 1 addition & 1 deletion main/EvaluateTask.scala
Expand Up @@ -35,7 +35,7 @@ object EvaluateTask
processResult(result, log)
}

@deprecated("This method does not apply state changes requested during task execution. Use 'apply' instead, which does.", "0.11.1")
@deprecated("This method does not apply state changes requested during task execution. Use 'apply' instead, which does.")
def evaluateTask[T](structure: BuildStructure, taskKey: ScopedKey[Task[T]], state: State, ref: ProjectRef, checkCycles: Boolean = false, maxWorkers: Int = SystemProcessors): Option[Result[T]] =
apply(structure, taskKey, state, ref, checkCycles, maxWorkers).map(_._2)
def apply[T](structure: BuildStructure, taskKey: ScopedKey[Task[T]], state: State, ref: ProjectRef, checkCycles: Boolean = false, maxWorkers: Int = SystemProcessors): Option[(State, Result[T])] =
Expand Down
4 changes: 2 additions & 2 deletions main/Project.scala
Expand Up @@ -70,7 +70,7 @@ final case class Extracted(structure: BuildStructure, session: SessionSettings,
def get[T](key: SettingKey[T]) = getOrError(inCurrent(key), key.key)
def getOpt[T](key: SettingKey[T]): Option[T] = structure.data.get(inCurrent(key), key.key)
private[this] def inCurrent[T](key: SettingKey[T]): Scope = if(key.scope.project == This) key.scope.copy(project = Select(currentRef)) else key.scope
@deprecated("This method does not apply state changes requested during task execution. Use 'runTask' instead, which does.", "0.11.1")
@deprecated("This method does not apply state changes requested during task execution. Use 'runTask' instead, which does.")
def evalTask[T](key: TaskKey[T], state: State): T = runTask(key, state)._2
def runTask[T](key: TaskKey[T], state: State): (State, T) =
{
Expand Down Expand Up @@ -336,7 +336,7 @@ object Project extends Init[Scope] with ProjectExtra
val newS = setProjectReturn(s, newBase :: projectReturn(s))
(newS, newBase)
}
@deprecated("This method does not apply state changes requested during task execution. Use 'runTask' instead, which does.", "0.11.1")
@deprecated("This method does not apply state changes requested during task execution. Use 'runTask' instead, which does.")
def evaluateTask[T](taskKey: ScopedKey[Task[T]], state: State, checkCycles: Boolean = false, maxWorkers: Int = EvaluateTask.SystemProcessors): Option[Result[T]] =
runTask(taskKey, state, checkCycles, maxWorkers).map(_._2)
def runTask[T](taskKey: ScopedKey[Task[T]], state: State, checkCycles: Boolean = false, maxWorkers: Int = EvaluateTask.SystemProcessors): Option[(State, Result[T])] =
Expand Down
4 changes: 2 additions & 2 deletions main/Structure.scala
Expand Up @@ -163,7 +163,7 @@ object Scoped
}
final class RichInitialize[S](init: Initialize[S])
{
@deprecated("A call to 'identity' is no longer necessary and can be removed.", "0.11.0")
@deprecated("A call to 'identity' is no longer necessary and can be removed.")
final def identity: Initialize[S] = init
def map[T](f: S => T): Initialize[Task[T]] = init(s => mktask(f(s)) )
def flatMap[T](f: S => Task[T]): Initialize[Task[T]] = init(f)
Expand All @@ -182,7 +182,7 @@ object Scoped
def task: SettingKey[Task[S]] = scopedSetting(scope, key)
def get(settings: Settings[Scope]): Option[Task[S]] = settings.get(scope, key)

@deprecated("A call to 'identity' is no longer necessary and can be removed.", "0.11.0")
@deprecated("A call to 'identity' is no longer necessary and can be removed.")
def identity: Initialize[Task[S]] = this

def ? : Initialize[Task[Option[S]]] = Project.optional(scopedKey) { case None => mktask { None }; case Some(t) => t map some.fn }
Expand Down
2 changes: 1 addition & 1 deletion main/TaskData.scala
Expand Up @@ -11,7 +11,7 @@ package sbt

import sbinary.{Format, Operations}

@deprecated("Superseded by task state system.", "0.11.1")
@deprecated("Superseded by task state system.")
object TaskData
{
val DefaultDataID = "data"
Expand Down
1 change: 1 addition & 0 deletions project/Sbt.scala
Expand Up @@ -102,6 +102,7 @@ object Sbt extends Build
lazy val precompiled210 = precompiled("2.10.0-SNAPSHOT", scalaVersionGlobal)
lazy val precompiled291 = precompiled("2.9.1", scalaVersionGlobal)
lazy val precompiled29 = precompiled("2.9.0-1", scalaVersionGlobal)
lazy val precompiled283 = precompiled("2.8.3-SNAPSHOT", scalaVersionGlobal)
lazy val precompiled282 = precompiled("2.8.2", scalaVersionGlobal)
lazy val precompiled28 = precompiled("2.8.1", scalaVersionGlobal)

Expand Down
6 changes: 3 additions & 3 deletions project/Util.scala
Expand Up @@ -5,9 +5,9 @@

private object VersionComp {
val versionMap = Map(
"scalacheck" -> Map("2.8.1" -> "1.8", "2.9.0-1" -> "1.9", "2.9.1" -> "1.9", "2.10.0-SNAPSHOT" -> "1.9"),
"sbinary" -> Map("2.8.1" -> "0.4.0", "2.9.0" -> "0.4.0", "2.9.0-1" -> "0.4.0", "2.9.1" -> "0.4.0", "2.10.0-SNAPSHOT" -> "0.4.0"),
"sxr" -> Map("2.8.1" -> "0.2.7", "2.9.0-1" -> "0.2.7", "2.9.1" -> "0.2.7", "2.10.0-SNAPSHOT" -> "0.2.7-SNAPSHOT")
"scalacheck" -> Map("2.8.1" -> "1.8", "2.8.2" -> "1.8", "2.8.3-SNAPSHOT" -> "1.8", "2.9.1" -> "1.9", "2.10.0-SNAPSHOT" -> "1.9"),
"sbinary" -> Map("2.8.1" -> "0.4.0", "2.8.2" -> "0.4.0", "2.8.3-SNAPSHOT" -> "0.4.0", "2.9.0" -> "0.4.0", "2.9.1" -> "0.4.0", "2.10.0-SNAPSHOT" -> "0.4.0"),
"sxr" -> Map("2.8.1" -> "0.2.7", "2.8.2" -> "0.2.7", "2.8.3-SNAPSHOT" -> "0.2.7", "2.9.1" -> "0.2.7", "2.10.0-SNAPSHOT" -> "0.2.7-SNAPSHOT")
)
}

Expand Down
6 changes: 3 additions & 3 deletions sbt/package.scala
Expand Up @@ -4,11 +4,11 @@
package object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtra with sbt.impl.DependencyBuilders
with sbt.PathExtra with sbt.ProjectExtra with sbt.DependencyFilterExtra with sbt.BuildExtra
{
@deprecated("Use SettingKey, which is a drop-in replacement.", "0.11.1")
@deprecated("Use SettingKey, which is a drop-in replacement.")
type ScopedSetting[T] = SettingKey[T]
@deprecated("Use TaskKey, which is a drop-in replacement.", "0.11.1")
@deprecated("Use TaskKey, which is a drop-in replacement.")
type ScopedTask[T] = TaskKey[T]
@deprecated("Use InputKey, which is a drop-in replacement.", "0.11.1")
@deprecated("Use InputKey, which is a drop-in replacement.")
type ScopedInput[T] = InputKey[T]

type Setting[T] = Project.Setting[T]
Expand Down
7 changes: 7 additions & 0 deletions util/collection/IDSet.scala
Expand Up @@ -42,4 +42,11 @@ object IDSet
def process[S](t: T)(ifSeen: S)(ifNew: => S) = if(contains(t)) ifSeen else { this += t ; ifNew }
override def toString = backing.toString
}

private class Compat {
def iterableAsScalaIterable[T](coll: java.util.Set[T]) = collection.JavaConversions.asIterable(coll)
def asIterable[T](coll: java.util.Set[T]): Nothing = throw new RuntimeException("For source compatibility only: should not get here.")
}

private[this] final implicit def miscCompat(n: AnyRef): Compat = new Compat
}

0 comments on commit 7905d05

Please sign in to comment.