1

I am new to the sbt and mill, and I am practicing to use both tool to build the chisel (scala project). View this github repo as a reference, I am wondering to know how to write the mill-version build.sh in that repo.

Here is my directory structure

─ chisel-template (root directory / projects directory)
├── build.sc
├── build.sh
├── src
|   └─main
|     └─scala
|       └─lab1
|         └─Mux2.scala
└── _temphelper.scala

What the build.sh do is preparing a boilerplate as main function in the root directory to make compile and run process much easier, and it's sbt version. I'm curious that why sbt can detect the main function (_temphelper.Elaborate) even it's not in the src/main directory. And when I change to use Mill, Mill can't detect the _temphelper.scala at all, unless I move the file to root/src/main. Is there settings that can make Mill do what sbt can do?

I'm not sure whether this issue is related to...

  1. altering the sourceDirectories in sbt and chiselMoudule.sources in Mill. Any advice is welcome.

  2. modify the millSourcePath to realize my request.

My quetions is What setting should I do to make mill can detect the main class that be in the root directory?

徐韋凱
  • 11
  • 1

1 Answers1

1

This is because sbt is including any Scala files it finds in the project root directory as sources files, unless told otherwise.

In contrast, Mill will only use the source files found under whatever directories are specified with sources. As a consequence, you may want to add the project root directory as source directory, but I strongly advice to do not so.

Best is to move the _temphelper.scala file either to one of the source directories or create a new dedicated directory, move the file there and add this directory to the sources like this:

object chiselModule extends CrossSbtModule // ...
{
  def sources = T.sources { 
    super.sources() ++ Seq(PathRef(T.workspace / "your" / "new" / "directory"))
  }
}

Tobias Roeser
  • 431
  • 2
  • 8
  • Thanks for your clear answer, it's really helpful for me!!! I also try to add another source directory in Mill , but I don't come up with an idea like yours haha! btw, can I ask another quetion? what's the meaning of "T" in Mill's build.sc? – 徐韋凱 Feb 24 '22 at 16:40
  • `mill.T` is kind of alias for `mill.define.Target`. For more info, read this page: https://com-lihaoyi.github.io/mill/mill/Tasks.html – Tobias Roeser Feb 24 '22 at 19:29