Skip to content

Commit

Permalink
Migrate writing --explain output to use InstrumentationOutput int…
Browse files Browse the repository at this point in the history
…erface

PiperOrigin-RevId: 686659518
Change-Id: I4a9de1ac4880ef1c5dd01e4b5bcb1538e69029af
  • Loading branch information
yuyue730 authored and copybara-github committed Oct 16, 2024
1 parent 0fdb36f commit 1d022f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
import com.google.devtools.build.lib.runtime.BlazeModule;
import com.google.devtools.build.lib.runtime.BlazeRuntime;
import com.google.devtools.build.lib.runtime.CommandEnvironment;
import com.google.devtools.build.lib.runtime.CommonCommandOptions;
import com.google.devtools.build.lib.runtime.InstrumentationOutput;
import com.google.devtools.build.lib.server.FailureDetails;
import com.google.devtools.build.lib.server.FailureDetails.Execution;
import com.google.devtools.build.lib.server.FailureDetails.Execution.Code;
Expand Down Expand Up @@ -722,7 +724,7 @@ private void createActionLogDirectory() throws AbruptExitException {
private static BuildConfigurationValue getConfiguration(
SkyframeExecutor executor, Reporter reporter, BuildOptions options) {
try {
return executor.getConfiguration(reporter, options, /*keepGoing=*/ false);
return executor.getConfiguration(reporter, options, /* keepGoing= */ false);
} catch (InvalidConfigurationException e) {
reporter.handle(
Event.warn(
Expand Down Expand Up @@ -846,9 +848,21 @@ private ExplanationHandler installExplanationHandler(
}
ExplanationHandler handler;
try {
handler =
new ExplanationHandler(
getWorkspace().getRelative(explanationPath).getOutputStream(), allOptions);
InstrumentationOutput instrumentationOutput =
runtime
.getInstrumentationOutputFactory()
.createInstrumentationOutput(
/* name= */ "explain",
getWorkspace().getRelative(explanationPath),
env.getOptions(),
env.getOptions()
.getOptions(CommonCommandOptions.class)
.redirectLocalInstrumentationOutputWrites,
getReporter(),
/* convenienceName= */ null,
/* append= */ null,
/* internal= */ null);
handler = new ExplanationHandler(instrumentationOutput.createOutputStream(), allOptions);
} catch (IOException e) {
getReporter()
.handle(
Expand Down Expand Up @@ -1087,9 +1101,7 @@ public void setupExecutionProgressReceiver(SomeExecutionStartedEvent event) {
if (progressReceiverStarted.compareAndSet(false, true)) {
// TODO(leba): count test actions
ExecutionProgressReceiver executionProgressReceiver =
new ExecutionProgressReceiver(
/*exclusiveTestsCount=*/ 0,
env.getEventBus());
new ExecutionProgressReceiver(/* exclusiveTestsCount= */ 0, env.getEventBus());
env.getEventBus()
.post(new ExecutionProgressReceiverAvailableEvent(executionProgressReceiver));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,10 @@ public RepositoryRemoteExecutorFactory getRepositoryRemoteExecutorFactory() {
return repositoryRemoteExecutorFactory;
}

public InstrumentationOutputFactory getInstrumentationOutputFactory() {
return instrumentationOutputFactory;
}

/**
* A builder for {@link BlazeRuntime} objects. The only required fields are the {@link
* BlazeDirectories}, and the {@link com.google.devtools.build.lib.packages.RuleClassProvider}
Expand Down

0 comments on commit 1d022f4

Please sign in to comment.