diff options
author | nharmata <nharmata@google.com> | 2017-06-06 10:42:15 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-06-06 12:36:44 -0400 |
commit | d3c59b37fa0e39c242d6bb246b0af4a88794ab17 (patch) | |
tree | 62039c853c89067717b70e6a208686110cc612be /src/main/java/com | |
parent | abc64dd614705b023a4b18c94e5b7df4b8d943ae (diff) |
Factor out Bazel-specific ctor constants in SequencedSkyframeExecutor into a separate class. They're currently passed in around various callsites in the codebase and tests.
RELNOTES: None
PiperOrigin-RevId: 158139074
Diffstat (limited to 'src/main/java/com')
3 files changed, 117 insertions, 29 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BazelSkyframeExecutorConstants.java b/src/main/java/com/google/devtools/build/lib/skyframe/BazelSkyframeExecutorConstants.java new file mode 100644 index 0000000000..198c10fb74 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BazelSkyframeExecutorConstants.java @@ -0,0 +1,29 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.skyframe; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.skyframe.PackageLookupFunction.CrossRepositoryLabelViolationStrategy; +import com.google.devtools.build.lib.skyframe.PackageLookupValue.BuildFileName; + +class BazelSkyframeExecutorConstants { + private BazelSkyframeExecutorConstants() { + } + + static final CrossRepositoryLabelViolationStrategy CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY = + CrossRepositoryLabelViolationStrategy.ERROR; + + static final ImmutableList<BuildFileName> BUILD_FILES_BY_PRIORITY = + ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD); +} diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java index 0cb6552496..26e146b88b 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java @@ -146,6 +146,42 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { this.customDirtinessCheckers = customDirtinessCheckers; } + private static SequencedSkyframeExecutor create( + PackageFactory pkgFactory, + BlazeDirectories directories, + BinTools binTools, + Factory workspaceStatusActionFactory, + ImmutableList<BuildInfoFactory> buildInfoFactories, + Iterable<? extends DiffAwareness.Factory> diffAwarenessFactories, + Predicate<PathFragment> allowedMissingInputs, + ImmutableMap<SkyFunctionName, SkyFunction> extraSkyFunctions, + ImmutableList<PrecomputedValue.Injected> extraPrecomputedValues, + Iterable<SkyValueDirtinessChecker> customDirtinessCheckers, + PathFragment blacklistedPackagePrefixesFile, + String productName, + CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy, + List<BuildFileName> buildFilesByPriority) { + SequencedSkyframeExecutor skyframeExecutor = + new SequencedSkyframeExecutor( + InMemoryMemoizingEvaluator.SUPPLIER, + pkgFactory, + directories, + binTools, + workspaceStatusActionFactory, + buildInfoFactories, + diffAwarenessFactories, + allowedMissingInputs, + extraSkyFunctions, + extraPrecomputedValues, + customDirtinessCheckers, + blacklistedPackagePrefixesFile, + productName, + crossRepositoryLabelViolationStrategy, + buildFilesByPriority); + skyframeExecutor.init(); + return skyframeExecutor; + } + public static SequencedSkyframeExecutor create( PackageFactory pkgFactory, BlazeDirectories directories, @@ -177,7 +213,37 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { buildFilesByPriority); } - private static SequencedSkyframeExecutor create( + @VisibleForTesting + public static SequencedSkyframeExecutor createForTesting( + PackageFactory pkgFactory, + BlazeDirectories directories, + BinTools binTools, + Factory workspaceStatusActionFactory, + ImmutableList<BuildInfoFactory> buildInfoFactories, + Iterable<? extends DiffAwareness.Factory> diffAwarenessFactories, + Predicate<PathFragment> allowedMissingInputs, + ImmutableMap<SkyFunctionName, SkyFunction> extraSkyFunctions, + ImmutableList<PrecomputedValue.Injected> extraPrecomputedValues, + Iterable<SkyValueDirtinessChecker> customDirtinessCheckers, + String productName) { + return createForTesting( + pkgFactory, + directories, + binTools, + workspaceStatusActionFactory, + buildInfoFactories, + diffAwarenessFactories, + allowedMissingInputs, + extraSkyFunctions, + extraPrecomputedValues, + customDirtinessCheckers, + productName, + BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, + BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY); + } + + @VisibleForTesting + public static SequencedSkyframeExecutor createForTesting( PackageFactory pkgFactory, BlazeDirectories directories, BinTools binTools, @@ -188,33 +254,28 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { ImmutableMap<SkyFunctionName, SkyFunction> extraSkyFunctions, ImmutableList<PrecomputedValue.Injected> extraPrecomputedValues, Iterable<SkyValueDirtinessChecker> customDirtinessCheckers, - PathFragment blacklistedPackagePrefixesFile, String productName, CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy, - List<BuildFileName> buildFilesByPriority) { - SequencedSkyframeExecutor skyframeExecutor = - new SequencedSkyframeExecutor( - InMemoryMemoizingEvaluator.SUPPLIER, - pkgFactory, - directories, - binTools, - workspaceStatusActionFactory, - buildInfoFactories, - diffAwarenessFactories, - allowedMissingInputs, - extraSkyFunctions, - extraPrecomputedValues, - customDirtinessCheckers, - blacklistedPackagePrefixesFile, - productName, - crossRepositoryLabelViolationStrategy, - buildFilesByPriority); - skyframeExecutor.init(); - return skyframeExecutor; + ImmutableList<BuildFileName> buildFilesByPriority) { + return create( + pkgFactory, + directories, + binTools, + workspaceStatusActionFactory, + buildInfoFactories, + diffAwarenessFactories, + allowedMissingInputs, + extraSkyFunctions, + extraPrecomputedValues, + customDirtinessCheckers, + /*blacklistedPackagePrefixesFile=*/ PathFragment.EMPTY_FRAGMENT, + productName, + crossRepositoryLabelViolationStrategy, + buildFilesByPriority); } @VisibleForTesting - public static SequencedSkyframeExecutor create( + public static SequencedSkyframeExecutor createForTesting( PackageFactory pkgFactory, BlazeDirectories directories, BinTools binTools, @@ -236,8 +297,8 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { ImmutableList.<SkyValueDirtinessChecker>of(), blacklistedPackagePrefixesFile, productName, - CrossRepositoryLabelViolationStrategy.ERROR, - ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)); + BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, + BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java index b82f740dc3..b6e91fec82 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java @@ -21,8 +21,6 @@ import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Factory; import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory; import com.google.devtools.build.lib.analysis.config.BinTools; import com.google.devtools.build.lib.packages.PackageFactory; -import com.google.devtools.build.lib.skyframe.PackageLookupFunction.CrossRepositoryLabelViolationStrategy; -import com.google.devtools.build.lib.skyframe.PackageLookupValue.BuildFileName; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyFunctionName; @@ -57,7 +55,7 @@ public class SequencedSkyframeExecutorFactory implements SkyframeExecutorFactory extraPrecomputedValues, customDirtinessCheckers, productName, - CrossRepositoryLabelViolationStrategy.ERROR, - ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD)); + BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, + BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY); } } |