mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Gradle: report build progress from build tasks
This commit is contained in:
parent
bcc2c0ff35
commit
d33c491a33
|
@ -364,14 +364,14 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
||||||
*/
|
*/
|
||||||
public void build(BuildTarget buildTarget, String outputName) {
|
public void build(BuildTarget buildTarget, String outputName) {
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
reportPhase(TeaVMPhase.DEPENDENCY_ANALYSIS, lastKnownClasses > 0 ? lastKnownClasses : 1);
|
reportPhase(TeaVMPhase.DEPENDENCY_ANALYSIS, lastKnownClasses);
|
||||||
if (wasCancelled()) {
|
if (wasCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyAnalyzer.setAsyncSupported(target.isAsyncSupported());
|
dependencyAnalyzer.setAsyncSupported(target.isAsyncSupported());
|
||||||
dependencyAnalyzer.setInterruptor(() -> {
|
dependencyAnalyzer.setInterruptor(() -> {
|
||||||
int progress = lastKnownClasses > 0 ? dependencyAnalyzer.getReachableClasses().size() : 0;
|
int progress = dependencyAnalyzer.getReachableClasses().size();
|
||||||
cancelled |= progressListener.progressReached(progress) != TeaVMProgressFeedback.CONTINUE;
|
cancelled |= progressListener.progressReached(progress) != TeaVMProgressFeedback.CONTINUE;
|
||||||
return !cancelled;
|
return !cancelled;
|
||||||
});
|
});
|
||||||
|
@ -417,7 +417,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
||||||
// Render
|
// Render
|
||||||
try {
|
try {
|
||||||
if (!isLazy) {
|
if (!isLazy) {
|
||||||
compileProgressReportStart = 500;
|
compileProgressReportStart = 0;
|
||||||
compileProgressReportLimit = 1000;
|
compileProgressReportLimit = 1000;
|
||||||
}
|
}
|
||||||
target.emit(classSet, buildTarget, outputName);
|
target.emit(classSet, buildTarget, outputName);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.rmi.NotBoundException;
|
||||||
import java.rmi.registry.LocateRegistry;
|
import java.rmi.registry.LocateRegistry;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import javax.inject.Inject;
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
import org.gradle.api.GradleException;
|
import org.gradle.api.GradleException;
|
||||||
import org.gradle.api.file.ConfigurableFileCollection;
|
import org.gradle.api.file.ConfigurableFileCollection;
|
||||||
|
@ -33,6 +34,8 @@ import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.Optional;
|
import org.gradle.api.tasks.Optional;
|
||||||
import org.gradle.api.tasks.OutputDirectory;
|
import org.gradle.api.tasks.OutputDirectory;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
import org.gradle.internal.logging.progress.ProgressLogger;
|
||||||
|
import org.gradle.internal.logging.progress.ProgressLoggerFactory;
|
||||||
import org.teavm.gradle.api.OptimizationLevel;
|
import org.teavm.gradle.api.OptimizationLevel;
|
||||||
import org.teavm.tooling.TeaVMProblemRenderer;
|
import org.teavm.tooling.TeaVMProblemRenderer;
|
||||||
import org.teavm.tooling.builder.BuildException;
|
import org.teavm.tooling.builder.BuildException;
|
||||||
|
@ -43,6 +46,9 @@ import org.teavm.tooling.daemon.BuildDaemon;
|
||||||
import org.teavm.tooling.daemon.DaemonLog;
|
import org.teavm.tooling.daemon.DaemonLog;
|
||||||
import org.teavm.tooling.daemon.RemoteBuildService;
|
import org.teavm.tooling.daemon.RemoteBuildService;
|
||||||
import org.teavm.vm.TeaVMOptimizationLevel;
|
import org.teavm.vm.TeaVMOptimizationLevel;
|
||||||
|
import org.teavm.vm.TeaVMPhase;
|
||||||
|
import org.teavm.vm.TeaVMProgressFeedback;
|
||||||
|
import org.teavm.vm.TeaVMProgressListener;
|
||||||
|
|
||||||
public abstract class TeaVMTask extends DefaultTask {
|
public abstract class TeaVMTask extends DefaultTask {
|
||||||
public TeaVMTask() {
|
public TeaVMTask() {
|
||||||
|
@ -102,6 +108,9 @@ public abstract class TeaVMTask extends DefaultTask {
|
||||||
@Internal
|
@Internal
|
||||||
public abstract Property<Integer> getDaemonDebugPort();
|
public abstract Property<Integer> getDaemonDebugPort();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected abstract ProgressLoggerFactory getProgressLoggerFactory();
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void execute() throws BuildException, IOException, NotBoundException {
|
public void execute() throws BuildException, IOException, NotBoundException {
|
||||||
if (getOutOfProcess().get()) {
|
if (getOutOfProcess().get()) {
|
||||||
|
@ -149,6 +158,7 @@ public abstract class TeaVMTask extends DefaultTask {
|
||||||
}
|
}
|
||||||
builder.setProperties(properties);
|
builder.setProperties(properties);
|
||||||
}
|
}
|
||||||
|
builder.setProgressListener(createProgressListener());
|
||||||
setupBuilder(builder);
|
setupBuilder(builder);
|
||||||
var result = builder.build();
|
var result = builder.build();
|
||||||
TeaVMProblemRenderer.describeProblems(result.getCallGraph(), result.getProblems(), toolLog);
|
TeaVMProblemRenderer.describeProblems(result.getCallGraph(), result.getProblems(), toolLog);
|
||||||
|
@ -157,6 +167,57 @@ public abstract class TeaVMTask extends DefaultTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TeaVMProgressListener createProgressListener() {
|
||||||
|
return new TeaVMProgressListener() {
|
||||||
|
private ProgressLogger currentLogger;
|
||||||
|
private TeaVMPhase phase;
|
||||||
|
private int phaseLimit;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TeaVMProgressFeedback phaseStarted(TeaVMPhase phase, int count) {
|
||||||
|
this.phase = phase;
|
||||||
|
this.phaseLimit = count;
|
||||||
|
if (currentLogger != null) {
|
||||||
|
currentLogger.completed();
|
||||||
|
currentLogger = null;
|
||||||
|
}
|
||||||
|
switch (phase) {
|
||||||
|
case DEPENDENCY_ANALYSIS:
|
||||||
|
currentLogger = getProgressLoggerFactory().newOperation(getClass());
|
||||||
|
currentLogger.start("Dependency analysis", getName());
|
||||||
|
break;
|
||||||
|
case COMPILING:
|
||||||
|
currentLogger = getProgressLoggerFactory().newOperation(getClass());
|
||||||
|
currentLogger.start("Compilation", getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TeaVMProgressFeedback.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TeaVMProgressFeedback progressReached(int progress) {
|
||||||
|
switch (phase) {
|
||||||
|
case DEPENDENCY_ANALYSIS:
|
||||||
|
if (phaseLimit == 0) {
|
||||||
|
currentLogger.progress(progress + " classes reached");
|
||||||
|
} else {
|
||||||
|
currentLogger.progress(showPercent(progress) + " %");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case COMPILING:
|
||||||
|
currentLogger.progress(showPercent(progress) + " %");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TeaVMProgressFeedback.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int showPercent(int value) {
|
||||||
|
return Math.min(100, (value * 1000 / phaseLimit + 5) / 10);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static TeaVMOptimizationLevel map(OptimizationLevel level) {
|
private static TeaVMOptimizationLevel map(OptimizationLevel level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case AGGRESSIVE:
|
case AGGRESSIVE:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user