From ce671343292e116aeaa043d75902400783bd42f5 Mon Sep 17 00:00:00 2001 From: David Biancolin Date: Sun, 21 Jun 2020 23:25:53 +0000 Subject: [PATCH] Support using bloop instead of SBT --- .gitignore | 1 + common.mk | 22 +++++++++++++++------- project/plugins.sbt | 1 + sims/firesim | 2 +- variables.mk | 17 ++++++++++++++++- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 47cb4d87..35d9b2d8 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ tags *~ env-riscv-tools.sh env-esp-tools.sh +.bloop/ diff --git a/common.mk b/common.mk index 5b502cb1..abd91b35 100644 --- a/common.mk +++ b/common.mk @@ -60,11 +60,19 @@ $(FIRRTL_TEST_JAR): $(call lookup_srcs,$(CHIPYARD_FIRRTL_DIR),scala) cp -p $(CHIPYARD_FIRRTL_DIR)/utils/bin/firrtl-test.jar $@ touch $@ + +######################################################################################### +# Bloop Project Definitions +######################################################################################### +$(BLOOP_CONFIG_DIR)/TIMESTAMP: $(base_dir)/build.sbt + cd $(base_dir) && $(SBT) "project chipyardRoot" "bloopInstall" + touch $@ + ######################################################################################### # create list of simulation file inputs ######################################################################################### -$(sim_files): $(call lookup_srcs,$(base_dir)/generators/utilities/src/main/scala,scala) $(FIRRTL_JAR) - cd $(base_dir) && $(SBT) "project utilities" "runMain utilities.GenerateSimFiles -td $(build_dir) -sim $(sim_name)" +$(sim_files): $(call lookup_srcs,$(base_dir)/generators/utilities/src/main/scala,scala) $(FIRRTL_JAR) $(SCALA_BUILDTOOL_DEPS) + $(call run_scala_main,utilities,utilities.GenerateSimFiles,-td $(build_dir) -sim $(sim_name)) ######################################################################################### # create firrtl file rule and variables @@ -76,11 +84,11 @@ $(FIRRTL_FILE) $(ANNO_FILE): generator_temp # AG: must re-elaborate if ariane sources have changed... otherwise just run firrtl compile generator_temp: $(SCALA_SOURCES) $(sim_files) $(EXTRA_GENERATOR_REQS) mkdir -p $(build_dir) - cd $(base_dir) && $(SBT) "project $(SBT_PROJECT)" "runMain $(GENERATOR_PACKAGE).Generator \ + $(call run_scala_main,$(SBT_PROJECT),$(GENERATOR_PACKAGE).Generator,\ --target-dir $(build_dir) \ --name $(long_name) \ --top-module $(MODEL_PACKAGE).$(MODEL) \ - --legacy-configs $(CONFIG_PACKAGE).$(CONFIG)" + --legacy-configs $(CONFIG_PACKAGE).$(CONFIG)) .PHONY: firrtl firrtl: $(FIRRTL_FILE) @@ -101,7 +109,7 @@ $(TOP_TARGETS) $(HARNESS_TARGETS): firrtl_temp @echo "" > /dev/null firrtl_temp: $(FIRRTL_FILE) $(ANNO_FILE) $(VLOG_SOURCES) - cd $(base_dir) && $(SBT) "project tapeout" "runMain barstools.tapeout.transforms.GenerateTopAndHarness -o $(TOP_FILE) -tho $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(VLOG_MODEL) -faf $(ANNO_FILE) -tsaof $(TOP_ANNO) -tdf $(sim_top_blackboxes) -tsf $(TOP_FIR) -thaof $(HARNESS_ANNO) -hdf $(sim_harness_blackboxes) -thf $(HARNESS_FIR) $(REPL_SEQ_MEM) $(HARNESS_CONF_FLAGS) -td $(build_dir)" && touch $(sim_top_blackboxes) $(sim_harness_blackboxes) + $(call run_scala_main,tapeout,barstools.tapeout.transforms.GenerateTopAndHarness,-o $(TOP_FILE) -tho $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(VLOG_MODEL) -faf $(ANNO_FILE) -tsaof $(TOP_ANNO) -tdf $(sim_top_blackboxes) -tsf $(TOP_FIR) -thaof $(HARNESS_ANNO) -hdf $(sim_harness_blackboxes) -thf $(HARNESS_FIR) $(REPL_SEQ_MEM) $(HARNESS_CONF_FLAGS) -td $(build_dir)) && touch $(sim_top_blackboxes) $(sim_harness_blackboxes) # DOC include end: FirrtlCompiler # This file is for simulation only. VLSI flows should replace this file with one containing hard SRAMs @@ -111,7 +119,7 @@ $(TOP_SMEMS_FILE) $(TOP_SMEMS_FIR): top_macro_temp @echo "" > /dev/null top_macro_temp: $(TOP_SMEMS_CONF) - cd $(base_dir) && $(SBT) "project barstoolsMacros" "runMain barstools.macros.MacroCompiler -n $(TOP_SMEMS_CONF) -v $(TOP_SMEMS_FILE) -f $(TOP_SMEMS_FIR) $(MACROCOMPILER_MODE)" + $(call run_scala_main,barstoolsMacros,barstools.macros.MacroCompiler,-n $(TOP_SMEMS_CONF) -v $(TOP_SMEMS_FILE) -f $(TOP_SMEMS_FIR) $(MACROCOMPILER_MODE)) HARNESS_MACROCOMPILER_MODE = --mode synflops .INTERMEDIATE: harness_macro_temp @@ -119,7 +127,7 @@ $(HARNESS_SMEMS_FILE) $(HARNESS_SMEMS_FIR): harness_macro_temp @echo "" > /dev/null harness_macro_temp: $(HARNESS_SMEMS_CONF) | top_macro_temp - cd $(base_dir) && $(SBT) "project barstoolsMacros" "runMain barstools.macros.MacroCompiler -n $(HARNESS_SMEMS_CONF) -v $(HARNESS_SMEMS_FILE) -f $(HARNESS_SMEMS_FIR) $(HARNESS_MACROCOMPILER_MODE)" + $(call run_scala_main,barstoolsMacros,barstools.macros.MacroCompiler, -n $(HARNESS_SMEMS_CONF) -v $(HARNESS_SMEMS_FILE) -f $(HARNESS_SMEMS_FIR) $(HARNESS_MACROCOMPILER_MODE)) ######################################################################################## # remove duplicate files and headers in list of simulation file inputs diff --git a/project/plugins.sbt b/project/plugins.sbt index 8de71081..3fe776fa 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -15,5 +15,6 @@ addSbtPlugin("com.simplytyped" % "sbt-antlr4" % "0.8.1") addSbtPlugin("com.github.gseitz" % "sbt-protobuf" % "0.6.3") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.4") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.1") libraryDependencies += "com.github.os72" % "protoc-jar" % "3.5.1.1" diff --git a/sims/firesim b/sims/firesim index c2d8e3a4..5e0ec3fd 160000 --- a/sims/firesim +++ b/sims/firesim @@ -1 +1 @@ -Subproject commit c2d8e3a46e59222e115a1fdaa7267592e1d3c503 +Subproject commit 5e0ec3fd70bc601fd5dae51414805c40f30a9871 diff --git a/variables.mk b/variables.mk index 1a3623a2..3abcc63b 100644 --- a/variables.mk +++ b/variables.mk @@ -125,9 +125,24 @@ JAVA_ARGS ?= -Xmx$(JAVA_HEAP_SIZE) -Xss8M -XX:MaxPermSize=256M ######################################################################################### SCALA_VERSION=2.12.10 SCALA_VERSION_MAJOR=$(basename $(SCALA_VERSION)) - SBT ?= java $(JAVA_ARGS) -jar $(ROCKETCHIP_DIR)/sbt-launch.jar +BLOOP ?= bloop +BLOOP_CONFIG_DIR ?= $(base_dir)/.bloop + +SCALA_BUILDTOOL_DEPS ?= $(base_dir)/build.sbt + +ifdef ENABLE_BLOOP +override SCALA_BUILDTOOL_DEPS += $(BLOOP_CONFIG_DIR)/TIMESTAMP +define run_scala_main + cd $(base_dir) && bloop run $(shell echo $(1) | sed 's/{.*}//') --main $(2) -- $(3) +endef +else +define run_scala_main + cd $(base_dir) && $(SBT) "project $(1)" "runMain $(2) $(3)" +endef +endif + ######################################################################################### # output directory for tests #########################################################################################