Hi !
I have been working on implementing a technique that would allow sbt to record dependencies on auxiliary files from macro-client.
The idea is to ask the author of the macro to attach to the expanded macro the list of the files that have been used to produce the expansion. Using this information, sbt would be able to invalidate macro-clients whenever a file used to produce a macro expansion is modified. This information would be given to sbt using a `java.util.HashMap[String, Any]` : The macro author would simply have to add a mapping from `touchedFiles` to a `List[java.io.File]` that contains the list of files that have been used to produce the expansion.
Please consult this scripted test for an example [1] of case where we encounter this kind of dependency.
The complete implementation can be found at [2] (it is based on #1736 [3]).
What do you think ?
The parts of this work that, I guess, may be the most surprising are :
- [4] Since we do not know where auxiliary files are in general, there's no directory that we can scan and get them all. We only see them if the compiled file advertise them. Therefore, we may not see them at all for a while, even if they have not be deleted. Therefore, we need to pass them from a previous analysis to the next, because otherwise sbt would consider that they have been deleted.
- [5] Adding a method `allAuxiliary` to `ReadStamps`. The methods of this kind (`allBinary`, ...) are all in the trait `Stamps` that extends `ReadStamps`. This method needs to be here because from method `changedInitial` in `IncrementalCommon.scala` we have an instance of `ReadStamps`. However, we need to check all the stamps on auxiliary dependencies to detect it if they have been changed.
Thank you for your comments !
Martin