From 3c0adb26bac6d756fb97e4bcc6d4e5b2cefa5eeb Mon Sep 17 00:00:00 2001 From: Janak Ramakrishnan Date: Mon, 15 Aug 2016 21:54:55 +0000 Subject: Allow Skyframe graph lookups and value retrievals to throw InterruptedException. The only place we now don't handle InterruptedException is in the action graph created after analysis, since I'm not sure that will be around for that much longer. -- MOS_MIGRATED_REVID=130327770 --- .../devtools/build/lib/actions/AbstractAction.java | 10 +- .../google/devtools/build/lib/actions/Action.java | 20 +- .../build/lib/actions/ActionCacheChecker.java | 4 +- .../build/lib/actions/ArtifactFactory.java | 4 +- .../build/lib/actions/ArtifactResolver.java | 13 +- .../build/lib/actions/PackageRootResolver.java | 31 +- .../build/lib/analysis/AnalysisEnvironment.java | 11 +- .../devtools/build/lib/analysis/BuildView.java | 34 +- .../lib/analysis/CachingAnalysisEnvironment.java | 13 +- .../analysis/ConfigurationCollectionFactory.java | 11 +- .../build/lib/analysis/DependencyResolver.java | 84 +++-- .../build/lib/analysis/RedirectChaser.java | 2 +- .../devtools/build/lib/analysis/RuleContext.java | 2 +- .../analysis/config/ConfigurationEnvironment.java | 15 +- .../lib/analysis/config/ConfigurationFactory.java | 20 +- .../config/ConfigurationFragmentFactory.java | 3 +- .../config/PackageProviderForConfigurations.java | 29 +- .../bazel/repository/GitRepositoryFunction.java | 7 +- .../lib/bazel/repository/MavenJarFunction.java | 21 +- .../lib/bazel/repository/MavenServerFunction.java | 16 +- .../bazel/repository/NewGitRepositoryFunction.java | 3 +- .../skylark/SkylarkRepositoryContext.java | 52 ++- .../bazel/rules/BazelConfigurationCollection.java | 34 +- .../android/AndroidNdkRepositoryFunction.java | 6 +- .../android/AndroidSdkRepositoryFunction.java | 5 +- .../build/lib/bazel/rules/genrule/GenRule.java | 4 +- .../build/lib/cmdline/TargetPatternResolver.java | 2 +- .../build/lib/concurrent/AbstractQueueVisitor.java | 56 +-- .../lib/concurrent/ForkJoinQuiescingExecutor.java | 6 +- .../lib/packages/AbstractAttributeMapper.java | 9 +- .../lib/packages/AggregatingAttributeMapper.java | 86 +++-- .../devtools/build/lib/packages/AttributeMap.java | 15 +- .../lib/packages/DelegatingAttributeMapper.java | 3 +- .../build/lib/packages/ExternalPackageBuilder.java | 6 +- .../devtools/build/lib/packages/Globber.java | 5 +- .../devtools/build/lib/packages/Package.java | 37 +- .../google/devtools/build/lib/packages/Rule.java | 37 +- .../devtools/build/lib/packages/TargetUtils.java | 12 +- .../build/lib/pkgcache/PackageProvider.java | 12 +- .../lib/pkgcache/RecursivePackageProvider.java | 17 +- .../build/lib/pkgcache/TargetEdgeObserver.java | 11 +- .../lib/pkgcache/TargetPatternResolverUtil.java | 6 +- .../lib/query2/AbstractBlazeQueryEnvironment.java | 6 +- .../build/lib/query2/BlazeQueryEnvironment.java | 4 +- .../build/lib/query2/BlazeTargetAccessor.java | 16 +- .../ErrorPrintingTargetEdgeErrorObserver.java | 3 +- .../devtools/build/lib/query2/LabelVisitor.java | 35 +- .../build/lib/query2/SkyQueryEnvironment.java | 51 +-- .../build/lib/query2/TargetEdgeErrorObserver.java | 7 +- .../build/lib/query2/engine/QueryEnvironment.java | 34 +- .../build/lib/query2/engine/TestsFunction.java | 19 +- .../build/lib/query2/engine/VisibleFunction.java | 16 +- .../build/lib/rules/SkylarkRuleContext.java | 26 +- .../build/lib/rules/android/AndroidBinary.java | 13 +- .../lib/rules/android/AndroidConfiguration.java | 3 +- .../build/lib/rules/android/NativeLibs.java | 3 +- .../build/lib/rules/apple/AppleConfiguration.java | 17 +- .../build/lib/rules/apple/XcodeConfig.java | 68 ++-- .../devtools/build/lib/rules/cpp/CcBinary.java | 3 +- .../devtools/build/lib/rules/cpp/CcIncLibrary.java | 5 +- .../devtools/build/lib/rules/cpp/CcLibrary.java | 5 +- .../build/lib/rules/cpp/CcLibraryHelper.java | 2 +- .../devtools/build/lib/rules/cpp/CcToolchain.java | 3 +- .../build/lib/rules/cpp/CppCompileAction.java | 6 +- .../lib/rules/cpp/CppConfigurationLoader.java | 6 +- .../build/lib/rules/cpp/CppLinkActionBuilder.java | 4 +- .../devtools/build/lib/rules/cpp/CppModel.java | 5 +- .../rules/cpp/CrosstoolConfigurationLoader.java | 23 +- .../build/lib/rules/cpp/ExtraLinkTimeLibrary.java | 6 +- .../devtools/build/lib/rules/cpp/FdoSupport.java | 14 +- .../build/lib/rules/extra/ExtraAction.java | 10 +- .../build/lib/rules/genquery/GenQuery.java | 17 +- .../build/lib/rules/java/DeployArchiveBuilder.java | 8 +- .../devtools/build/lib/rules/java/JavaCommon.java | 11 +- .../lib/rules/java/JavaConfigurationLoader.java | 2 +- .../build/lib/rules/java/JavaSemantics.java | 10 +- .../lib/rules/java/JvmConfigurationLoader.java | 8 +- .../lib/rules/nativedeps/NativeDepsHelper.java | 16 +- .../lib/rules/objc/ObjcConfigurationLoader.java | 2 +- .../lib/rules/objc/ReleaseBundlingSupport.java | 2 +- .../rules/python/PythonConfigurationLoader.java | 5 +- .../build/lib/rules/python/PythonSemantics.java | 7 +- .../rules/repository/LocalRepositoryFunction.java | 4 +- .../repository/NewLocalRepositoryFunction.java | 3 +- .../repository/NewRepositoryBuildFileHandler.java | 7 +- .../lib/rules/repository/RepositoryFunction.java | 64 ++-- .../build/lib/runtime/commands/InfoCommand.java | 3 +- .../build/lib/runtime/commands/InfoItem.java | 8 +- .../lib/skyframe/ActionExecutionFunction.java | 27 +- .../skyframe/ActionTemplateExpansionFunction.java | 2 +- .../build/lib/skyframe/ArtifactFunction.java | 16 +- .../build/lib/skyframe/AspectFunction.java | 14 +- .../lib/skyframe/BuildConfigurationFunction.java | 6 +- .../lib/skyframe/BuildInfoCollectionFunction.java | 3 +- .../CollectPackagesUnderDirectoryFunction.java | 4 +- .../build/lib/skyframe/CompletionFunction.java | 21 +- .../skyframe/ConfigurationCollectionFunction.java | 23 +- .../skyframe/ConfigurationFragmentFunction.java | 24 +- .../lib/skyframe/ConfiguredTargetFunction.java | 50 +-- .../skyframe/ContainingPackageLookupFunction.java | 3 +- .../build/lib/skyframe/CoverageReportFunction.java | 2 +- .../lib/skyframe/DirectoryListingFunction.java | 3 +- .../skyframe/DirectoryListingStateFunction.java | 3 +- .../EnvironmentBackedRecursivePackageProvider.java | 15 +- .../build/lib/skyframe/ExternalFilesHelper.java | 17 +- .../lib/skyframe/ExternalPackageFunction.java | 3 +- .../devtools/build/lib/skyframe/FileFunction.java | 24 +- .../build/lib/skyframe/FileStateFunction.java | 4 +- .../build/lib/skyframe/FilesetEntryFunction.java | 8 +- .../build/lib/skyframe/FilesystemValueChecker.java | 8 +- .../devtools/build/lib/skyframe/GlobFunction.java | 5 +- .../GraphBackedRecursivePackageProvider.java | 22 +- .../build/lib/skyframe/PackageErrorFunction.java | 4 +- .../build/lib/skyframe/PackageFunction.java | 32 +- .../build/lib/skyframe/PackageLookupFunction.java | 21 +- .../lib/skyframe/PostConfiguredTargetFunction.java | 6 +- .../build/lib/skyframe/PrecomputedValue.java | 6 +- .../lib/skyframe/PrepareDepsOfPatternFunction.java | 15 +- ...PrepareDepsOfTargetsUnderDirectoryFunction.java | 8 +- .../RecursiveDirectoryTraversalFunction.java | 20 +- .../RecursiveFilesystemTraversalFunction.java | 21 +- ...PackageProviderBackedTargetPatternResolver.java | 3 +- .../build/lib/skyframe/RecursivePkgFunction.java | 4 +- .../build/lib/skyframe/SkyframeActionExecutor.java | 4 +- .../build/lib/skyframe/SkyframeAwareAction.java | 12 +- .../build/lib/skyframe/SkyframeBuildView.java | 15 +- .../lib/skyframe/SkyframeDependencyResolver.java | 11 +- .../SkyframePackageLoaderWithValueEnvironment.java | 13 +- .../lib/skyframe/SkylarkImportLookupFunction.java | 24 +- .../build/lib/skyframe/TargetMarkerFunction.java | 6 +- .../lib/skyframe/TargetPatternPhaseFunction.java | 12 +- .../build/lib/skyframe/TargetPatternValue.java | 14 +- .../lib/skyframe/TargetPatternsResultBuilder.java | 14 +- .../build/lib/skyframe/TestCompletionFunction.java | 6 +- .../lib/skyframe/TestSuiteExpansionFunction.java | 6 +- .../build/lib/skyframe/TestsInSuiteFunction.java | 19 +- .../skyframe/TransitiveBaseTraversalFunction.java | 32 +- .../lib/skyframe/TransitiveTargetFunction.java | 22 +- .../lib/skyframe/TransitiveTraversalFunction.java | 4 +- .../lib/skyframe/WorkspaceStatusFunction.java | 2 +- .../skyframe/AbstractSkyFunctionEnvironment.java | 91 +++-- .../devtools/build/skyframe/BuildDriver.java | 7 +- .../build/skyframe/DelegatingNodeEntry.java | 18 +- .../build/skyframe/DelegatingWalkableGraph.java | 62 ++-- .../build/skyframe/DirtyBuildingState.java | 5 +- .../devtools/build/skyframe/EagerInvalidator.java | 10 +- .../devtools/build/skyframe/EvaluableGraph.java | 13 +- .../devtools/build/skyframe/InMemoryGraph.java | 15 +- .../devtools/build/skyframe/InMemoryGraphImpl.java | 29 +- .../build/skyframe/InMemoryMemoizingEvaluator.java | 70 ++-- .../devtools/build/skyframe/InMemoryNodeEntry.java | 17 +- .../build/skyframe/InterruptibleSupplier.java | 63 ++++ .../build/skyframe/InvalidatingNodeVisitor.java | 63 ++-- .../build/skyframe/MemoizingEvaluator.java | 4 +- .../google/devtools/build/skyframe/NodeEntry.java | 34 +- .../devtools/build/skyframe/ParallelEvaluator.java | 276 ++++++++------ .../devtools/build/skyframe/QueryableGraph.java | 16 +- ...QueryableGraphBackedSkyFunctionEnvironment.java | 66 ++-- .../build/skyframe/SequentialBuildDriver.java | 3 +- .../devtools/build/skyframe/SkyFunction.java | 194 ++++++---- .../devtools/build/skyframe/ThinNodeEntry.java | 23 +- .../devtools/build/skyframe/WalkableGraph.java | 25 +- .../analysis/config/BuildConfigurationTest.java | 6 +- .../build/lib/analysis/util/ActionTester.java | 9 +- .../build/lib/analysis/util/AnalysisTestUtil.java | 10 +- .../lib/concurrent/AbstractQueueVisitorTest.java | 74 +--- .../build/lib/packages/WorkspaceFactoryTest.java | 8 +- .../build/lib/rules/cpp/CppLinkActionTest.java | 15 +- .../PrepareDepsOfPatternsFunctionTest.java | 19 +- .../lib/skyframe/SkyframeAwareActionTest.java | 3 +- .../lib/skyframe/SkyframeLabelVisitorTestCase.java | 8 +- .../lib/skyframe/WorkspaceASTFunctionTest.java | 8 +- .../lib/skyframe/WorkspaceFileFunctionTest.java | 6 +- .../skyframe/util/SkyframeExecutorTestUtils.java | 13 +- .../build/skyframe/DeterministicHelper.java | 23 +- .../build/skyframe/DeterministicInMemoryGraph.java | 34 +- .../build/skyframe/EvaluationResultSubject.java | 4 +- .../build/skyframe/GraphConcurrencyTest.java | 98 +++-- .../build/skyframe/InMemoryNodeEntryTest.java | 68 ++-- .../build/skyframe/MemoizingEvaluatorTest.java | 204 +++++----- .../devtools/build/skyframe/NotifyingHelper.java | 24 +- .../build/skyframe/NotifyingInMemoryGraph.java | 33 +- .../build/skyframe/ParallelEvaluatorTest.java | 413 +++++++++++---------- .../build/skyframe/WalkableGraphUtils.java | 6 +- .../build/workspace/GenerateWorkspace.java | 5 +- .../build/workspace/WorkspaceResolver.java | 12 +- 186 files changed, 2322 insertions(+), 1912 deletions(-) create mode 100644 src/main/java/com/google/devtools/build/skyframe/InterruptibleSupplier.java diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java index 00f918a17a..8bd3f4428a 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java +++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java @@ -32,10 +32,8 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.Symlinks; - import java.io.IOException; import java.util.Collection; - import javax.annotation.Nullable; /** @@ -154,9 +152,11 @@ public abstract class AbstractAction implements Action, SkylarkValue { @Nullable @Override - public Iterable resolveInputsFromCache(ArtifactResolver artifactResolver, - PackageRootResolver resolver, Collection inputPaths) - throws PackageRootResolutionException { + public Iterable resolveInputsFromCache( + ArtifactResolver artifactResolver, + PackageRootResolver resolver, + Collection inputPaths) + throws PackageRootResolutionException, InterruptedException { throw new IllegalStateException( "Method must be overridden for actions that may have unknown inputs."); } diff --git a/src/main/java/com/google/devtools/build/lib/actions/Action.java b/src/main/java/com/google/devtools/build/lib/actions/Action.java index 01cf55472f..d7623de017 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/Action.java +++ b/src/main/java/com/google/devtools/build/lib/actions/Action.java @@ -19,10 +19,8 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ConditionallyThread import com.google.devtools.build.lib.profiler.Describable; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; - import java.io.IOException; import java.util.Collection; - import javax.annotation.Nullable; /** @@ -154,25 +152,25 @@ public interface Action extends ActionExecutionMetadata, Describable { throws ActionExecutionException, InterruptedException; /** - * Method used to resolve action inputs based on the information contained in - * the action cache. It will be called iff inputsKnown() is false for the - * given action instance and there is a related cache entry in the action - * cache. + * Method used to resolve action inputs based on the information contained in the action cache. It + * will be called iff inputsKnown() is false for the given action instance and there is a related + * cache entry in the action cache. * - * Method must be redefined for any action that may return - * inputsKnown() == false. + *

Method must be redefined for any action that may return inputsKnown() == false. * * @param artifactResolver the artifact factory that can be used to manufacture artifacts * @param resolver object which helps to resolve some of the artifacts * @param inputPaths List of relative (to the execution root) input paths * @return List of Artifacts corresponding to inputPaths, or null if some dependencies were - * missing and we need to try again later. + * missing and we need to try again later. * @throws PackageRootResolutionException on failure to determine package roots of inputPaths */ @Nullable Iterable resolveInputsFromCache( - ArtifactResolver artifactResolver, PackageRootResolver resolver, - Collection inputPaths) throws PackageRootResolutionException; + ArtifactResolver artifactResolver, + PackageRootResolver resolver, + Collection inputPaths) + throws PackageRootResolutionException, InterruptedException; /** * Informs the action that its inputs are {@code inputs}, and that its inputs are now known. Can diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java index 86cbd0a07f..b96a9e4111 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java @@ -27,13 +27,11 @@ import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.events.EventKind; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.PathFragment; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.annotation.Nullable; /** @@ -242,7 +240,7 @@ public class ActionCacheChecker { @Nullable public Iterable getCachedInputs(Action action, PackageRootResolver resolver) - throws PackageRootResolutionException { + throws PackageRootResolutionException, InterruptedException { ActionCache.Entry entry = getCacheEntry(action); if (entry == null || entry.isCorrupted()) { return ImmutableList.of(); diff --git a/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java b/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java index 1606c0e783..941ea1554c 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ArtifactFactory.java @@ -26,13 +26,11 @@ import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Objects; - import javax.annotation.Nullable; /** @@ -369,7 +367,7 @@ public class ArtifactFactory implements ArtifactResolver, ArtifactSerializer, Ar @Override public synchronized Map resolveSourceArtifacts( Iterable execPaths, PackageRootResolver resolver) - throws PackageRootResolutionException { + throws PackageRootResolutionException, InterruptedException { Map result = new HashMap<>(); ArrayList unresolvedPaths = new ArrayList<>(); diff --git a/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java b/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java index e7ea2f2c5f..58b36c9371 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ArtifactResolver.java @@ -15,9 +15,7 @@ package com.google.devtools.build.lib.actions; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.Map; - import javax.annotation.Nullable; /** @@ -69,12 +67,13 @@ public interface ArtifactResolver { * @param execPaths list of exec paths of the artifacts to resolve * @param resolver object that helps to resolve package root of given paths * @return map which contains list of execPaths and corresponding Artifacts. Map can contain - * existing or new source Artifacts for the given execPaths. The artifact is null if the - * root cannot be determined and the artifact did not exist before. Return null if any - * dependencies are missing. + * existing or new source Artifacts for the given execPaths. The artifact is null if the root + * cannot be determined and the artifact did not exist before. Return null if any dependencies + * are missing. * @throws PackageRootResolutionException failure to determine package roots of {@code execPaths} */ @Nullable - Map resolveSourceArtifacts(Iterable execPaths, - PackageRootResolver resolver) throws PackageRootResolutionException; + Map resolveSourceArtifacts( + Iterable execPaths, PackageRootResolver resolver) + throws PackageRootResolutionException, InterruptedException; } diff --git a/src/main/java/com/google/devtools/build/lib/actions/PackageRootResolver.java b/src/main/java/com/google/devtools/build/lib/actions/PackageRootResolver.java index 0db0075ddc..2b7a3ca4d5 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/PackageRootResolver.java +++ b/src/main/java/com/google/devtools/build/lib/actions/PackageRootResolver.java @@ -15,9 +15,7 @@ package com.google.devtools.build.lib.actions; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.Map; - import javax.annotation.Nullable; /** @@ -26,34 +24,33 @@ import javax.annotation.Nullable; public interface PackageRootResolver { /** - * Returns mapping from execPath to Root. Root will be null if the path has no containing - * package. + * Returns mapping from execPath to Root. Root will be null if the path has no containing package. * * @param execPaths the paths to find {@link Root}s for. The search for a containing package will - * start with the path's parent directory, since the path is assumed to be a file. - * @return mappings from {@code execPath} to {@link Root}, or null if for some reason we - * cannot determine the result at this time (such as when used within a SkyFunction) + * start with the path's parent directory, since the path is assumed to be a file. + * @return mappings from {@code execPath} to {@link Root}, or null if for some reason we cannot + * determine the result at this time (such as when used within a SkyFunction) * @throws PackageRootResolutionException if unable to determine package roots or lack thereof, - * typically caused by exceptions encountered while attempting to locate BUILD files + * typically caused by exceptions encountered while attempting to locate BUILD files */ @Nullable Map findPackageRootsForFiles(Iterable execPaths) - throws PackageRootResolutionException; + throws PackageRootResolutionException, InterruptedException; /** - * Returns mapping from execPath to Root. Root will be null if the path has no containing - * package. Unlike {@link #findPackageRootsForFiles(Iterable)}, this function allows directories - * in the list of exec paths. + * Returns mapping from execPath to Root. Root will be null if the path has no containing package. + * Unlike {@link #findPackageRootsForFiles(Iterable)}, this function allows directories in the + * list of exec paths. * * @param execPaths the paths to find {@link Root}s for. The search for a containing package will - * start with the path's parent directory, since the path is assumed to be a file. - * @return mappings from {@code execPath} to {@link Root}, or null if for some reason we - * cannot determine the result at this time (such as when used within a SkyFunction) + * start with the path's parent directory, since the path is assumed to be a file. + * @return mappings from {@code execPath} to {@link Root}, or null if for some reason we cannot + * determine the result at this time (such as when used within a SkyFunction) * @throws PackageRootResolutionException if unable to determine package roots or lack thereof, - * typically caused by exceptions encountered while attempting to locate BUILD files + * typically caused by exceptions encountered while attempting to locate BUILD files */ // TODO(bazel-team): Remove this once we don't need to find package roots for directories. @Nullable Map findPackageRoots(Iterable execPaths) - throws PackageRootResolutionException; + throws PackageRootResolutionException, InterruptedException; } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisEnvironment.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisEnvironment.java index fcdc3ec4c6..9f9a655069 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisEnvironment.java @@ -127,13 +127,13 @@ public interface AnalysisEnvironment extends ActionRegistry { * Returns the Artifact that is used to hold the non-volatile workspace status for the current * build request. */ - Artifact getStableWorkspaceStatusArtifact(); + Artifact getStableWorkspaceStatusArtifact() throws InterruptedException; /** - * Returns the Artifact that is used to hold the volatile workspace status (e.g. build - * changelist) for the current build request. + * Returns the Artifact that is used to hold the volatile workspace status (e.g. build changelist) + * for the current build request. */ - Artifact getVolatileWorkspaceStatusArtifact(); + Artifact getVolatileWorkspaceStatusArtifact() throws InterruptedException; /** * Returns the Artifacts that contain the workspace status for the current build request. @@ -142,7 +142,8 @@ public interface AnalysisEnvironment extends ActionRegistry { * @param config the current build configuration. */ ImmutableList getBuildInfo( - RuleContext ruleContext, BuildInfoKey key, BuildConfiguration config); + RuleContext ruleContext, BuildInfoKey key, BuildConfiguration config) + throws InterruptedException; /** * Returns the set of orphan Artifacts (i.e. Artifacts without generating action). Should only be 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 5fed4a32fa..8b5eb241b8 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 @@ -81,7 +81,6 @@ import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.WalkableGraph; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionsBase; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -568,19 +567,26 @@ public class BuildView { String error = createErrorMessage(loadingResult, skyframeAnalysisResult); final WalkableGraph graph = skyframeAnalysisResult.getWalkableGraph(); - final ActionGraph actionGraph = new ActionGraph() { - @Nullable - @Override - public ActionAnalysisMetadata getGeneratingAction(Artifact artifact) { - ArtifactOwner artifactOwner = artifact.getArtifactOwner(); - if (artifactOwner instanceof ActionLookupValue.ActionLookupKey) { - SkyKey key = ActionLookupValue.key((ActionLookupValue.ActionLookupKey) artifactOwner); - ActionLookupValue val = (ActionLookupValue) graph.getValue(key); - return val == null ? null : val.getGeneratingAction(artifact); - } - return null; - } - }; + final ActionGraph actionGraph = + new ActionGraph() { + @Nullable + @Override + public ActionAnalysisMetadata getGeneratingAction(Artifact artifact) { + ArtifactOwner artifactOwner = artifact.getArtifactOwner(); + if (artifactOwner instanceof ActionLookupValue.ActionLookupKey) { + SkyKey key = ActionLookupValue.key((ActionLookupValue.ActionLookupKey) artifactOwner); + ActionLookupValue val; + try { + val = (ActionLookupValue) graph.getValue(key); + } catch (InterruptedException e) { + throw new IllegalStateException( + "Interruption not expected from this graph: " + key, e); + } + return val == null ? null : val.getGeneratingAction(artifact); + } + return null; + } + }; return new AnalysisResult( configuredTargets, aspects, diff --git a/src/main/java/com/google/devtools/build/lib/analysis/CachingAnalysisEnvironment.java b/src/main/java/com/google/devtools/build/lib/analysis/CachingAnalysisEnvironment.java index 5fd3d43822..5aed23d0f9 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/CachingAnalysisEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/CachingAnalysisEnvironment.java @@ -37,7 +37,6 @@ import com.google.devtools.build.lib.skyframe.WorkspaceStatusValue; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.SkyFunction; - import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; @@ -49,7 +48,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; - import javax.annotation.Nullable; /** @@ -287,21 +285,21 @@ public class CachingAnalysisEnvironment implements AnalysisEnvironment { } @Override - public Artifact getStableWorkspaceStatusArtifact() { + public Artifact getStableWorkspaceStatusArtifact() throws InterruptedException { return ((WorkspaceStatusValue) skyframeEnv.getValue(WorkspaceStatusValue.SKY_KEY)) .getStableArtifact(); } @Override - public Artifact getVolatileWorkspaceStatusArtifact() { + public Artifact getVolatileWorkspaceStatusArtifact() throws InterruptedException { return ((WorkspaceStatusValue) skyframeEnv.getValue(WorkspaceStatusValue.SKY_KEY)) .getVolatileArtifact(); } // See SkyframeBuildView#getWorkspaceStatusValues for the code that this method is attempting to // verify. - private NullPointerException collectDebugInfoAndCrash( - BuildInfoKey key, BuildConfiguration config) { + private NullPointerException collectDebugInfoAndCrash(BuildInfoKey key, BuildConfiguration config) + throws InterruptedException { String debugInfo = key + " " + config; Preconditions.checkState(skyframeEnv.valuesMissing(), debugInfo); Map buildInfoFactories = Preconditions.checkNotNull( @@ -314,7 +312,8 @@ public class CachingAnalysisEnvironment implements AnalysisEnvironment { @Override public ImmutableList getBuildInfo( - RuleContext ruleContext, BuildInfoKey key, BuildConfiguration config) { + RuleContext ruleContext, BuildInfoKey key, BuildConfiguration config) + throws InterruptedException { boolean stamp = AnalysisUtils.isStampingEnabled(ruleContext, config); BuildInfoCollectionValue collectionValue = (BuildInfoCollectionValue) skyframeEnv.getValue(BuildInfoCollectionValue.key( diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfigurationCollectionFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfigurationCollectionFactory.java index 77c51d9e44..75ac3a0d53 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ConfigurationCollectionFactory.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfigurationCollectionFactory.java @@ -21,7 +21,6 @@ import com.google.devtools.build.lib.analysis.config.ConfigurationFactory; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; import com.google.devtools.build.lib.analysis.config.PackageProviderForConfigurations; import com.google.devtools.build.lib.events.EventHandler; - import javax.annotation.Nullable; /** @@ -31,9 +30,10 @@ public interface ConfigurationCollectionFactory { /** * Creates the top-level configuration for a build. * - *

