aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2017-11-10 17:41:04 +0100
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-11-10 23:28:05 +0100
commit970dea8b62557c664f741be1718242218fc79d3c (patch)
tree0c70d956fbfcb55cc2a6c7481ec9f05f4fab2538 /src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
parent0dd5a680f2d6d209a1b814071a3131d3a469995d (diff)
Fix a bug in which --experimental_post_build_query crashes if asked to run on a graph without edges. Now we fail gracefully.
PiperOrigin-RevId: 175294923
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java24
1 files changed, 19 insertions, 5 deletions
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 ef26627558..72908523f0 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
@@ -124,19 +124,20 @@ public final class BuildTool {
*
* <p>The caller is responsible for setting up and syncing the package cache.
*
- * <p>During this function's execution, the actualTargets and successfulTargets
- * fields of the request object are set.
+ * <p>During this function's execution, the actualTargets and successfulTargets fields of the
+ * request object are set.
*
* @param request the build request that this build tool is servicing, which specifies various
- * options; during this method's execution, the actualTargets and successfulTargets fields
- * of the request object are populated
+ * options; during this method's execution, the actualTargets and successfulTargets fields of
+ * the request object are populated
* @param result the build result that is the mutable result of this build
* @param validator target validator
*/
public void buildTargets(BuildRequest request, BuildResult result, TargetValidator validator)
throws BuildFailedException, InterruptedException, ViewCreationFailedException,
TargetParsingException, LoadingFailedException, AbruptExitException,
- InvalidConfigurationException, TestExecException {
+ InvalidConfigurationException, TestExecException,
+ ConfiguredTargetQueryCommandLineException {
validateOptions(request);
BuildOptions buildOptions = runtime.createBuildOptions(request);
// Sync the package manager before sending the BuildStartingEvent in runLoadingPhase()
@@ -237,6 +238,10 @@ public final class BuildTool {
// graph beforehand if this option is specified, or add another option to wipe if desired
// (SkyframeExecutor#handleConfiguredTargetChange should be sufficient).
if (request.getBuildOptions().queryExpression != null) {
+ if (!env.getSkyframeExecutor().hasIncrementalState()) {
+ throw new ConfiguredTargetQueryCommandLineException(
+ "Configured query is not allowed if incrementality state is not being kept");
+ }
try {
doConfiguredTargetQuery(request, configurations, loadingResult);
} catch (QueryException | IOException e) {
@@ -373,6 +378,9 @@ public final class BuildTool {
} catch (TargetParsingException | LoadingFailedException | ViewCreationFailedException e) {
exitCode = ExitCode.PARSING_FAILURE;
reportExceptionError(e);
+ } catch (ConfiguredTargetQueryCommandLineException e) {
+ exitCode = ExitCode.COMMAND_LINE_ERROR;
+ reportExceptionError(e);
} catch (TestExecException e) {
// ExitCode.SUCCESS means that build was successful. Real return code of program
// is going to be calculated in TestCommand.doTest().
@@ -684,4 +692,10 @@ public final class BuildTool {
private Reporter getReporter() {
return env.getReporter();
}
+
+ private static class ConfiguredTargetQueryCommandLineException extends Exception {
+ ConfiguredTargetQueryCommandLineException(String message) {
+ super(message);
+ }
+ }
}