diff --git a/nix/pkgs/mill-builder.nix b/nix/pkgs/mill-builder.nix index 79b37f767..fbab7ebe1 100644 --- a/nix/pkgs/mill-builder.nix +++ b/nix/pkgs/mill-builder.nix @@ -12,12 +12,22 @@ let mill ] ++ (args.nativeBuildInputs or [ ]); - impureEnvVars = [ "JAVA_OPTS" ]; + impureEnvVars = [ "https_proxy" "JAVA_OPTS" ]; buildPhase = '' runHook preBuild + export JAVA_OPTS="-Duser.home=$TMPDIR $JAVA_OPTS" + if [[ -z "$https_proxy" && ! "proxyHost" =~ "$JAVA_OPTS" ]]; then + _https_proxy="''${https_proxy#http://}" + _https_proxy="''${_https_proxy#https://}" + _https_proxy_parts=(''${_https_proxy//:/ }) + _host=''${_https_proxy_parts[0]} + _port=''${_https_proxy_parts[1]} + export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=$_host -Dhttp.proxyPort=$_port -Dhttps.proxyHost=$_host -Dhttps.proxyPort=$_port" + fi + # Use "https://repo1.maven.org/maven2/" only to keep dependencies integrity export COURSIER_REPOSITORIES="central" @@ -32,7 +42,10 @@ let # And we don't want to wait too long for a dependencies task, so here is the solution: # "checkFormat" the "build.sc" file so that mill will download scalafmt for us, # and we don't need to wait too long for formatting. - mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll buildSources + if ! mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll buildSources; then + echo "[ERROR] build.sc is misformatted, please run 'mill -i mill.scalalib.scalafmt.ScalafmtModule/reformatAll buildSources'" >&2 + exit 1 + fi runHook postBuild ''; diff --git a/nix/t1/conversion/sv-to-verilator-emulator.nix b/nix/t1/conversion/sv-to-verilator-emulator.nix index 10a915317..6f3c13b57 100644 --- a/nix/t1/conversion/sv-to-verilator-emulator.nix +++ b/nix/t1/conversion/sv-to-verilator-emulator.nix @@ -30,6 +30,8 @@ rec { "--cc" "--main" "--exe" + "--timescale" + "1ns/1ps" "--timing" "--threads" (toString verilatorThreads) diff --git a/script/build.sc b/script/build.sc index ed06d5748..897b9c587 100644 --- a/script/build.sc +++ b/script/build.sc @@ -7,15 +7,18 @@ import mill.scalalib.TestModule.Utest import mill.util.Jvm import coursier.maven.MavenRepository -trait ScriptModule extends ScalaModule { +// Required for scalafmt to recognize which file to format +def buildSources = T.sources(os.pwd / "build.sc") + +trait ScriptModule extends ScalaModule with ScalafmtModule { val scala3 = "3.3.3" val mainargs = ivy"com.lihaoyi::mainargs:0.5.0" val oslib = ivy"com.lihaoyi::os-lib:0.10.0" val upickle = ivy"com.lihaoyi::upickle:3.3.1" - def scalaVersion = scala3 - def scalacOptions = Seq("-new-syntax", "-deprecation") - override def ivyDeps = Agg(mainargs, oslib, upickle) + def scalaVersion = scala3 + def scalacOptions = Seq("-new-syntax", "-deprecation") + override def ivyDeps = Agg(mainargs, oslib, upickle) } object emu extends ScriptModule {} diff --git a/script/ci/src/Main.scala b/script/ci/src/Main.scala index 75ccbc036..37244550a 100644 --- a/script/ci/src/Main.scala +++ b/script/ci/src/Main.scala @@ -235,8 +235,7 @@ object Main: "## Cycle Update\n" ) - if urgReportFilePath.nonEmpty then - os.write(os.Path(urgReportFilePath.get, os.pwd), "# Coverage report\n") + if urgReportFilePath.nonEmpty then os.write(os.Path(urgReportFilePath.get, os.pwd), "# Coverage report\n") os.walk(os.pwd / ".github" / caseDir) .filter(_.last == "default.json") diff --git a/script/default.nix b/script/default.nix index 0502741ea..e92e82aea 100644 --- a/script/default.nix +++ b/script/default.nix @@ -19,6 +19,7 @@ let fileset = unions [ scriptSrc ./build.sc + ./.scalafmt.conf ]; }; @@ -28,9 +29,10 @@ let root = ./.; fileset = unions [ ./build.sc + ./.scalafmt.conf ]; }; - millDepsHash = "sha256-QQ5gCbvovC55t9MmfCNTvNFdD6FcNqmLmfhT9qJhQQc="; + millDepsHash = "sha256-y8tAFwctiU6ehghuf7KP73DuWCGCnAAdIXOIPwT+QOo="; }; passthru.withLsp = self.overrideAttrs (old: { @@ -58,15 +60,26 @@ let ]; buildPhase = '' + runHook preBuild + + echo "Checking format" + mill -i ${moduleName}.checkFormat + echo "Building JAR" mill -i ${moduleName}.assembly echo "Running native-image" native-image --no-fallback -jar out/${moduleName}/assembly.dest/out.jar "$name.elf" + + runHook postBuild ''; installPhase = '' + runHook preInstall + mkdir -p "$out"/bin cp "$name.elf" "$out"/bin/"${outName}" + + runHook postInstall ''; meta.mainProgram = toString outName; diff --git a/script/emu/src/Main.scala b/script/emu/src/Main.scala index 41f9893de..f8bb9e66b 100644 --- a/script/emu/src/Main.scala +++ b/script/emu/src/Main.scala @@ -168,6 +168,10 @@ object Main: name = "dry-run", doc = "Print the final emulator command line and exit" ) dryRun: Flag = Flag(false), + @arg( + name = "timeout", + doc = "Specify maximum cycle count limit" + ) timeout: Option[Int] = None, leftOver: Leftover[String] ): Unit = if leftOver.value.isEmpty then Logger.fatal("No test case name") @@ -204,6 +208,7 @@ object Main: emulator.toString(), s"+t1_elf_file=${caseElfPath}" ) + ++ optionals(timeout.isDefined, Seq(s"+t1_timeout=${timeout.getOrElse("unreachable")}")) ++ optionals(isTrace, Seq(s"+t1_wave_path=${outputPath / "wave.fsdb"}")) ++ optionals(isCover, Seq(s"-cm assert")) ++ optionals(!leftOverArguments.isEmpty, leftOverArguments) @@ -266,8 +271,7 @@ object Main: os.move(os.pwd / "cm.vdb", outputPath / "cm.vdb", replaceExisting = true) os.move(os.pwd / "cm.log", outputPath / "cm.log", replaceExisting = true) Logger.info(s"Coverage database saved under ${outputPath}/cm.vdb") - else - Logger.error("No cm.vdb cm.log found") + else if !finalEmuType.get.startsWith("verilator-emu") then Logger.error("No cm.vdb cm.log found") if os.exists(os.pwd / "perf.json") then os.move(os.pwd / "perf.json", outputPath / "perf.json", replaceExisting = true)