Also it may create a set of BuildConfigurations and define a transition table over them. - * All configurations during a build should be accessible from this top-level configuration - * via configuration transitions. + *

Also it may create a set of BuildConfigurations and define a transition table over them. All + * configurations during a build should be accessible from this top-level configuration via + * configuration transitions. + * * @param configurationFactory the configuration factory * @param cache a cache for BuildConfigurations * @param loadedPackageProvider the package provider @@ -48,7 +48,8 @@ public interface ConfigurationCollectionFactory { Cache cache, PackageProviderForConfigurations loadedPackageProvider, BuildOptions buildOptions, - EventHandler errorEventListener) throws InvalidConfigurationException; + EventHandler errorEventListener) + throws InvalidConfigurationException, InterruptedException; /** * Returns the module the given configuration should use for choosing dynamic transitions. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java index 6816b42e8d..10703ba8eb 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java @@ -45,14 +45,12 @@ import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.EvalUtils; import com.google.devtools.build.lib.util.OrderedSetMultimap; import com.google.devtools.build.lib.util.Preconditions; - import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; - import javax.annotation.Nullable; /** @@ -232,12 +230,15 @@ public abstract class DependencyResolver { } } - private void resolveExplicitAttributes(final RuleResolver depResolver) { + private void resolveExplicitAttributes(final RuleResolver depResolver) + throws InterruptedException { depResolver.attributeMap.visitLabels( new AttributeMap.AcceptsLabelAttribute() { @Override - public void acceptLabelAttribute(Label label, Attribute attribute) { - if (attribute.getType() == BuildType.NODEP_LABEL || attribute.isImplicit() + public void acceptLabelAttribute(Label label, Attribute attribute) + throws InterruptedException { + if (attribute.getType() == BuildType.NODEP_LABEL + || attribute.isImplicit() || attribute.isLateBound()) { return; } @@ -246,10 +247,8 @@ public abstract class DependencyResolver { }); } - /** - * Resolves the dependencies for all implicit attributes in this rule. - */ - private void resolveImplicitAttributes(RuleResolver depResolver) { + /** Resolves the dependencies for all implicit attributes in this rule. */ + private void resolveImplicitAttributes(RuleResolver depResolver) throws InterruptedException { // Since the attributes that come from aspects do not appear in attributeMap, we have to get // their values from somewhere else. This incidentally means that aspects attributes are not // configurable. It would be nice if that wasn't the case, but we'd have to revamp how @@ -455,7 +454,8 @@ public abstract class DependencyResolver { * @param attrName the name of the attribute to add dependency labels to * @param labels the dependencies to add */ - private void addExplicitDeps(RuleResolver depResolver, String attrName, Iterable

Use this method with care: it skips Bazel's standard config transition semantics - * ({@link BuildConfiguration#evaluateTransition}). That means attributes passed through here - * won't obey standard rules on which configurations apply to their deps. This should only - * be done for special circumstances that really justify the difference. When in doubt, use - * {@link #resolveDep(Attribute, Label)}. + *

Use this method with care: it skips Bazel's standard config transition semantics ({@link + * BuildConfiguration#evaluateTransition}). That means attributes passed through here won't obey + * standard rules on which configurations apply to their deps. This should only be done for + * special circumstances that really justify the difference. When in doubt, use {@link + * #resolveDep(Attribute, Label)}. */ - void resolveDep(Attribute attribute, Label depLabel, BuildConfiguration config) { + void resolveDep(Attribute attribute, Label depLabel, BuildConfiguration config) + throws InterruptedException { Target toTarget = getTarget(rule, depLabel, rootCauses); if (toTarget == null) { return; // Skip this round: this is either a loading error or unevaluated Skyframe dep. @@ -686,8 +694,11 @@ public abstract class DependencyResolver { } } - private void visitTargetVisibility(TargetAndConfiguration node, - NestedSetBuilder

Returns null if the target is not ready to be returned at this moment. If getTarget returns * null once or more during a {@link #dependentNodeMap} call, the results of that call will be - * incomplete. For use within Skyframe, where several iterations may be needed to discover - * all dependencies. + * incomplete. For use within Skyframe, where several iterations may be needed to discover all + * dependencies. */ @Nullable - protected abstract Target getTarget(Target from, Label label, NestedSetBuilder

Returns null if any configurations aren't ready to be returned at this moment. If * getConfigurations returns null once or more during a {@link #dependentNodeMap} call, the @@ -758,5 +771,6 @@ public abstract class DependencyResolver { @Nullable protected abstract List getConfigurations( Set> fragments, - Iterable buildOptions) throws InvalidConfigurationException; + Iterable buildOptions) + throws InvalidConfigurationException, InterruptedException; } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java b/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java index a908ada500..6a27b5c2a1 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java @@ -71,7 +71,7 @@ public final class RedirectChaser { */ @Nullable public static Label followRedirects(ConfigurationEnvironment env, Label label, String name) - throws InvalidConfigurationException { + throws InvalidConfigurationException, InterruptedException { Label oldLabel = null; Set

If the configuration has already been created, re-uses it, otherwise, creates a new one. */ @Nullable - public BuildConfiguration getConfiguration(PackageProviderForConfigurations loadedPackageProvider, - BuildOptions buildOptions, boolean actionsDisabled, Cache cache) - throws InvalidConfigurationException { + public BuildConfiguration getConfiguration( + PackageProviderForConfigurations loadedPackageProvider, + BuildOptions buildOptions, + boolean actionsDisabled, + Cache cache) + throws InvalidConfigurationException, InterruptedException { String cacheKey = buildOptions.computeCacheKey(); BuildConfiguration result = cache.getIfPresent(cacheKey); diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationFragmentFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationFragmentFactory.java index 1ae9a66bb0..0c19502324 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationFragmentFactory.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationFragmentFactory.java @@ -15,7 +15,6 @@ package com.google.devtools.build.lib.analysis.config; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment; - import javax.annotation.Nullable; /** @@ -31,7 +30,7 @@ public interface ConfigurationFragmentFactory { */ @Nullable BuildConfiguration.Fragment create(ConfigurationEnvironment env, BuildOptions buildOptions) - throws InvalidConfigurationException; + throws InvalidConfigurationException, InterruptedException; /** * @return the exact type of the fragment this factory creates. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/PackageProviderForConfigurations.java b/src/main/java/com/google/devtools/build/lib/analysis/config/PackageProviderForConfigurations.java index dddc786209..e493e482b4 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/PackageProviderForConfigurations.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/PackageProviderForConfigurations.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.packages.NoSuchPackageException; import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.Package; import com.google.devtools.build.lib.packages.Target; - import java.io.IOException; /** @@ -35,18 +34,15 @@ public interface PackageProviderForConfigurations { * Adds dependency to fileName if needed. Used only in skyframe, for creating correct dependencies * for {@link com.google.devtools.build.lib.skyframe.ConfigurationCollectionValue}. */ - void addDependency(Package pkg, String fileName) throws LabelSyntaxException, IOException; - - /** - * Returns fragment based on fragment type and build options. - */ - T getFragment(BuildOptions buildOptions, Class fragmentType) - throws InvalidConfigurationException; - - /** - * Returns blaze directories and adds dependency to that value. - */ - BlazeDirectories getDirectories(); + void addDependency(Package pkg, String fileName) + throws LabelSyntaxException, IOException, InterruptedException; + + /** Returns fragment based on fragment type and build options. */ + T getFragment(BuildOptions buildOptions, Class fragmentType) + throws InvalidConfigurationException, InterruptedException; + + /** Returns blaze directories and adds dependency to that value. */ + BlazeDirectories getDirectories() throws InterruptedException; /** * Returns true if any dependency is missing (value of some node hasn't been evaluated yet). @@ -59,8 +55,9 @@ public interface PackageProviderForConfigurations { * function evaluation. * * @throws NoSuchPackageException if the package could not be found - * @throws NoSuchTargetException if the package was loaded successfully, but - * the specified {@link Target} was not found in it + * @throws NoSuchTargetException if the package was loaded successfully, but the specified {@link + * Target} was not found in it */ - Target getTarget(Label label) throws NoSuchPackageException, NoSuchTargetException; + Target getTarget(Label label) + throws NoSuchPackageException, NoSuchTargetException, InterruptedException; } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/GitRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/GitRepositoryFunction.java index 0ba5c0f5e5..55c30dd316 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/GitRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/GitRepositoryFunction.java @@ -23,10 +23,8 @@ import com.google.devtools.build.lib.rules.repository.RepositoryFunction; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.skyframe.SkyFunction.Environment; -import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyValue; - import java.io.IOException; /** @@ -42,14 +40,13 @@ public class GitRepositoryFunction extends RepositoryFunction { @Override public SkyValue fetch( Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env) - throws SkyFunctionException { + throws InterruptedException, RepositoryFunctionException { createDirectory(outputDirectory, rule); GitCloner.clone(rule, outputDirectory, env.getListener(), clientEnvironment); return RepositoryDirectoryValue.create(outputDirectory); } - protected void createDirectory(Path path, Rule rule) - throws RepositoryFunctionException { + protected static void createDirectory(Path path, Rule rule) throws RepositoryFunctionException { try { FileSystemUtils.createDirectoryAndParents(path); } catch (IOException e) { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java index 28c4a00dcc..a18b4e089c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java @@ -23,12 +23,10 @@ import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.bazel.repository.downloader.HttpDownloader; import com.google.devtools.build.lib.bazel.rules.workspace.MavenJarRule; -import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.packages.AggregatingAttributeMapper; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryValue; -import com.google.devtools.build.lib.rules.repository.RepositoryFunction; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.Fingerprint; @@ -36,7 +34,9 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.skyframe.SkyFunction.Environment; import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyValue; - +import java.io.IOException; +import java.util.Map; +import javax.annotation.Nullable; import org.apache.maven.settings.Server; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -50,11 +50,6 @@ import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; -import java.io.IOException; -import java.util.Map; - -import javax.annotation.Nullable; - /** * Implementation of maven_jar. */ @@ -68,7 +63,7 @@ public class MavenJarFunction extends HttpArchiveFunction { @Override protected byte[] getRuleSpecificMarkerData(Rule rule, Environment env) - throws RepositoryFunctionException { + throws RepositoryFunctionException, InterruptedException { MavenServerValue serverValue = getServer(rule, env); if (env.valuesMissing()) { return null; @@ -80,11 +75,11 @@ public class MavenJarFunction extends HttpArchiveFunction { .digestAndReset(); } - private MavenServerValue getServer(Rule rule, Environment env) - throws RepositoryFunctionException { + private static MavenServerValue getServer(Rule rule, Environment env) + throws RepositoryFunctionException, InterruptedException { AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule); - boolean hasRepository = mapper.has("repository", Type.STRING) - && !mapper.get("repository", Type.STRING).isEmpty(); + boolean hasRepository = + mapper.has("repository", Type.STRING) && !mapper.get("repository", Type.STRING).isEmpty(); boolean hasServer = mapper.has("server", Type.STRING) && !mapper.get("server", Type.STRING).isEmpty(); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenServerFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenServerFunction.java index 73bfe2682c..ea85f50c80 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenServerFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenServerFunction.java @@ -31,12 +31,14 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.RootedPath; import com.google.devtools.build.skyframe.SkyFunction; -import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; - +import java.io.IOException; +import java.util.Arrays; +import java.util.Map; +import javax.annotation.Nullable; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.settings.building.DefaultSettingsBuilder; @@ -45,12 +47,6 @@ import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; import org.apache.maven.settings.building.SettingsBuildingException; import org.apache.maven.settings.building.SettingsBuildingResult; -import java.io.IOException; -import java.util.Arrays; -import java.util.Map; - -import javax.annotation.Nullable; - /** * Implementation of maven_repository. */ @@ -66,7 +62,7 @@ public class MavenServerFunction implements SkyFunction { @Nullable @Override public SkyValue compute(SkyKey skyKey, Environment env) - throws SkyFunctionException { + throws InterruptedException, RepositoryFunctionException { String repository = (String) skyKey.argument(); Rule repositoryRule = null; try { @@ -175,7 +171,7 @@ public class MavenServerFunction implements SkyFunction { } private Map getDefaultSettingsFile( - BlazeDirectories directories, Environment env) { + BlazeDirectories directories, Environment env) throws InterruptedException { // The system settings file is at $M2_HOME/conf/settings.xml. String m2Home = System.getenv("M2_HOME"); ImmutableList.Builder settingsFilesBuilder = ImmutableList.builder(); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/NewGitRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/NewGitRepositoryFunction.java index 4a8c56fb5c..e41695f5ea 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/NewGitRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/NewGitRepositoryFunction.java @@ -20,7 +20,6 @@ import com.google.devtools.build.lib.rules.repository.NewRepositoryBuildFileHand import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryValue; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.skyframe.SkyFunction.Environment; -import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyValue; /** @@ -30,7 +29,7 @@ public class NewGitRepositoryFunction extends GitRepositoryFunction { @Override public SkyValue fetch( Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env) - throws SkyFunctionException { + throws InterruptedException, RepositoryFunctionException { NewRepositoryBuildFileHandler buildFileHandler = new NewRepositoryBuildFileHandler(directories.getWorkspace()); if (!buildFileHandler.prepareBuildFile(rule, env)) { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java index 4ed66e965b..bfe4aec0a0 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java @@ -142,11 +142,12 @@ public class SkylarkRepositoryContext { + "during the analysis phase and thus cannot depends on a target result (the " + "label should point to a non-generated file)." ) - public SkylarkPath path(Object path) throws EvalException { + public SkylarkPath path(Object path) throws EvalException, InterruptedException { return getPath("path()", path); } - private SkylarkPath getPath(String method, Object path) throws EvalException { + private SkylarkPath getPath(String method, Object path) + throws EvalException, InterruptedException { if (path instanceof String) { PathFragment pathFragment = new PathFragment(path.toString()); return new SkylarkPath(pathFragment.isAbsolute() @@ -171,7 +172,8 @@ public class SkylarkRepositoryContext { "Create a symlink on the filesystem, the destination of the symlink should be in the " + "output directory. from can also be a label to a file." ) - public void symlink(Object from, Object to) throws RepositoryFunctionException, EvalException { + public void symlink(Object from, Object to) + throws RepositoryFunctionException, EvalException, InterruptedException { SkylarkPath fromPath = getPath("symlink()", from); SkylarkPath toPath = getPath("symlink()", to); try { @@ -198,26 +200,25 @@ public class SkylarkRepositoryContext { } @SkylarkCallable(name = "file", documented = false) - public void createFile(Object path) throws RepositoryFunctionException, EvalException { + public void createFile(Object path) + throws RepositoryFunctionException, EvalException, InterruptedException { createFile(path, ""); } - @SkylarkCallable( - name = "file", - documented = false - ) + @SkylarkCallable(name = "file", documented = false) public void createFile(Object path, String content) - throws RepositoryFunctionException, EvalException { + throws RepositoryFunctionException, EvalException, InterruptedException { createFile(path, content, true); } @SkylarkCallable( name = "file", - doc = "Generate a file in the output directory with the provided content. An optional third " - + "argument set the executable bit to on or off (default to True)." + doc = + "Generate a file in the output directory with the provided content. An optional third " + + "argument set the executable bit to on or off (default to True)." ) public void createFile(Object path, String content, Boolean executable) - throws RepositoryFunctionException, EvalException { + throws RepositoryFunctionException, EvalException, InterruptedException { SkylarkPath p = getPath("file()", path); try { checkInOutputDirectory(p); @@ -233,28 +234,25 @@ public class SkylarkRepositoryContext { } } - @SkylarkCallable( - name = "template", - documented = false - ) + @SkylarkCallable(name = "template", documented = false) public void createFileFromTemplate( Object path, Object template, Map substitutions) - throws RepositoryFunctionException, EvalException { + throws RepositoryFunctionException, EvalException, InterruptedException { createFileFromTemplate(path, template, substitutions, true); } @SkylarkCallable( - name = "template", - doc = - "Generate a new file using a template. Every occurrence in " - + "template of a key of substitutions will be replaced by " - + "the corresponding value. The result is written in path. An optional" - + "executable argument (default to true) can be set to turn on or off" - + "the executable bit." + name = "template", + doc = + "Generate a new file using a template. Every occurrence in " + + "template of a key of substitutions will be replaced by " + + "the corresponding value. The result is written in path. An optional" + + "executable argument (default to true) can be set to turn on or off" + + "the executable bit." ) public void createFileFromTemplate( - Object path, Object template, Map substitutions, Boolean executable) - throws RepositoryFunctionException, EvalException { + Object path, Object template, Map substitutions, Boolean executable) + throws RepositoryFunctionException, EvalException, InterruptedException { SkylarkPath p = getPath("template()", path); SkylarkPath t = getPath("template()", template); try { @@ -522,7 +520,7 @@ public class SkylarkRepositoryContext { } // Resolve the label given by value into a file path. - private SkylarkPath getPathFromLabel(Label label) throws EvalException { + private SkylarkPath getPathFromLabel(Label label) throws EvalException, InterruptedException { // Look for package. if (label.getPackageIdentifier().getRepository().isDefault()) { try { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java index 4db1a92b53..0bc74f4948 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java @@ -35,11 +35,9 @@ import com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition; import com.google.devtools.build.lib.packages.Attribute.SplitTransition; import com.google.devtools.build.lib.packages.Attribute.Transition; import com.google.devtools.build.lib.rules.cpp.CppRuleClasses.LipoTransition; - import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; - import javax.annotation.Nullable; /** @@ -53,7 +51,8 @@ public class BazelConfigurationCollection implements ConfigurationCollectionFact Cache cache, PackageProviderForConfigurations packageProvider, BuildOptions buildOptions, - EventHandler eventHandler) throws InvalidConfigurationException { + EventHandler eventHandler) + throws InvalidConfigurationException, InterruptedException { // Target configuration BuildConfiguration targetConfiguration = configurationFactory.getConfiguration( packageProvider, buildOptions, false, cache); @@ -114,29 +113,28 @@ public class BazelConfigurationCollection implements ConfigurationCollectionFact } /** - * Gets the correct host configuration for this build. The behavior - * depends on the value of the --distinct_host_configuration flag. + * Gets the correct host configuration for this build. The behavior depends on the value of the + * --distinct_host_configuration flag. * - *

With --distinct_host_configuration=false, we use identical configurations - * for the host and target, and you can ignore everything below. But please - * note: if you're cross-compiling for k8 on a piii machine, your build will - * fail. This is a stopgap measure. + *

With --distinct_host_configuration=false, we use identical configurations for the host and + * target, and you can ignore everything below. But please note: if you're cross-compiling for k8 + * on a piii machine, your build will fail. This is a stopgap measure. * - *

Currently, every build is (in effect) a cross-compile, in the strict - * sense that host and target configurations are unequal, thus we do not - * issue a "cross-compiling" warning. (Perhaps we should?) - * * - * @param requestConfig the requested target (not host!) configuration for - * this build. + *

Currently, every build is (in effect) a cross-compile, in the strict sense that host and + * target configurations are unequal, thus we do not issue a "cross-compiling" warning. (Perhaps + * we should?) * + * + * @param requestConfig the requested target (not host!) configuration for this build. * @param buildOptions the configuration options used for the target configuration */ @Nullable - private BuildConfiguration getHostConfigurationFromRequest( + private static BuildConfiguration getHostConfigurationFromRequest( ConfigurationFactory configurationFactory, PackageProviderForConfigurations loadedPackageProvider, - BuildConfiguration requestConfig, BuildOptions buildOptions, + BuildConfiguration requestConfig, + BuildOptions buildOptions, Cache cache) - throws InvalidConfigurationException { + throws InvalidConfigurationException, InterruptedException { BuildConfiguration.Options commonOptions = buildOptions.get(BuildConfiguration.Options.class); if (!commonOptions.useDistinctHostConfiguration) { return requestConfig; diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java index b30dae6afb..f26bfc93c2 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java @@ -44,11 +44,9 @@ import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CTool import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.ToolPath; import com.google.devtools.build.skyframe.SkyFunction.Environment; -import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; - import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -80,7 +78,7 @@ public class AndroidNdkRepositoryFunction extends RepositoryFunction { @Override public SkyValue fetch( Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env) - throws SkyFunctionException { + throws InterruptedException, RepositoryFunctionException { prepareLocalRepositorySymlinkTree(rule, outputDirectory); PathFragment pathFragment = getTargetPath(rule, directories.getWorkspace()); Path ndkSymlinkTreeDirectory = outputDirectory.getRelative("ndk"); @@ -267,7 +265,7 @@ public class AndroidNdkRepositoryFunction extends RepositoryFunction { } private static NdkRelease getNdkRelease(Path directory, Environment env) - throws RepositoryFunctionException { + throws RepositoryFunctionException, InterruptedException { // For NDK r11+ Path releaseFilePath = directory.getRelative("ndk/source.properties"); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java index 7285c056bf..5852a19012 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java @@ -33,7 +33,6 @@ import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; - import java.io.IOException; import java.util.Properties; @@ -49,7 +48,7 @@ public class AndroidSdkRepositoryFunction extends RepositoryFunction { @Override public SkyValue fetch( Rule rule, Path outputDirectory, BlazeDirectories directories, Environment env) - throws SkyFunctionException { + throws SkyFunctionException, InterruptedException { prepareLocalRepositorySymlinkTree(rule, outputDirectory); PathFragment pathFragment = getTargetPath(rule, directories.getWorkspace()); @@ -111,7 +110,7 @@ public class AndroidSdkRepositoryFunction extends RepositoryFunction { private static Properties getBuildToolsSourceProperties( Path directory, String buildToolsDirectory, Environment env) - throws RepositoryFunctionException { + throws RepositoryFunctionException, InterruptedException { Path sourcePropertiesFilePath = directory.getRelative( "build-tools/" + buildToolsDirectory + "/source.properties"); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java index 418130b9eb..479bfce47f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java @@ -42,7 +42,6 @@ import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.vfs.PathFragment; - import java.util.List; import java.util.Map; @@ -62,7 +61,8 @@ public class GenRule implements RuleConfiguredTargetFactory { } @Override - public ConfiguredTarget create(RuleContext ruleContext) throws RuleErrorException { + public ConfiguredTarget create(RuleContext ruleContext) + throws RuleErrorException, InterruptedException { final List resolvedSrcs = Lists.newArrayList(); final NestedSet filesToBuild = diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPatternResolver.java b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPatternResolver.java index 8dc0f0a76a..a3aea666c7 100644 --- a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPatternResolver.java +++ b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPatternResolver.java @@ -95,7 +95,7 @@ public interface TargetPatternResolver { * Returns true, if and only if the given package identifier corresponds to a package, i.e., a * file with the name {@code packageName/BUILD} exists in the appropriat repository. */ - boolean isPackage(PackageIdentifier packageIdentifier); + boolean isPackage(PackageIdentifier packageIdentifier) throws InterruptedException; /** * Returns the target kind of the given target, for example {@code cc_library rule}. diff --git a/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java b/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java index baab8847e7..01cdca1d3e 100644 --- a/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java +++ b/src/main/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitor.java @@ -20,7 +20,6 @@ import com.google.common.util.concurrent.AtomicLongMap; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.devtools.build.lib.concurrent.ErrorClassifier.ErrorClassification; import com.google.devtools.build.lib.util.Preconditions; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.RejectedExecutionException; @@ -29,7 +28,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.logging.Level; import java.util.logging.Logger; - import javax.annotation.Nullable; /** A {@link QuiescingExecutor} implementation that wraps an {@link ExecutorService}. */ @@ -143,7 +141,6 @@ public class AbstractQueueVisitor implements QuiescingExecutor { private final boolean ownExecutorService; private final ErrorClassifier errorClassifier; - private final ErrorHandler errorHandler; private static final Logger LOG = Logger.getLogger(AbstractQueueVisitor.class.getName()); @@ -176,25 +173,23 @@ public class AbstractQueueVisitor implements QuiescingExecutor { failFastOnException, poolName, EXECUTOR_FACTORY, - ErrorClassifier.DEFAULT, - ErrorHandler.NullHandler.INSTANCE); + ErrorClassifier.DEFAULT); } /** * Create the {@link AbstractQueueVisitor}. * * @param concurrent {@code true} if concurrency should be enabled. Only set to {@code false} for - * debugging. + * debugging. * @param parallelism a measure of parallelism for the {@link ExecutorService}, such as {@code - * parallelism} in {@link java.util.concurrent.ForkJoinPool}, or both {@code - * corePoolSize} and {@code maximumPoolSize} in {@link ThreadPoolExecutor}. + * parallelism} in {@link java.util.concurrent.ForkJoinPool}, or both {@code corePoolSize} and + * {@code maximumPoolSize} in {@link ThreadPoolExecutor}. * @param keepAliveTime the keep-alive time for the {@link ExecutorService}, if applicable. * @param units the time units of keepAliveTime. * @param failFastOnException if {@code true}, don't run new actions after an uncaught exception. * @param poolName sets the name of threads spawned by the {@link ExecutorService}. If {@code - * null}, default thread naming will be used. + * null}, default thread naming will be used. * @param errorClassifier an error classifier used to determine whether to log and/or stop jobs. - * @param errorHandler a handler for classified errors. */ public AbstractQueueVisitor( boolean concurrent, @@ -203,8 +198,7 @@ public class AbstractQueueVisitor implements QuiescingExecutor { TimeUnit units, boolean failFastOnException, String poolName, - ErrorClassifier errorClassifier, - ErrorHandler errorHandler) { + ErrorClassifier errorClassifier) { this( concurrent, parallelism, @@ -213,27 +207,25 @@ public class AbstractQueueVisitor implements QuiescingExecutor { failFastOnException, poolName, EXECUTOR_FACTORY, - errorClassifier, - errorHandler); + errorClassifier); } /** * Create the {@link AbstractQueueVisitor}. * * @param concurrent {@code true} if concurrency should be enabled. Only set to {@code false} for - * debugging. + * debugging. * @param parallelism a measure of parallelism for the {@link ExecutorService}, such as {@code - * parallelism} in {@link java.util.concurrent.ForkJoinPool}, or both {@code - * corePoolSize} and {@code maximumPoolSize} in {@link ThreadPoolExecutor}. + * parallelism} in {@link java.util.concurrent.ForkJoinPool}, or both {@code corePoolSize} and + * {@code maximumPoolSize} in {@link ThreadPoolExecutor}. * @param keepAliveTime the keep-alive time for the {@link ExecutorService}, if applicable. * @param units the time units of keepAliveTime. * @param failFastOnException if {@code true}, don't run new actions after an uncaught exception. * @param poolName sets the name of threads spawned by the {@link ExecutorService}. If {@code - * null}, default thread naming will be used. + * null}, default thread naming will be used. * @param executorFactory the factory for constructing the executor service if {@code concurrent} - * is {@code true}. + * is {@code true}. * @param errorClassifier an error classifier used to determine whether to log and/or stop jobs. - * @param errorHandler a handler for classified errors. */ public AbstractQueueVisitor( boolean concurrent, @@ -243,8 +235,7 @@ public class AbstractQueueVisitor implements QuiescingExecutor { boolean failFastOnException, String poolName, Function executorFactory, - ErrorClassifier errorClassifier, - ErrorHandler errorHandler) { + ErrorClassifier errorClassifier) { Preconditions.checkNotNull(poolName); Preconditions.checkNotNull(executorFactory); Preconditions.checkNotNull(errorClassifier); @@ -258,7 +249,6 @@ public class AbstractQueueVisitor implements QuiescingExecutor { parallelism, keepAliveTime, units, poolName, new BlockingStack())) : null; this.errorClassifier = errorClassifier; - this.errorHandler = errorHandler; } /** @@ -278,8 +268,7 @@ public class AbstractQueueVisitor implements QuiescingExecutor { executorService, shutdownOnCompletion, failFastOnException, - ErrorClassifier.DEFAULT, - ErrorHandler.NullHandler.INSTANCE); + ErrorClassifier.DEFAULT); } /** @@ -305,37 +294,32 @@ public class AbstractQueueVisitor implements QuiescingExecutor { this.ownExecutorService = shutdownOnCompletion; this.executorService = executorService; this.errorClassifier = ErrorClassifier.DEFAULT; - this.errorHandler = ErrorHandler.NullHandler.INSTANCE; } /** * Create the AbstractQueueVisitor. * * @param concurrent if {@code false}, run tasks inline instead of using the {@link - * ExecutorService}. + * ExecutorService}. * @param executorService The {@link ExecutorService} to use. * @param shutdownOnCompletion If {@code true}, pass ownership of the {@link ExecutorService} to - * this class. The service will be shut down after a - * call to {@link #awaitQuiescence}. Callers must not shut down the - * {@link ExecutorService} while queue visitors use it. + * this class. The service will be shut down after a call to {@link #awaitQuiescence}. Callers + * must not shut down the {@link ExecutorService} while queue visitors use it. * @param failFastOnException if {@code true}, don't run new actions after an uncaught exception. * @param errorClassifier an error classifier used to determine whether to log and/or stop jobs. - * @param errorHandler a handler for classified errors. */ public AbstractQueueVisitor( boolean concurrent, ExecutorService executorService, boolean shutdownOnCompletion, boolean failFastOnException, - ErrorClassifier errorClassifier, - ErrorHandler errorHandler) { + ErrorClassifier errorClassifier) { Preconditions.checkArgument(executorService != null || !concurrent); this.concurrent = concurrent; this.failFastOnException = failFastOnException; this.ownExecutorService = shutdownOnCompletion; this.executorService = executorService; this.errorClassifier = errorClassifier; - this.errorHandler = errorHandler; } /** @@ -358,8 +342,7 @@ public class AbstractQueueVisitor implements QuiescingExecutor { false, poolName, EXECUTOR_FACTORY, - ErrorClassifier.DEFAULT, - ErrorHandler.NullHandler.INSTANCE); + ErrorClassifier.DEFAULT); } @@ -437,7 +420,6 @@ public class AbstractQueueVisitor implements QuiescingExecutor { default: break; } - errorHandler.handle(e, errorClassification); if (unhandled == null || errorClassification.compareTo(errorClassifier.classify(unhandled)) > 0) { // Save the most severe error. diff --git a/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java b/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java index 54bb572665..45132a1cb7 100644 --- a/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java @@ -23,15 +23,13 @@ import java.util.concurrent.ForkJoinTask; // maintaining AQV.remainingTasks. public class ForkJoinQuiescingExecutor extends AbstractQueueVisitor { - public ForkJoinQuiescingExecutor(ForkJoinPool forkJoinPool, ErrorClassifier errorClassifier, - ErrorHandler errorHandler) { + public ForkJoinQuiescingExecutor(ForkJoinPool forkJoinPool, ErrorClassifier errorClassifier) { super( /*concurrent=*/ true, forkJoinPool, /*shutdownOnCompletion=*/ true, /*failFastOnException=*/ true, - errorClassifier, - errorHandler); + errorClassifier); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java index f37613fd04..d89e278ab7 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java @@ -136,7 +136,7 @@ public abstract class AbstractAttributeMapper implements AttributeMap { } @Override - public void visitLabels(AcceptsLabelAttribute observer) { + public void visitLabels(AcceptsLabelAttribute observer) throws InterruptedException { for (Attribute attribute : ruleClass.getAttributes()) { Type type = attribute.getType(); // TODO(bazel-team): clean up the typing / visitation interface so we don't have to @@ -148,10 +148,9 @@ public abstract class AbstractAttributeMapper implements AttributeMap { } } - /** - * Visits all labels reachable from the given attribute. - */ - protected void visitLabels(Attribute attribute, AcceptsLabelAttribute observer) { + /** Visits all labels reachable from the given attribute. */ + protected void visitLabels(Attribute attribute, AcceptsLabelAttribute observer) + throws InterruptedException { Type type = attribute.getType(); Object value = get(attribute.getName(), type); if (value != null) { // null values are particularly possible for computed defaults. diff --git a/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java index 454cd71bf9..4fab639d96 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java @@ -86,8 +86,7 @@ public class AggregatingAttributeMapper extends AbstractAttributeMapper { } /** - * Override that also visits the rule's configurable attribute keys (which are - * themselves labels). + * Override that also visits the rule's configurable attribute keys (which are themselves labels). * *

Note that we directly parse the selectors rather than just calling {@link #visitAttribute} * to iterate over all possible values. That's because {@link #visitAttribute} can grow @@ -96,12 +95,14 @@ public class AggregatingAttributeMapper extends AbstractAttributeMapper { * path whenever actual value iteration isn't specifically needed. */ @Override - protected void visitLabels(Attribute attribute, AcceptsLabelAttribute observer) { + protected void visitLabels(Attribute attribute, AcceptsLabelAttribute observer) + throws InterruptedException { visitLabels(attribute, true, observer); } - private void visitLabels(Attribute attribute, boolean includeSelectKeys, - AcceptsLabelAttribute observer) { + private void visitLabels( + Attribute attribute, boolean includeSelectKeys, AcceptsLabelAttribute observer) + throws InterruptedException { Type type = attribute.getType(); SelectorList selectorList = getSelectorList(attribute.getName(), type); if (selectorList == null) { @@ -137,12 +138,13 @@ public class AggregatingAttributeMapper extends AbstractAttributeMapper { } /** - * Returns all labels reachable via the given attribute. If a label is listed multiple times, - * each instance appears in the returned list. + * Returns all labels reachable via the given attribute. If a label is listed multiple times, each + * instance appears in the returned list. * * @param includeSelectKeys whether to include config_setting keys for configurable attributes */ - public List

    + *
  • Each name refers to at most one target. + *
  • No rule with errors is inserted into the package. + *
  • The generating rule of every output file in the package must itself be in the package. + *
*/ - private void checkForConflicts(Rule rule) throws NameConflictException { + private void checkForConflicts(Rule rule) throws NameConflictException, InterruptedException { String name = rule.getName(); Target existing = targets.get(name); if (existing != null) { @@ -1451,17 +1452,15 @@ public class Package { } /** - * A utility method that checks for conflicts between - * input file names and output file names for a rule from a build - * file. - * @param rule the rule whose inputs and outputs are - * to be checked for conflicts. - * @param outputFiles a set containing the names of output - * files to be generated by the rule. + * A utility method that checks for conflicts between input file names and output file names for + * a rule from a build file. + * + * @param rule the rule whose inputs and outputs are to be checked for conflicts. + * @param outputFiles a set containing the names of output files to be generated by the rule. * @throws NameConflictException if a conflict is found. */ private void checkForInputOutputConflicts(Rule rule, Set outputFiles) - throws NameConflictException { + throws NameConflictException, InterruptedException { PathFragment packageFragment = rule.getLabel().getPackageFragment(); for (Label inputLabel : rule.getLabels()) { if (packageFragment.equals(inputLabel.getPackageFragment()) diff --git a/src/main/java/com/google/devtools/build/lib/packages/Rule.java b/src/main/java/com/google/devtools/build/lib/packages/Rule.java index dd5df33055..29af9a54c9 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Rule.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Rule.java @@ -398,10 +398,8 @@ public final class Rule implements Target, DependencyFilter.AttributeInfoProvide return false; } - /** - * Returns a new List instance containing all direct dependencies (all types). - */ - public Collection