This commit is contained in:
Roman Iakovlev 2016-05-30 18:33:26 +02:00 committed by Eugene Yokota
parent 982a7c8724
commit e8b951c0d1
4 changed files with 8 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
target/
__pycache__
.idea

View File

@ -534,8 +534,8 @@ object Project extends ProjectExtra {
printScopes("Delegates", delegates(structure, scope, key)) +
printScopes("Related", related, 10)
}
def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_], maxGraphWidth: Int)(implicit display: Show[ScopedKey[_]]): SettingGraph =
SettingGraph(structure, basedir, scoped, 0, maxGraphWidth)
def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_])(implicit display: Show[ScopedKey[_]]): SettingGraph =
SettingGraph(structure, basedir, scoped, 0)
def graphSettings(structure: BuildStructure, basedir: File)(implicit display: Show[ScopedKey[_]]): Unit = {
def graph(actual: Boolean, name: String) = graphSettings(structure, actual, name, new File(basedir, name + ".dot"))
graph(true, "actual_dependencies")

View File

@ -47,7 +47,7 @@ object Inspect {
Project.details(structure, actual, sk.scope, sk.key)
case DependencyTreeMode =>
val basedir = new File(Project.session(s).current.build)
Project.settingGraph(structure, basedir, sk, get(sbt.Keys.asciiGraphWidth)).dependsAscii
Project.settingGraph(structure, basedir, sk).dependsAscii(get(sbt.Keys.asciiGraphWidth))
case UsesMode =>
Project.showUses(Project.usedBy(structure, true, sk.key))
case DefinitionsMode =>

View File

@ -13,7 +13,7 @@ import Predef.{ any2stringadd => _, _ }
import sbt.io.IO
object SettingGraph {
def apply(structure: BuildStructure, basedir: File, scoped: ScopedKey[_], generation: Int, graphMaxWidth: Int)(implicit display: Show[ScopedKey[_]]): SettingGraph =
def apply(structure: BuildStructure, basedir: File, scoped: ScopedKey[_], generation: Int)(implicit display: Show[ScopedKey[_]]): SettingGraph =
{
val cMap = flattenLocals(compiled(structure.settings, false)(structure.delegates, structure.scopeLocal, display))
def loop(scoped: ScopedKey[_], generation: Int): SettingGraph =
@ -28,8 +28,7 @@ object SettingGraph {
SettingGraph(display(scoped), definedIn,
Project.scopedKeyData(structure, scope, key),
key.description, basedir,
depends map { (x: ScopedKey[_]) => loop(x, generation + 1) },
graphMaxWidth)
depends map { (x: ScopedKey[_]) => loop(x, generation + 1) })
}
loop(scoped, generation)
}
@ -41,8 +40,7 @@ case class SettingGraph(
data: Option[ScopedKeyData[_]],
description: Option[String],
basedir: File,
depends: Set[SettingGraph],
graphMaxWidth: Int
depends: Set[SettingGraph]
) {
def dataString: String =
data map { d =>
@ -52,11 +50,11 @@ case class SettingGraph(
} getOrElse { d.typeName }
} getOrElse { "" }
def dependsAscii: String = Graph.toAscii(
def dependsAscii(defaultWidth: Int): String = Graph.toAscii(
this,
(x: SettingGraph) => x.depends.toSeq.sortBy(_.name),
(x: SettingGraph) => "%s = %s" format (x.definedIn getOrElse { "" }, x.dataString),
graphMaxWidth
defaultWidth
)
}