aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar nharmata <nharmata@google.com>2017-12-05 09:27:45 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-05 09:29:47 -0800
commite4eb23fe5512760b0e4a80c19a98f43875051fb1 (patch)
tree65bf81551ea6410918c8a88af7ac4cb466b7437a /src/main
parent97facf3aee6332cdb5b6cf51f700f3efe1e6bf45 (diff)
Automated rollback of commit d0f06a6e4b61adc39bf5e1cfbae39501a89dc8e3.
RELNOTES: None PiperOrigin-RevId: 177965330
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/BazelSkyframeExecutorConstants.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/BlacklistedPackagePrefixesFunction.java73
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/PrecomputedValue.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java6
7 files changed, 73 insertions, 59 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
index 82a13773f8..f7b19ce28f 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
@@ -14,15 +14,23 @@
package com.google.devtools.build.lib.skyframe;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.packages.BuildFileName;
import com.google.devtools.build.lib.skyframe.PackageFunction.ActionOnIOExceptionReadingBuildFile;
import com.google.devtools.build.lib.skyframe.PackageLookupFunction.CrossRepositoryLabelViolationStrategy;
+import com.google.devtools.build.lib.vfs.PathFragment;
/** Hardcoded constants describing bazel-on-skyframe behavior. */
public class BazelSkyframeExecutorConstants {
private BazelSkyframeExecutorConstants() {
}
+ public static final ImmutableSet<PathFragment> HARDCODED_BLACKLISTED_PACKAGE_PREFIXES =
+ ImmutableSet.of();
+
+ public static final PathFragment ADDITIONAL_BLACKLISTED_PACKAGE_PREFIXES_FILE =
+ PathFragment.EMPTY_FRAGMENT;
+
public static final CrossRepositoryLabelViolationStrategy
CROSS_REPOSITORY_LABEL_VIOLATION_STRATEGY = CrossRepositoryLabelViolationStrategy.ERROR;
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BlacklistedPackagePrefixesFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/BlacklistedPackagePrefixesFunction.java
index a3c6768c96..713022c7e5 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/BlacklistedPackagePrefixesFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/BlacklistedPackagePrefixesFunction.java
@@ -24,58 +24,69 @@ import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionException;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
-
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
-
import javax.annotation.Nullable;
/**
- * A function that retrieves a set of blacklisted package pattern prefixes from the file given by
- * PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.
+ * A function that returns the union of a set of hardcoded blacklisted package prefixes and the
+ * contents of a hardcoded filepath whose contents is a blacklisted package prefix on each line.
*/
public class BlacklistedPackagePrefixesFunction implements SkyFunction {
+ private ImmutableSet<PathFragment> hardcodedBlacklistedPackagePrefixes;
+ private PathFragment additionalBlacklistedPackagePrefixesFile;
+
+ public BlacklistedPackagePrefixesFunction(
+ ImmutableSet<PathFragment> hardcodedBlacklistedPackagePrefixes,
+ PathFragment additionalBlacklistedPackagePrefixesFile) {
+ this.hardcodedBlacklistedPackagePrefixes = hardcodedBlacklistedPackagePrefixes;
+ this.additionalBlacklistedPackagePrefixesFile = additionalBlacklistedPackagePrefixesFile;
+ }
+
@Nullable
@Override
public SkyValue compute(SkyKey key, Environment env)
throws SkyFunctionException, InterruptedException {
- PathPackageLocator pkgLocator = PrecomputedValue.PATH_PACKAGE_LOCATOR.get(env);
- PathFragment patternsFile = PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.get(env);
- if (env.valuesMissing()) {
- return null;
- }
+ ImmutableSet.Builder<PathFragment> blacklistedPackagePrefixesBuilder = ImmutableSet.builder();
- if (patternsFile.equals(PathFragment.EMPTY_FRAGMENT)) {
- return new BlacklistedPackagePrefixesValue(ImmutableSet.<PathFragment>of());
- }
+ blacklistedPackagePrefixesBuilder.addAll(hardcodedBlacklistedPackagePrefixes);
- for (Path packagePathEntry : pkgLocator.getPathEntries()) {
- RootedPath rootedPatternFile = RootedPath.toRootedPath(packagePathEntry, patternsFile);
- FileValue patternFileValue = (FileValue) env.getValue(FileValue.key(rootedPatternFile));
- if (patternFileValue == null) {
+ if (!additionalBlacklistedPackagePrefixesFile.equals(PathFragment.EMPTY_FRAGMENT)) {
+ PathPackageLocator pkgLocator = PrecomputedValue.PATH_PACKAGE_LOCATOR.get(env);
+ if (env.valuesMissing()) {
return null;
}
- if (patternFileValue.isFile()) {
- try {
- try (InputStreamReader reader =
- new InputStreamReader(rootedPatternFile.asPath().getInputStream(),
- StandardCharsets.UTF_8)) {
- return new BlacklistedPackagePrefixesValue(
- CharStreams.readLines(reader, new PathFragmentLineProcessor()));
+
+ for (Path packagePathEntry : pkgLocator.getPathEntries()) {
+ RootedPath rootedPatternFile =
+ RootedPath.toRootedPath(packagePathEntry, additionalBlacklistedPackagePrefixesFile);
+ FileValue patternFileValue = (FileValue) env.getValue(FileValue.key(rootedPatternFile));
+ if (patternFileValue == null) {
+ return null;
+ }
+ if (patternFileValue.isFile()) {
+ try {
+ try (InputStreamReader reader =
+ new InputStreamReader(rootedPatternFile.asPath().getInputStream(),
+ StandardCharsets.UTF_8)) {
+ blacklistedPackagePrefixesBuilder.addAll(
+ CharStreams.readLines(reader, new PathFragmentLineProcessor()));
+ break;
+ }
+ } catch (IOException e) {
+ String errorMessage = e.getMessage() != null
+ ? "error '" + e.getMessage() + "'" : "an error";
+ throw new BlacklistedPatternsFunctionException(
+ new InconsistentFilesystemException(
+ rootedPatternFile.asPath() + " is not readable because: " + errorMessage
+ + ". Was it modified mid-build?"));
}
- } catch (IOException e) {
- String errorMessage = e.getMessage() != null
- ? "error '" + e.getMessage() + "'" : "an error";
- throw new BlacklistedPatternsFunctionException(
- new InconsistentFilesystemException(
- rootedPatternFile.asPath() + " is not readable because: " + errorMessage
- + ". Was it modified mid-build?"));
}
}
}
- return new BlacklistedPackagePrefixesValue(ImmutableSet.<PathFragment>of());
+ return new BlacklistedPackagePrefixesValue(blacklistedPackagePrefixesBuilder.build());
}
private static final class PathFragmentLineProcessor
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PrecomputedValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/PrecomputedValue.java
index 0d21adc540..8f5277a98a 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/PrecomputedValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/PrecomputedValue.java
@@ -26,7 +26,6 @@ import com.google.devtools.build.lib.packages.RuleVisibility;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
import com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.ConflictException;
import com.google.devtools.build.lib.syntax.SkylarkSemantics;
-import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.Injectable;
import com.google.devtools.build.skyframe.LegacySkyKey;
import com.google.devtools.build.skyframe.SkyFunction;
@@ -78,10 +77,6 @@ public final class PrecomputedValue implements SkyValue {
public static final Precomputed<String> DEFAULTS_PACKAGE_CONTENTS =
new Precomputed<>(LegacySkyKey.create(SkyFunctions.PRECOMPUTED, "default_pkg"));
- public static final Precomputed<PathFragment> BLACKLISTED_PACKAGE_PREFIXES_FILE =
- new Precomputed<>(
- LegacySkyKey.create(SkyFunctions.PRECOMPUTED, "blacklisted_package_prefixes_file"));
-
public static final Precomputed<RuleVisibility> DEFAULT_VISIBILITY =
new Precomputed<>(LegacySkyKey.create(SkyFunctions.PRECOMPUTED, "default_visibility"));
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 4e68fb7818..f3e4bf4da0 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
@@ -140,7 +140,8 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor {
Iterable<? extends DiffAwareness.Factory> diffAwarenessFactories,
ImmutableMap<SkyFunctionName, SkyFunction> extraSkyFunctions,
Iterable<SkyValueDirtinessChecker> customDirtinessCheckers,
- PathFragment blacklistedPackagePrefixesFile,
+ ImmutableSet<PathFragment> hardcodedBlacklistedPackagePrefixes,
+ PathFragment additionalBlacklistedPackagePrefixesFile,
CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy,
List<BuildFileName> buildFilesByPriority,
ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile) {
@@ -154,7 +155,8 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor {
buildInfoFactories,
extraSkyFunctions,
ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS,
- blacklistedPackagePrefixesFile,
+ hardcodedBlacklistedPackagePrefixes,
+ additionalBlacklistedPackagePrefixesFile,
crossRepositoryLabelViolationStrategy,
buildFilesByPriority,
actionOnIOExceptionReadingBuildFile);
@@ -172,7 +174,8 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor {
Iterable<? extends DiffAwareness.Factory> diffAwarenessFactories,
ImmutableMap<SkyFunctionName, SkyFunction> extraSkyFunctions,
Iterable<SkyValueDirtinessChecker> customDirtinessCheckers,
- PathFragment blacklistedPackagePrefixesFile,
+ ImmutableSet<PathFragment> hardcodedBlacklistedPackagePrefixes,
+ PathFragment additionalBlacklistedPackagePrefixesFile,
CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy,
List<BuildFileName> buildFilesByPriority,
ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile) {
@@ -188,7 +191,8 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor {
diffAwarenessFactories,
extraSkyFunctions,
customDirtinessCheckers,
- blacklistedPackagePrefixesFile,
+ hardcodedBlacklistedPackagePrefixes,
+ additionalBlacklistedPackagePrefixesFile,
crossRepositoryLabelViolationStrategy,
buildFilesByPriority,
actionOnIOExceptionReadingBuildFile);
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 c56469f0e7..f8c5b8babb 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.WorkspaceStatusAction.Factory;
import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory;
import com.google.devtools.build.lib.packages.PackageFactory;
import com.google.devtools.build.lib.vfs.FileSystem;
-import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionName;
@@ -51,7 +50,8 @@ public class SequencedSkyframeExecutorFactory implements SkyframeExecutorFactory
diffAwarenessFactories,
extraSkyFunctions,
customDirtinessCheckers,
- PathFragment.EMPTY_FRAGMENT,
+ 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);
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index 1e89fe5ff1..da4d4efef1 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -275,7 +275,8 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
private MutableSupplier<ImmutableList<ConfigurationFragmentFactory>> configurationFragments =
new MutableSupplier<>();
- private final PathFragment blacklistedPackagePrefixesFile;
+ private final ImmutableSet<PathFragment> hardcodedBlacklistedPackagePrefixes;
+ private final PathFragment additionalBlacklistedPackagePrefixesFile;
private final RuleClassProvider ruleClassProvider;
@@ -300,7 +301,8 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
ImmutableList<BuildInfoFactory> buildInfoFactories,
ImmutableMap<SkyFunctionName, SkyFunction> extraSkyFunctions,
ExternalFileAction externalFileAction,
- PathFragment blacklistedPackagePrefixesFile,
+ ImmutableSet<PathFragment> hardcodedBlacklistedPackagePrefixes,
+ PathFragment additionalBlacklistedPackagePrefixesFile,
CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy,
List<BuildFileName> buildFilesByPriority,
ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile) {
@@ -326,7 +328,8 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
this.buildInfoFactories = factoryMapBuilder.build();
this.extraSkyFunctions = extraSkyFunctions;
this.externalFileAction = externalFileAction;
- this.blacklistedPackagePrefixesFile = blacklistedPackagePrefixesFile;
+ this.hardcodedBlacklistedPackagePrefixes = hardcodedBlacklistedPackagePrefixes;
+ this.additionalBlacklistedPackagePrefixesFile = additionalBlacklistedPackagePrefixesFile;
this.ruleClassProvider = pkgFactory.getRuleClassProvider();
this.skyframeBuildView = new SkyframeBuildView(
@@ -384,7 +387,9 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
map.put(
SkyFunctions.COLLECT_PACKAGES_UNDER_DIRECTORY,
new CollectPackagesUnderDirectoryFunction(directories));
- map.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, new BlacklistedPackagePrefixesFunction());
+ map.put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES,
+ new BlacklistedPackagePrefixesFunction(
+ hardcodedBlacklistedPackagePrefixes, additionalBlacklistedPackagePrefixesFile));
map.put(SkyFunctions.TESTS_IN_SUITE, new TestsInSuiteFunction());
map.put(SkyFunctions.TEST_SUITE_EXPANSION, new TestSuiteExpansionFunction());
map.put(SkyFunctions.TARGET_PATTERN_PHASE, new TargetPatternPhaseFunction(pkgLocator));
@@ -577,11 +582,6 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
}
}
- @VisibleForTesting
- public PathFragment getBlacklistedPackagePrefixesFile() {
- return blacklistedPackagePrefixesFile;
- }
-
class BuildViewProvider {
/**
* Returns the current {@link SkyframeBuildView} instance.
@@ -994,11 +994,6 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
@VisibleForTesting // productionVisibility = Visibility.PRIVATE
public abstract void setDeletedPackages(Iterable<PackageIdentifier> pkgs);
- @VisibleForTesting
- public final void setBlacklistedPackagePrefixesFile(PathFragment blacklistedPkgFile) {
- PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set(injectable(), blacklistedPkgFile);
- }
-
/**
* Prepares the evaluator for loading.
*
@@ -1022,7 +1017,6 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory {
setCommandId(commandId);
PrecomputedValue.ACTION_ENV.set(injectable(), actionEnv);
this.clientEnv.set(clientEnv);
- setBlacklistedPackagePrefixesFile(getBlacklistedPackagePrefixesFile());
setShowLoadingProgress(packageCacheOptions.showLoadingProgress);
setDefaultVisibility(packageCacheOptions.defaultVisibility);
setSkylarkSemantics(skylarkSemanticsOptions);
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java
index 6ea1789ce3..a10deeb595 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java
@@ -271,7 +271,6 @@ public abstract class AbstractPackageLoader implements PackageLoader {
PrecomputedValue.DEFAULT_VISIBILITY.set(injectable, ConstantRuleVisibility.PRIVATE);
PrecomputedValue.SKYLARK_SEMANTICS.set(injectable, skylarkSemantics);
PrecomputedValue.DEFAULTS_PACKAGE_CONTENTS.set(injectable, defaultsPackageContents);
- PrecomputedValue.BLACKLISTED_PACKAGE_PREFIXES_FILE.set(injectable, PathFragment.EMPTY_FRAGMENT);
return new ImmutableDiff(ImmutableList.<SkyKey>of(), valuesToInject);
}
@@ -379,7 +378,10 @@ public abstract class AbstractPackageLoader implements PackageLoader {
/* deletedPackages= */ new AtomicReference<>(ImmutableSet.<PackageIdentifier>of()),
getCrossRepositoryLabelViolationStrategy(),
getBuildFilesByPriority()))
- .put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES, new BlacklistedPackagePrefixesFunction())
+ .put(SkyFunctions.BLACKLISTED_PACKAGE_PREFIXES,
+ new BlacklistedPackagePrefixesFunction(
+ /*hardcodedBlacklistedPackagePrefixes=*/ ImmutableSet.of(),
+ /*additionalBlacklistedPackagePrefixesFile=*/ PathFragment.EMPTY_FRAGMENT))
.put(SkyFunctions.CONTAINING_PACKAGE_LOOKUP, new ContainingPackageLookupFunction())
.put(SkyFunctions.AST_FILE_LOOKUP, new ASTFileLookupFunction(ruleClassProvider))
.put(