New Scala-based Config Finder
This commit is contained in:
committed by
abejgonzalez
parent
59b67c9612
commit
a5ee995ed4
@@ -149,7 +149,12 @@ lazy val chipyard = (project in file("generators/chipyard"))
|
|||||||
gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, fft_generator,
|
gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, fft_generator,
|
||||||
constellation, mempress)
|
constellation, mempress)
|
||||||
.settings(libraryDependencies ++= rocketLibDeps.value)
|
.settings(libraryDependencies ++= rocketLibDeps.value)
|
||||||
.settings(commonSettings)
|
.settings(
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"org.reflections" % "reflections" % "0.10.2"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.settings(commonSettings)
|
||||||
|
|
||||||
lazy val mempress = (project in file("generators/mempress"))
|
lazy val mempress = (project in file("generators/mempress"))
|
||||||
.dependsOn(rocketchip, midasTargetUtils)
|
.dependsOn(rocketchip, midasTargetUtils)
|
||||||
|
|||||||
10
common.mk
10
common.mk
@@ -50,7 +50,7 @@ HELP_COMMANDS += \
|
|||||||
" run-tests = run all assembly and benchmark tests" \
|
" run-tests = run all assembly and benchmark tests" \
|
||||||
" launch-sbt = start sbt terminal" \
|
" launch-sbt = start sbt terminal" \
|
||||||
" {shutdown,start}-sbt-server = shutdown or start sbt server if using ENABLE_SBT_THIN_CLIENT" \
|
" {shutdown,start}-sbt-server = shutdown or start sbt server if using ENABLE_SBT_THIN_CLIENT" \
|
||||||
" find-config-fragments = list all config. fragments and their locations (recursive up to CONFIG_FRAG_LEVELS=$(CONFIG_FRAG_LEVELS))"
|
" find-config-fragments = list all config. fragments"
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# include additional subproject make fragments
|
# include additional subproject make fragments
|
||||||
@@ -406,13 +406,9 @@ define \n
|
|||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
CONFIG_FRAG_LEVELS ?= 3
|
|
||||||
.PHONY: find-config-fragments
|
.PHONY: find-config-fragments
|
||||||
find-config-fragments: private IN_F := $(shell mktemp -d -t cy-XXXXXXXX)/scala_files.f
|
find-config-fragments:
|
||||||
find-config-fragments: $(SCALA_SOURCES)
|
$(call run_scala_main,chipyard,chipyard.ConfigFinder,)
|
||||||
@$(foreach file,$(SCALA_SOURCES),echo $(file) >> $(IN_F)${\n})
|
|
||||||
$(base_dir)/scripts/config-finder.py -l $(CONFIG_FRAG_LEVELS) $(IN_F)
|
|
||||||
@rm -rf $(dir $(IN_F))
|
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
|
|||||||
@@ -79,5 +79,4 @@ We can use this config fragment when composing our configs.
|
|||||||
Chipyard Config Fragments
|
Chipyard Config Fragments
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
For discoverability, users can run ``make find-config-fragments`` to see a list of config. fragments
|
For discoverability, users can run ``make find-config-fragments`` to see a list of config. fragments.
|
||||||
(config. fragments that match "class NAME extends CONFIG\n" on a single line and a subset of their children) and their file path in a fully initialized Chipyard repository.
|
|
||||||
|
|||||||
19
generators/chipyard/src/main/scala/ConfigFinder.scala
Normal file
19
generators/chipyard/src/main/scala/ConfigFinder.scala
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package chipyard
|
||||||
|
|
||||||
|
import org.reflections.Reflections
|
||||||
|
import org.reflections.scanners.Scanners.SubTypes
|
||||||
|
import scala.jdk.CollectionConverters._
|
||||||
|
import scala.collection.{SortedSet}
|
||||||
|
|
||||||
|
import freechips.rocketchip.config.{Config}
|
||||||
|
|
||||||
|
object ConfigFinder {
|
||||||
|
def main(args: Array[String]) = {
|
||||||
|
val reflections = new Reflections()
|
||||||
|
val classes = reflections.get(SubTypes.of(classOf[Config]).asClass()).asScala
|
||||||
|
val sortedClasses = SortedSet[String]() ++ classes.map(_.getName)
|
||||||
|
for (cls <- sortedClasses) {
|
||||||
|
println(cls)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user