Skip to content

Commit

Permalink
Show fetch progress for the mod command
Browse files Browse the repository at this point in the history
By sending out the proper events to let the UiEventHandler know that we want progress displayed.

Fixes bazelbuild#19252

PiperOrigin-RevId: 565701083
Change-Id: If4853cc70c0fad2e0b0bebd2378dddab05e37ce1
  • Loading branch information
Wyverald authored and copybara-github committed Sep 15, 2023
1 parent 5abdcf7 commit 820ed9b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.analysis.NoBuildEvent;
import com.google.devtools.build.lib.analysis.NoBuildRequestFinishedEvent;
import com.google.devtools.build.lib.bazel.bzlmod.BazelDepGraphValue;
import com.google.devtools.build.lib.bazel.bzlmod.BazelModuleInspectorValue;
import com.google.devtools.build.lib.bazel.bzlmod.BazelModuleInspectorValue.AugmentedModule;
Expand Down Expand Up @@ -106,6 +108,23 @@ public void editOptions(OptionsParser optionsParser) {

@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) {
env.getEventBus()
.post(
new NoBuildEvent(
env.getCommandName(),
env.getCommandStartTime(),
/* separateFinishedEvent= */ true,
/* showProgress= */ true,
/* id= */ null));
BlazeCommandResult result = execInternal(env, options);
env.getEventBus()
.post(
new NoBuildRequestFinishedEvent(
result.getExitCode(), env.getRuntime().getClock().currentTimeMillis()));
return result;
}

private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingResult options) {
BazelDepGraphValue depGraphValue;
BazelModuleInspectorValue moduleInspector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ private void completeBuild() {
return;
}
buildRunning = false;
// Have to set this, otherwise there's a lingering "checking cached actions" message for the
// `mod` command, which doesn't even run any actions.
stateTracker.setBuildComplete();
}
stopUpdateThread();
synchronized (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,7 @@ synchronized void progressReceiverAvailable(ExecutionProgressReceiverAvailableEv
}

Event buildComplete(BuildCompleteEvent event) {
buildComplete = true;
buildCompleteAt = Instant.ofEpochMilli(clock.currentTimeMillis());
setBuildComplete();

status = null;
additionalMessage = "";
Expand Down Expand Up @@ -492,6 +491,11 @@ protected boolean buildCompleted() {
return buildComplete;
}

public void setBuildComplete() {
buildComplete = true;
buildCompleteAt = Instant.ofEpochMilli(clock.currentTimeMillis());
}

synchronized void downloadProgress(FetchProgress event) {
String url = event.getResourceIdentifier();
if (event.isFinished()) {
Expand Down

0 comments on commit 820ed9b

Please sign in to comment.