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 index 331a4e48360a78..5e7e6892906d21 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BazelSkyframeExecutorConstants.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BazelSkyframeExecutorConstants.java @@ -51,4 +51,13 @@ private BazelSkyframeExecutorConstants() { public static final ActionOnIOExceptionReadingBuildFile ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE = ActionOnIOExceptionReadingBuildFile.UseOriginalIOException.INSTANCE; + + public static SequencedSkyframeExecutor.Builder newBazelSkyframeExecutorBuilder() { + return SequencedSkyframeExecutor.builder() + .setHardcodedBlacklistedPackagePrefixes(HARDCODED_BLACKLISTED_PACKAGE_PREFIXES) + .setAdditionalBlacklistedPackagePrefixesFile(ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE) + .setActionOnIOExceptionReadingBuildFile(ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE) + .setCrossRepositoryLabelViolationStrategy(CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY) + .setBuildFilesByPriority(BUILD_FILES_BY_PRIORITY); + } } 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 3fa441fb49949b..cd14cb59d83151 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 @@ -187,84 +187,6 @@ private SequencedSkyframeExecutor( this.customDirtinessCheckers = customDirtinessCheckers; } - public static SequencedSkyframeExecutor create( - PackageFactory pkgFactory, - FileSystem fileSystem, - BlazeDirectories directories, - ActionKeyContext actionKeyContext, - Factory workspaceStatusActionFactory, - ImmutableList buildInfoFactories, - Iterable diffAwarenessFactories, - ImmutableMap extraSkyFunctions, - Iterable customDirtinessCheckers, - ImmutableSet hardcodedBlacklistedPackagePrefixes, - PathFragment additionalBlacklistedPackagePrefixesFile, - CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy, - List buildFilesByPriority, - ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile, - BuildOptions defaultBuildOptions) { - return create( - pkgFactory, - fileSystem, - directories, - actionKeyContext, - workspaceStatusActionFactory, - buildInfoFactories, - diffAwarenessFactories, - extraSkyFunctions, - customDirtinessCheckers, - hardcodedBlacklistedPackagePrefixes, - additionalBlacklistedPackagePrefixesFile, - crossRepositoryLabelViolationStrategy, - buildFilesByPriority, - actionOnIOExceptionReadingBuildFile, - defaultBuildOptions, - new MutableArtifactFactorySupplier(), - skyframeExecutor -> {}); - } - - public static SequencedSkyframeExecutor create( - PackageFactory pkgFactory, - FileSystem fileSystem, - BlazeDirectories directories, - ActionKeyContext actionKeyContext, - Factory workspaceStatusActionFactory, - ImmutableList buildInfoFactories, - Iterable diffAwarenessFactories, - ImmutableMap extraSkyFunctions, - Iterable customDirtinessCheckers, - ImmutableSet hardcodedBlacklistedPackagePrefixes, - PathFragment additionalBlacklistedPackagePrefixesFile, - CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy, - List buildFilesByPriority, - ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile, - BuildOptions defaultBuildOptions, - MutableArtifactFactorySupplier mutableArtifactFactorySupplier, - Consumer skyframeExecutorConsumerOnInit) { - SequencedSkyframeExecutor skyframeExecutor = - new SequencedSkyframeExecutor( - skyframeExecutorConsumerOnInit, - InMemoryMemoizingEvaluator.SUPPLIER, - pkgFactory, - fileSystem, - directories, - actionKeyContext, - workspaceStatusActionFactory, - buildInfoFactories, - diffAwarenessFactories, - extraSkyFunctions, - customDirtinessCheckers, - hardcodedBlacklistedPackagePrefixes, - additionalBlacklistedPackagePrefixesFile, - crossRepositoryLabelViolationStrategy, - buildFilesByPriority, - actionOnIOExceptionReadingBuildFile, - defaultBuildOptions, - mutableArtifactFactorySupplier); - skyframeExecutor.init(); - return skyframeExecutor; - } - @Override protected BuildDriver getBuildDriver() { return new SequentialBuildDriver(memoizingEvaluator); @@ -876,4 +798,178 @@ public void dumpPackages(PrintStream out) { pkg.dump(out); } } + + public static Builder builder() { + return new Builder(); + } + + /** + * Builder class for {@link SequencedSkyframeExecutor}. + * + *

Allows addition of the new arguments to {@link SequencedSkyframeExecutor} constructor + * without the need to modify all the places, where {@link SequencedSkyframeExecutor} is + * constructed (if the default value can be provided for the new argument in Builder). + */ + public static final class Builder { + protected PackageFactory pkgFactory; + protected FileSystem fileSystem; + protected BlazeDirectories directories; + protected ActionKeyContext actionKeyContext; + protected ImmutableList buildInfoFactories; + protected BuildOptions defaultBuildOptions; + + private ImmutableSet hardcodedBlacklistedPackagePrefixes; + private PathFragment additionalBlacklistedPackagePrefixesFile; + private CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy; + private List buildFilesByPriority; + private ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile; + + // Fields with default values. + private ImmutableMap extraSkyFunctions = ImmutableMap.of(); + private Factory workspaceStatusActionFactory; + private Iterable diffAwarenessFactories = ImmutableList.of(); + private Iterable customDirtinessCheckers = ImmutableList.of(); + private MutableArtifactFactorySupplier mutableArtifactFactorySupplier = + new MutableArtifactFactorySupplier(); + private Consumer skyframeExecutorConsumerOnInit = skyframeExecutor -> {}; + + private Builder() {} + + public SequencedSkyframeExecutor build() { + // Check that the values were explicitly set. + Preconditions.checkNotNull(pkgFactory); + Preconditions.checkNotNull(fileSystem); + Preconditions.checkNotNull(directories); + Preconditions.checkNotNull(actionKeyContext); + Preconditions.checkNotNull(buildInfoFactories); + Preconditions.checkNotNull(defaultBuildOptions); + Preconditions.checkNotNull(hardcodedBlacklistedPackagePrefixes); + Preconditions.checkNotNull(additionalBlacklistedPackagePrefixesFile); + Preconditions.checkNotNull(crossRepositoryLabelViolationStrategy); + Preconditions.checkNotNull(buildFilesByPriority); + Preconditions.checkNotNull(actionOnIOExceptionReadingBuildFile); + + SequencedSkyframeExecutor skyframeExecutor = + new SequencedSkyframeExecutor( + skyframeExecutorConsumerOnInit, + InMemoryMemoizingEvaluator.SUPPLIER, + pkgFactory, + fileSystem, + directories, + actionKeyContext, + workspaceStatusActionFactory, + buildInfoFactories, + diffAwarenessFactories, + extraSkyFunctions, + customDirtinessCheckers, + hardcodedBlacklistedPackagePrefixes, + additionalBlacklistedPackagePrefixesFile, + crossRepositoryLabelViolationStrategy, + buildFilesByPriority, + actionOnIOExceptionReadingBuildFile, + defaultBuildOptions, + mutableArtifactFactorySupplier); + skyframeExecutor.init(); + return skyframeExecutor; + } + + public Builder modify(Consumer consumer) { + consumer.accept(this); + return this; + } + + public Builder setPkgFactory(PackageFactory pkgFactory) { + this.pkgFactory = pkgFactory; + return this; + } + + public Builder setFileSystem(FileSystem fileSystem) { + this.fileSystem = fileSystem; + return this; + } + + public Builder setDirectories(BlazeDirectories directories) { + this.directories = directories; + return this; + } + + public Builder setActionKeyContext(ActionKeyContext actionKeyContext) { + this.actionKeyContext = actionKeyContext; + return this; + } + + public Builder setBuildInfoFactories(ImmutableList buildInfoFactories) { + this.buildInfoFactories = buildInfoFactories; + return this; + } + + public Builder setDefaultBuildOptions(BuildOptions defaultBuildOptions) { + this.defaultBuildOptions = defaultBuildOptions; + return this; + } + + public Builder setExtraSkyFunctions( + ImmutableMap extraSkyFunctions) { + this.extraSkyFunctions = extraSkyFunctions; + return this; + } + + public Builder setWorkspaceStatusActionFactory(@Nullable Factory workspaceStatusActionFactory) { + this.workspaceStatusActionFactory = workspaceStatusActionFactory; + return this; + } + + public Builder setDiffAwarenessFactories( + Iterable diffAwarenessFactories) { + this.diffAwarenessFactories = diffAwarenessFactories; + return this; + } + + public Builder setCustomDirtinessCheckers( + Iterable customDirtinessCheckers) { + this.customDirtinessCheckers = customDirtinessCheckers; + return this; + } + + public Builder setHardcodedBlacklistedPackagePrefixes( + ImmutableSet hardcodedBlacklistedPackagePrefixes) { + this.hardcodedBlacklistedPackagePrefixes = hardcodedBlacklistedPackagePrefixes; + return this; + } + + public Builder setAdditionalBlacklistedPackagePrefixesFile( + PathFragment additionalBlacklistedPackagePrefixesFile) { + this.additionalBlacklistedPackagePrefixesFile = additionalBlacklistedPackagePrefixesFile; + return this; + } + + public Builder setCrossRepositoryLabelViolationStrategy( + CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy) { + this.crossRepositoryLabelViolationStrategy = crossRepositoryLabelViolationStrategy; + return this; + } + + public Builder setBuildFilesByPriority(List buildFilesByPriority) { + this.buildFilesByPriority = buildFilesByPriority; + return this; + } + + public Builder setActionOnIOExceptionReadingBuildFile( + ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile) { + this.actionOnIOExceptionReadingBuildFile = actionOnIOExceptionReadingBuildFile; + return this; + } + + public Builder setMutableArtifactFactorySupplier( + MutableArtifactFactorySupplier mutableArtifactFactorySupplier) { + this.mutableArtifactFactorySupplier = mutableArtifactFactorySupplier; + return this; + } + + public Builder setSkyframeExecutorConsumerOnInit( + Consumer skyframeExecutorConsumerOnInit) { + this.skyframeExecutorConsumerOnInit = skyframeExecutorConsumerOnInit; + return this; + } + } } 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 9f8d4be7efce89..aba704e7ca13e0 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,7 +21,6 @@ import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.packages.PackageFactory; -import com.google.devtools.build.lib.skyframe.SkyframeExecutor.MutableArtifactFactorySupplier; import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyFunctionName; @@ -48,23 +47,17 @@ public SkyframeExecutor create( Iterable diffAwarenessFactories, ImmutableMap extraSkyFunctions, Iterable customDirtinessCheckers) { - return SequencedSkyframeExecutor.create( - pkgFactory, - fileSystem, - directories, - actionKeyContext, - workspaceStatusActionFactory, - buildInfoFactories, - diffAwarenessFactories, - extraSkyFunctions, - customDirtinessCheckers, - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - defaultBuildOptions, - new MutableArtifactFactorySupplier(), - skyframeExecutor -> {}); + return BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(buildInfoFactories) + .setDefaultBuildOptions(defaultBuildOptions) + .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) + .setDiffAwarenessFactories(diffAwarenessFactories) + .setExtraSkyFunctions(extraSkyFunctions) + .setCustomDirtinessCheckers(customDirtinessCheckers) + .build(); } } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java index 5f8ba966588bf3..745c637bb96265 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java @@ -67,7 +67,6 @@ import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; import com.google.devtools.build.lib.skyframe.PrecomputedValue; -import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.skyframe.TargetPatternPhaseValue; import com.google.devtools.build.lib.skyframe.util.SkyframeExecutorTestUtils; @@ -194,22 +193,17 @@ public final void createMocks() throws Exception { protected SkyframeExecutor createSkyframeExecutor( PackageFactory pkgFactory, ImmutableList buildInfoFactories) { - return SequencedSkyframeExecutor.create( - pkgFactory, - fileSystem, - directories, - actionKeyContext, - workspaceStatusActionFactory, - buildInfoFactories, - ImmutableList.of(), - analysisMock.getSkyFunctions(directories), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)); + return BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(buildInfoFactories) + .setDefaultBuildOptions( + DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) + .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) + .build(); } /** diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index 3b7c1a5e50754c..8998f25b9f5651 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -135,11 +135,9 @@ import com.google.devtools.build.lib.skyframe.BuildConfigurationValue; import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; -import com.google.devtools.build.lib.skyframe.DiffAwareness; import com.google.devtools.build.lib.skyframe.PackageRootsNoSymlinkCreation; import com.google.devtools.build.lib.skyframe.PrecomputedValue; import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; -import com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.skyframe.TargetPatternPhaseValue; import com.google.devtools.build.lib.syntax.StarlarkSemantics; @@ -268,22 +266,17 @@ public void initializeSkyframeExecutor(boolean doPackageLoadingChecks) throws Ex pkgFactory = pkgFactoryBuilder.build(ruleClassProvider, fileSystem); tsgm = new TimestampGranularityMonitor(BlazeClock.instance()); skyframeExecutor = - SequencedSkyframeExecutor.create( - pkgFactory, - fileSystem, - directories, - actionKeyContext, - workspaceStatusActionFactory, - ruleClassProvider.getBuildInfoFactories(), - ImmutableList.of(), - analysisMock.getSkyFunctions(directories), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(ruleClassProvider.getBuildInfoFactories()) + .setDefaultBuildOptions( + DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) + .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) + .build(); TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); skyframeExecutor.injectExtraPrecomputedValues(extraPrecomputedValues); packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PUBLIC; diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java index 19907d6b4b4c2a..2da90b4a5f61a4 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java @@ -40,10 +40,8 @@ import com.google.devtools.build.lib.pkgcache.PathPackageLocator; import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction; import com.google.devtools.build.lib.skyframe.BazelSkyframeExecutorConstants; -import com.google.devtools.build.lib.skyframe.DiffAwareness; import com.google.devtools.build.lib.skyframe.PrecomputedValue; import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; -import com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker; import com.google.devtools.build.lib.testutil.FoundationTestCase; import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; @@ -133,22 +131,17 @@ public final void initializeSkyframeExecutor() throws Exception { AnalysisTestUtil.DummyWorkspaceStatusActionFactory workspaceStatusActionFactory = new AnalysisTestUtil.DummyWorkspaceStatusActionFactory(); skyframeExecutor = - SequencedSkyframeExecutor.create( - pkgFactory, - fileSystem, - directories, - actionKeyContext, - workspaceStatusActionFactory, - ruleClassProvider.getBuildInfoFactories(), - ImmutableList.of(), - analysisMock.getSkyFunctions(directories), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(ruleClassProvider.getBuildInfoFactories()) + .setDefaultBuildOptions( + DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) + .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) + .build(); TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); skyframeExecutor.injectExtraPrecomputedValues( ImmutableList.of( diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java index c0105a47664382..13545b25e3e9ce 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java @@ -40,10 +40,7 @@ import com.google.devtools.build.lib.pkgcache.PathPackageLocator; import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction; import com.google.devtools.build.lib.skyframe.BazelSkyframeExecutorConstants; -import com.google.devtools.build.lib.skyframe.DiffAwareness; import com.google.devtools.build.lib.skyframe.PrecomputedValue; -import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; -import com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.testutil.FoundationTestCase; import com.google.devtools.build.lib.testutil.TestConstants; @@ -52,8 +49,6 @@ import com.google.devtools.build.lib.vfs.ModifiedFileSet; import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.build.lib.vfs.RootedPath; -import com.google.devtools.build.skyframe.SkyFunction; -import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsParser; import java.io.IOException; @@ -117,22 +112,15 @@ protected List getExtraRules() { private SkyframeExecutor createSkyframeExecutor() { SkyframeExecutor skyframeExecutor = - SequencedSkyframeExecutor.create( - packageFactory, - fileSystem, - directories, - actionKeyContext, - /* workspaceStatusActionFactory= */ null, - ruleClassProvider.getBuildInfoFactories(), - ImmutableList.of(), - ImmutableMap.of(), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(packageFactory) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(ruleClassProvider.getBuildInfoFactories()) + .setDefaultBuildOptions( + DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .build(); skyframeExecutor.injectExtraPrecomputedValues( ImmutableList.of( PrecomputedValue.injected( diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java index e0c36f0a18f9d7..93e02c97d39b65 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java @@ -28,13 +28,11 @@ import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.packages.NoSuchPackageException; import com.google.devtools.build.lib.packages.Package; +import com.google.devtools.build.lib.packages.PackageFactory; import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions; import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction; import com.google.devtools.build.lib.skyframe.BazelSkyframeExecutorConstants; -import com.google.devtools.build.lib.skyframe.DiffAwareness; import com.google.devtools.build.lib.skyframe.PrecomputedValue; -import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; -import com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.testutil.FoundationTestCase; import com.google.devtools.build.lib.testutil.ManualClock; @@ -84,25 +82,21 @@ public final void initializeSkyframeExecutor() throws Exception { rootDirectory, /* defaultSystemJavabase= */ null, analysisMock.getProductName()); + PackageFactory pkgFactory = + analysisMock + .getPackageFactoryBuilderForTesting(directories) + .build(ruleClassProvider, fileSystem); skyframeExecutor = - SequencedSkyframeExecutor.create( - analysisMock - .getPackageFactoryBuilderForTesting(directories) - .build(ruleClassProvider, fileSystem), - fileSystem, - directories, - actionKeyContext, - /* workspaceStatusActionFactory= */ null, - ruleClassProvider.getBuildInfoFactories(), - ImmutableList.of(), - analysisMock.getSkyFunctions(directories), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(ruleClassProvider.getBuildInfoFactories()) + .setDefaultBuildOptions( + DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) + .build(); skyframeExecutor.injectExtraPrecomputedValues( ImmutableList.of( PrecomputedValue.injected( diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java index acbf8f7254e42f..1e392e2c9f98e5 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java @@ -35,6 +35,7 @@ import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.NoSuchThingException; import com.google.devtools.build.lib.packages.Package; +import com.google.devtools.build.lib.packages.PackageFactory; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions; import com.google.devtools.build.lib.packages.Target; @@ -44,7 +45,6 @@ import com.google.devtools.build.lib.skyframe.DiffAwareness; import com.google.devtools.build.lib.skyframe.PrecomputedValue; import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; -import com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.testutil.ManualClock; import com.google.devtools.build.lib.testutil.TestConstants; @@ -59,8 +59,6 @@ import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.build.lib.vfs.RootedPath; import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem; -import com.google.devtools.build.skyframe.SkyFunction; -import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsProvider; import java.io.FileNotFoundException; @@ -478,25 +476,19 @@ public PackageCacheTester(FileSystem fs, ManualClock clock) throws IOException { /* defaultSystemJavabase= */ null, loadingMock.getProductName()); ConfiguredRuleClassProvider ruleClassProvider = loadingMock.createRuleClassProvider(); + PackageFactory pkgFactory = + loadingMock.getPackageFactoryBuilderForTesting(directories).build(ruleClassProvider, fs); skyframeExecutor = - SequencedSkyframeExecutor.create( - loadingMock - .getPackageFactoryBuilderForTesting(directories) - .build(ruleClassProvider, fs), - fs, - directories, - actionKeyContext, - /* workspaceStatusActionFactory= */ null, - loadingMock.createRuleClassProvider().getBuildInfoFactories(), - ImmutableList.of(new ManualDiffAwarenessFactory()), - ImmutableMap.of(), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fs) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(loadingMock.createRuleClassProvider().getBuildInfoFactories()) + .setDefaultBuildOptions( + DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .setDiffAwarenessFactories(ImmutableList.of(new ManualDiffAwarenessFactory())) + .build(); TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class); packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PUBLIC; diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java index 23360f6be2b1d3..343b9fcdb33cb8 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java @@ -51,11 +51,8 @@ import com.google.devtools.build.lib.packages.util.MockToolsConfig; import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction; import com.google.devtools.build.lib.skyframe.BazelSkyframeExecutorConstants; -import com.google.devtools.build.lib.skyframe.DiffAwareness; import com.google.devtools.build.lib.skyframe.PatternExpandingError; import com.google.devtools.build.lib.skyframe.PrecomputedValue; -import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; -import com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.skyframe.TargetPatternPhaseValue; import com.google.devtools.build.lib.testutil.ManualClock; @@ -1097,22 +1094,15 @@ public LoadingPhaseTester() throws IOException { throw new RuntimeException(e); } skyframeExecutor = - SequencedSkyframeExecutor.create( - pkgFactory, - fs, - directories, - actionKeyContext, - null, /* workspaceStatusActionFactory -- not used */ - ruleClassProvider.getBuildInfoFactories(), - ImmutableList.of(), - analysisMock.getSkyFunctions(directories), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - defaultBuildOptions); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fs) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(ruleClassProvider.getBuildInfoFactories()) + .setDefaultBuildOptions(defaultBuildOptions) + .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) + .build(); TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); PathPackageLocator pkgLocator = PathPackageLocator.create( diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java index 0dc122ea5ae6ac..22a90e8373fdc8 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java @@ -39,10 +39,7 @@ import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction; import com.google.devtools.build.lib.skyframe.BazelSkyframeExecutorConstants; -import com.google.devtools.build.lib.skyframe.DiffAwareness; import com.google.devtools.build.lib.skyframe.PrecomputedValue; -import com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor; -import com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.syntax.BuildFileAST; import com.google.devtools.build.lib.testutil.FoundationTestCase; @@ -102,22 +99,15 @@ private void initializeSkyframeExecutor(boolean doPackageLoadingChecks) throws E throw new RuntimeException(e); } skyframeExecutor = - SequencedSkyframeExecutor.create( - packageFactoryBuilder.build(ruleClassProvider, fileSystem), - fileSystem, - directories, - actionKeyContext, - /* workspaceStatusActionFactory= */ null, - ruleClassProvider.getBuildInfoFactories(), - ImmutableList.of(), - analysisMock.getSkyFunctions(directories), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - BazelSkyframeExecutorConstants.ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE, - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - defaultBuildOptions); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(packageFactoryBuilder.build(ruleClassProvider, fileSystem)) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(actionKeyContext) + .setBuildInfoFactories(ruleClassProvider.getBuildInfoFactories()) + .setDefaultBuildOptions(defaultBuildOptions) + .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) + .build(); TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); setUpSkyframe(parsePackageCacheOptions(), parseSkylarkSemanticsOptions()); } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java index 8a86c99a5cfd4b..a7c87a05e95af0 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java @@ -31,6 +31,7 @@ import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.events.Reporter; +import com.google.devtools.build.lib.packages.PackageFactory; import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions; import com.google.devtools.build.lib.pkgcache.PackageCacheOptions; import com.google.devtools.build.lib.pkgcache.PathPackageLocator; @@ -80,25 +81,25 @@ public void setUp() throws Exception { /* defaultSystemJavabase= */ null, AnalysisMock.get().getProductName()); ConfiguredRuleClassProvider ruleClassProvider = AnalysisMock.get().createRuleClassProvider(); + + PackageFactory pkgFactory = + AnalysisMock.get() + .getPackageFactoryBuilderForTesting(directories) + .build(ruleClassProvider, fileSystem); skyframeExecutor = - SequencedSkyframeExecutor.create( - AnalysisMock.get() - .getPackageFactoryBuilderForTesting(directories) - .build(ruleClassProvider, fileSystem), - fileSystem, - directories, - new ActionKeyContext(), - /*workspaceStatusActionFactory=*/ null, - AnalysisMock.get().createRuleClassProvider().getBuildInfoFactories(), - ImmutableList.of(), - AnalysisMock.get().getSkyFunctions(directories), - ImmutableList.of(), - BazelSkyframeExecutorConstants.HARDCODED_BLACKLISTED_PACKAGE_PREFIXES, - PathFragment.create(ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING), - BazelSkyframeExecutorConstants.CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY, - BazelSkyframeExecutorConstants.BUILD_FILES_BY_PRIORITY, - BazelSkyframeExecutorConstants.ACTION_ON_IO_EXCEPTION_READING_BUILD_FILE, - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)); + BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() + .setPkgFactory(pkgFactory) + .setFileSystem(fileSystem) + .setDirectories(directories) + .setActionKeyContext(new ActionKeyContext()) + .setBuildInfoFactories( + AnalysisMock.get().createRuleClassProvider().getBuildInfoFactories()) + .setDefaultBuildOptions( + DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .setExtraSkyFunctions(AnalysisMock.get().getSkyFunctions(directories)) + .setAdditionalBlacklistedPackagePrefixesFile( + PathFragment.create(ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE_PATH_STRING)) + .build(); TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); skyframeExecutor.preparePackageLoading( new PathPackageLocator(