Skip to content

Add a hook to filter out Scala options in every compile #406

@jvican

Description

@jvican

If scala options change from one run to the other one, Zinc recompiles the whole project conservatively.

With the advent of compilers like Dotty, Hydra and rsc, the current behaviour is too restrictive because some downstream users may want to filter out scalac options that are dependent to the way compilation should occur (like number of cores). This is safe to do because downstream users know which scala flags affect the compilation and which do not.

You can add this hook in ExternalHooks https://github.com/sbt/zinc/blob/1.x/internal/compiler-interface/src/main/java/xsbti/compile/ExternalHooks.java and https://github.com/sbt/zinc/blob/1.x/internal/compiler-interface/src/main/java/xsbti/compile/DefaultExternalHooks.java. The method compile in IncrementalCompilerImpl already takes an instance of IncOptions, which inside has an instance of ExternalHooks, so the last thing to do is to use the external hook we've just provided in the body of makeConfig, inside MixedAnalyzingCompiler: https://github.com/sbt/zinc/blob/1.x/zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala#L183-L214

/cc @dragos

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions