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/ target/
__pycache__ __pycache__
.idea

View File

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

View File

@ -47,7 +47,7 @@ object Inspect {
Project.details(structure, actual, sk.scope, sk.key) Project.details(structure, actual, sk.scope, sk.key)
case DependencyTreeMode => case DependencyTreeMode =>
val basedir = new File(Project.session(s).current.build) 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 => case UsesMode =>
Project.showUses(Project.usedBy(structure, true, sk.key)) Project.showUses(Project.usedBy(structure, true, sk.key))
case DefinitionsMode => case DefinitionsMode =>

View File

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