diff options
author | 2017-10-19 22:14:16 +0200 | |
---|---|---|
committer | 2017-10-20 14:04:05 +0200 | |
commit | f78843615d9c2fd9b01627b83f4ee56972935c81 (patch) | |
tree | 1c3e7f220b0cc98869897888923bab10f7cb880a /src | |
parent | 39fab1020379d8e4554e5ddf1f269f11a37b6953 (diff) |
BEP: correctly report the cause of unbuilt targets if --noanalyze is given
If bazel is asked to only load target, but not perform an analysis
phase, correctly report this as the cause why the obtained targets wer
never configured.
Change-Id: Ib630a6dc1b955b810a6cc40254c0ae746e2eca1e
PiperOrigin-RevId: 172787777
Diffstat (limited to 'src')
5 files changed, 37 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto index 8a04efcc98..7b7390895e 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto @@ -219,6 +219,9 @@ message Aborted { // The user requested the build to be aborted (e.g., by hitting Ctl-C). USER_INTERRUPTED = 1; + // The user requested that no analysis be performed. + NO_ANALYZE = 8; + // The build or target was aborted as a timeout was exceeded. TIME_OUT = 2; diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java index c8a3acb395..5fe0095a1f 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java @@ -42,6 +42,7 @@ import com.google.devtools.build.lib.buildtool.BuildRequest.BuildRequestOptions; import com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent; import com.google.devtools.build.lib.buildtool.buildevent.BuildInterruptedEvent; import com.google.devtools.build.lib.buildtool.buildevent.BuildStartingEvent; +import com.google.devtools.build.lib.buildtool.buildevent.NoAnalyzeEvent; import com.google.devtools.build.lib.buildtool.buildevent.TestFilteringCompleteEvent; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.TargetParsingException; @@ -260,6 +261,7 @@ public final class BuildTool { } } else { getReporter().handle(Event.progress("Loading complete.")); + getReporter().post(new NoAnalyzeEvent()); logger.info("No analysis requested, so finished"); String errorMessage = BuildView.createErrorMessage(loadingResult, null); if (errorMessage != null) { diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/NoAnalyzeEvent.java b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/NoAnalyzeEvent.java new file mode 100644 index 0000000000..ecd9c9c8c6 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/buildtool/buildevent/NoAnalyzeEvent.java @@ -0,0 +1,20 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.buildtool.buildevent; + +import com.google.devtools.build.lib.events.ExtendedEventHandler; + +/** Event sent at the end of the loading phase, if no analysis of the target is requested. */ +public class NoAnalyzeEvent implements ExtendedEventHandler.Postable {} diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java index b393af0cb8..24569b251e 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java @@ -51,6 +51,7 @@ import com.google.devtools.build.lib.buildtool.BuildRequest; import com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent; import com.google.devtools.build.lib.buildtool.buildevent.BuildInterruptedEvent; import com.google.devtools.build.lib.buildtool.buildevent.BuildStartingEvent; +import com.google.devtools.build.lib.buildtool.buildevent.NoAnalyzeEvent; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetView; import com.google.devtools.build.lib.events.Event; @@ -394,6 +395,11 @@ public class BuildEventStreamer implements EventHandler { } @Subscribe + public void noAnalyze(NoAnalyzeEvent event) { + abortReason = AbortReason.NO_ANALYZE; + } + + @Subscribe public void buildEvent(BuildEvent event) { if (isActionWithoutError(event) || bufferUntilPrerequisitesReceived(event) diff --git a/src/test/shell/integration/build_event_stream_test.sh b/src/test/shell/integration/build_event_stream_test.sh index a647390b55..069b4845f9 100755 --- a/src/test/shell/integration/build_event_stream_test.sh +++ b/src/test/shell/integration/build_event_stream_test.sh @@ -766,5 +766,11 @@ function test_tool_command_line() { expect_log_once 'chunk: "foo bar"' } +function test_noanalyze() { + bazel build --noanalyze --build_event_text_file="${TEST_log}" pkg:true \ + || fail "build failed" + expect_log_once '^aborted' + expect_log 'reason: NO_ANALYZE' +} run_suite "Integration tests for the build event stream" |