diff options
author | ulfjack <ulfjack@google.com> | 2018-06-13 03:06:16 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-13 03:07:33 -0700 |
commit | c23bdac0838d817e776d66990de1e73bc3a515d8 (patch) | |
tree | 3189bf497c1ef4ff8d6de010ae0335ca154db97a /src/main | |
parent | e2d6ba911a070e10421cb06f635bac0a4d981494 (diff) |
Split AnalysisResult into a top-level class
PiperOrigin-RevId: 200363345
Diffstat (limited to 'src/main')
5 files changed, 159 insertions, 134 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java new file mode 100644 index 0000000000..6239328a60 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java @@ -0,0 +1,156 @@ +// Copyright 2018 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.analysis; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.devtools.build.lib.actions.ActionGraph; +import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.PackageRoots; +import com.google.devtools.build.lib.skyframe.AspectValue; +import java.util.Collection; +import java.util.List; +import javax.annotation.Nullable; + +/** + * Return value for {@link com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner}. + */ +public final class AnalysisResult { + private final ImmutableSet<ConfiguredTarget> targetsToBuild; + @Nullable private final ImmutableList<ConfiguredTarget> targetsToTest; + private final ImmutableSet<ConfiguredTarget> targetsToSkip; + @Nullable private final String error; + private final ActionGraph actionGraph; + private final ImmutableSet<Artifact> artifactsToBuild; + private final ImmutableSet<ConfiguredTarget> parallelTests; + private final ImmutableSet<ConfiguredTarget> exclusiveTests; + @Nullable private final TopLevelArtifactContext topLevelContext; + private final ImmutableSet<AspectValue> aspects; + private final PackageRoots packageRoots; + private final String workspaceName; + private final List<TargetAndConfiguration> topLevelTargetsWithConfigs; + + AnalysisResult( + Collection<ConfiguredTarget> targetsToBuild, + ImmutableSet<AspectValue> aspects, + Collection<ConfiguredTarget> targetsToTest, + Collection<ConfiguredTarget> targetsToSkip, + @Nullable String error, + ActionGraph actionGraph, + Collection<Artifact> artifactsToBuild, + Collection<ConfiguredTarget> parallelTests, + Collection<ConfiguredTarget> exclusiveTests, + TopLevelArtifactContext topLevelContext, + PackageRoots packageRoots, + String workspaceName, + List<TargetAndConfiguration> topLevelTargetsWithConfigs) { + this.targetsToBuild = ImmutableSet.copyOf(targetsToBuild); + this.aspects = aspects; + this.targetsToTest = targetsToTest == null ? null : ImmutableList.copyOf(targetsToTest); + this.targetsToSkip = ImmutableSet.copyOf(targetsToSkip); + this.error = error; + this.actionGraph = actionGraph; + this.artifactsToBuild = ImmutableSet.copyOf(artifactsToBuild); + this.parallelTests = ImmutableSet.copyOf(parallelTests); + this.exclusiveTests = ImmutableSet.copyOf(exclusiveTests); + this.topLevelContext = topLevelContext; + this.packageRoots = packageRoots; + this.workspaceName = workspaceName; + this.topLevelTargetsWithConfigs = topLevelTargetsWithConfigs; + } + + /** + * Returns configured targets to build. + */ + public ImmutableSet<ConfiguredTarget> getTargetsToBuild() { + return targetsToBuild; + } + + /** @see PackageRoots */ + public PackageRoots getPackageRoots() { + return packageRoots; + } + + /** + * Returns aspects of configured targets to build. + * + * <p>If this list is empty, build the targets returned by {@code getTargetsToBuild()}. + * Otherwise, only build these aspects of the targets returned by {@code getTargetsToBuild()}. + */ + public ImmutableSet<AspectValue> getAspects() { + return aspects; + } + + /** + * Returns the configured targets to run as tests, or {@code null} if testing was not + * requested (e.g. "build" command rather than "test" command). + */ + @Nullable + public Collection<ConfiguredTarget> getTargetsToTest() { + return targetsToTest; + } + + /** + * Returns the configured targets that should not be executed because they're not + * platform-compatible with the current build. + * + * <p>For example: tests that aren't intended for the designated CPU. + */ + public ImmutableSet<ConfiguredTarget> getTargetsToSkip() { + return targetsToSkip; + } + + public ImmutableSet<Artifact> getAdditionalArtifactsToBuild() { + return artifactsToBuild; + } + + public ImmutableSet<ConfiguredTarget> getExclusiveTests() { + return exclusiveTests; + } + + public ImmutableSet<ConfiguredTarget> getParallelTests() { + return parallelTests; + } + + /** + * Returns an error description (if any). + */ + @Nullable public String getError() { + return error; + } + + public boolean hasError() { + return error != null; + } + + /** + * Returns the action graph. + */ + public ActionGraph getActionGraph() { + return actionGraph; + } + + public TopLevelArtifactContext getTopLevelContext() { + return topLevelContext; + } + + public String getWorkspaceName() { + return workspaceName; + } + + public List<TargetAndConfiguration> getTopLevelTargetsWithConfigs() { + return topLevelTargetsWithConfigs; + } +} diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java index a78ccea927..002c1fc98f 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java @@ -304,137 +304,6 @@ public class BuildView { throw new UnsupportedOperationException(); // avoid nondeterminism } - /** - * Return value for {@link BuildView#update} and {@code BuildTool.prepareToBuild}. - */ - public static final class AnalysisResult { - private final ImmutableSet<ConfiguredTarget> targetsToBuild; - @Nullable private final ImmutableList<ConfiguredTarget> targetsToTest; - private final ImmutableSet<ConfiguredTarget> targetsToSkip; - @Nullable private final String error; - private final ActionGraph actionGraph; - private final ImmutableSet<Artifact> artifactsToBuild; - private final ImmutableSet<ConfiguredTarget> parallelTests; - private final ImmutableSet<ConfiguredTarget> exclusiveTests; - @Nullable private final TopLevelArtifactContext topLevelContext; - private final ImmutableSet<AspectValue> aspects; - private final PackageRoots packageRoots; - private final String workspaceName; - List<TargetAndConfiguration> topLevelTargetsWithConfigs; - - private AnalysisResult( - Collection<ConfiguredTarget> targetsToBuild, - ImmutableSet<AspectValue> aspects, - Collection<ConfiguredTarget> targetsToTest, - Collection<ConfiguredTarget> targetsToSkip, - @Nullable String error, - ActionGraph actionGraph, - Collection<Artifact> artifactsToBuild, - Collection<ConfiguredTarget> parallelTests, - Collection<ConfiguredTarget> exclusiveTests, - TopLevelArtifactContext topLevelContext, - PackageRoots packageRoots, - String workspaceName, - List<TargetAndConfiguration> topLevelTargetsWithConfigs) { - this.targetsToBuild = ImmutableSet.copyOf(targetsToBuild); - this.aspects = aspects; - this.targetsToTest = targetsToTest == null ? null : ImmutableList.copyOf(targetsToTest); - this.targetsToSkip = ImmutableSet.copyOf(targetsToSkip); - this.error = error; - this.actionGraph = actionGraph; - this.artifactsToBuild = ImmutableSet.copyOf(artifactsToBuild); - this.parallelTests = ImmutableSet.copyOf(parallelTests); - this.exclusiveTests = ImmutableSet.copyOf(exclusiveTests); - this.topLevelContext = topLevelContext; - this.packageRoots = packageRoots; - this.workspaceName = workspaceName; - this.topLevelTargetsWithConfigs = topLevelTargetsWithConfigs; - } - - /** - * Returns configured targets to build. - */ - public ImmutableSet<ConfiguredTarget> getTargetsToBuild() { - return targetsToBuild; - } - - /** @see PackageRoots */ - public PackageRoots getPackageRoots() { - return packageRoots; - } - - /** - * Returns aspects of configured targets to build. - * - * <p>If this list is empty, build the targets returned by {@code getTargetsToBuild()}. - * Otherwise, only build these aspects of the targets returned by {@code getTargetsToBuild()}. - */ - public ImmutableSet<AspectValue> getAspects() { - return aspects; - } - - /** - * Returns the configured targets to run as tests, or {@code null} if testing was not - * requested (e.g. "build" command rather than "test" command). - */ - @Nullable - public Collection<ConfiguredTarget> getTargetsToTest() { - return targetsToTest; - } - - /** - * Returns the configured targets that should not be executed because they're not - * platform-compatible with the current build. - * - * <p>For example: tests that aren't intended for the designated CPU. - */ - public ImmutableSet<ConfiguredTarget> getTargetsToSkip() { - return targetsToSkip; - } - - public ImmutableSet<Artifact> getAdditionalArtifactsToBuild() { - return artifactsToBuild; - } - - public ImmutableSet<ConfiguredTarget> getExclusiveTests() { - return exclusiveTests; - } - - public ImmutableSet<ConfiguredTarget> getParallelTests() { - return parallelTests; - } - - /** - * Returns an error description (if any). - */ - @Nullable public String getError() { - return error; - } - - public boolean hasError() { - return error != null; - } - - /** - * Returns the action graph. - */ - public ActionGraph getActionGraph() { - return actionGraph; - } - - public TopLevelArtifactContext getTopLevelContext() { - return topLevelContext; - } - - public String getWorkspaceName() { - return workspaceName; - } - - public List<TargetAndConfiguration> getTopLevelTargetsWithConfigs() { - return topLevelTargetsWithConfigs; - } - } - /** Returns the collection of configured targets corresponding to any of the provided targets. */ @VisibleForTesting static Iterable<? extends ConfiguredTarget> filterTestsByTargets( 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 55eed1a5cc..32307e0b43 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 @@ -22,9 +22,9 @@ import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.actions.BuildFailedException; import com.google.devtools.build.lib.actions.TestExecException; import com.google.devtools.build.lib.analysis.AnalysisPhaseCompleteEvent; +import com.google.devtools.build.lib.analysis.AnalysisResult; import com.google.devtools.build.lib.analysis.BuildInfoEvent; import com.google.devtools.build.lib.analysis.BuildView; -import com.google.devtools.build.lib.analysis.BuildView.AnalysisResult; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.LicensesProvider; import com.google.devtools.build.lib.analysis.LicensesProvider.TargetLicense; diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java index a149b1aa7f..94cba7ca25 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java @@ -40,7 +40,7 @@ import com.google.devtools.build.lib.actions.ResourceSet; import com.google.devtools.build.lib.actions.TestExecException; import com.google.devtools.build.lib.actions.cache.ActionCache; import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics; -import com.google.devtools.build.lib.analysis.BuildView.AnalysisResult; +import com.google.devtools.build.lib.analysis.AnalysisResult; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.TopLevelArtifactContext; import com.google.devtools.build.lib.analysis.TopLevelArtifactHelper; diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java index df5205eb70..941f53efaa 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java @@ -13,7 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.buildtool; -import com.google.devtools.build.lib.analysis.BuildView.AnalysisResult; +import com.google.devtools.build.lib.analysis.AnalysisResult; import com.google.devtools.build.lib.analysis.TargetAndConfiguration; import com.google.devtools.build.lib.analysis.ViewCreationFailedException; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; |