Skip to content

Commit

Permalink
Add option to disable incremental compilation
Browse files Browse the repository at this point in the history
Now it is possible to disable incremental compilation metadata creation in
IncOptions and directly in AnalysisCallback.
  • Loading branch information
romanowski committed Jan 27, 2017
1 parent 7215eae commit f898c2b
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ lazy val zincScripted = (project in internalPath / "zinc-scripted").
configure(addSbtUtilScripted)

lazy val publishBridgesAndTest = Command.args("publishBridgesAndTest", "<version>") { (state, args) =>
require(args.nonEmpty)
require(args.nonEmpty, "Missing arguments to publishBridgesAndTest. Maybe quotes are missing around command?")
val version = args mkString ""
s"${compilerInterface.id}/publishLocal" ::
// using plz here causes: java.lang.OutOfMemoryError: GC overhead limit exceeded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial
override lazy val phaseDescriptors =
{
phasesSet += sbtAnalyzer
phasesSet += sbtDependency
phasesSet += apiExtractor
if (callback.enabled()) {
phasesSet += sbtDependency
phasesSet += apiExtractor
}
superComputePhaseDescriptors
}
// Required because computePhaseDescriptors is private in 2.8 (changed to protected sometime later).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,10 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial
override lazy val phaseDescriptors =
{
phasesSet += sbtAnalyzer
phasesSet += sbtDependency
phasesSet += apiExtractor
if (callback.enabled()) {
phasesSet += sbtDependency
phasesSet += apiExtractor
}
superComputePhaseDescriptors
}
// Required because computePhaseDescriptors is private in 2.8 (changed to protected sometime later).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
"Determines whether incremental compiler stores apis alongside analysis."
]
},
{
"name": "enabled",
"type": "boolean",
"doc": [
"Determines whether incremental compilation is enabled."
]
},
{
"name": "antStyle",
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ public interface AnalysisCallback {

/** Called at the end of dependency phase. Can be used e.g. to wait on asynchronous tasks. */
void apiPhaseCompleted();

/** Determines if incremental compilation is enabled.
* If returns false, only xsbt-analyzer phase will be added (in order to report generated classes) */
boolean enabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public static boolean defaultStoreApis() {
return true;
}

public static boolean defaultEnabled() {
return true;
}

public static boolean defaultAntStyle() {
return false;
}
Expand Down Expand Up @@ -117,7 +121,7 @@ public static IncOptions defaultIncOptions() {
defaultApiDiffContextSize(), defaultApiDumpDirectory(),
defaultClassfileManagerType(), defaultUseCustomizedFileManager(),
defaultRecompileOnMacroDef(), defaultNameHashing(),
defaultStoreApis(), defaultAntStyle(),
defaultStoreApis(), defaultEnabled(), defaultAntStyle(),
defaultExtra(), defaultLogRecompileOnMacro(),
defaultExternal());
return retval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class TestCallback(override val nameHashing: Boolean = false) extends AnalysisCa
apis(source) += api
()
}

override def enabled(): Boolean = true

def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean): Unit = ()

override def dependencyPhaseCompleted(): Unit = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ private final class AnalysisCallback(

def nameHashing: Boolean = options.nameHashing

override def enabled(): Boolean = options.enabled

def get: Analysis =
addUsedNames(addCompilation(addProductsAndDeps(Analysis.empty(nameHashing = nameHashing))))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ class TestAnalysisCallback(
}
}

override def enabled(): Boolean = true

def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean): Unit = ()

override def dependencyPhaseCompleted(): Unit = {}
Expand Down

0 comments on commit f898c2b

Please sign in to comment.