diff options
Diffstat (limited to 'src/main/java')
7 files changed, 75 insertions, 4 deletions
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 5a8b535ff9..32d02911e2 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 @@ -160,4 +160,7 @@ public interface AnalysisEnvironment extends ActionRegistry { ImmutableSet<Artifact> getTreeArtifactsConflictingWithFiles(); ActionKeyContext getActionKeyContext(); + + /** Informs Skyframe that the {@link ConfiguredTarget} accesses {@code source}. */ + default void registerSourceDependency(Artifact.SourceArtifact source) {} } 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 f54f723880..2cf31cf0cc 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 @@ -50,6 +50,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; +import java.util.function.Consumer; import javax.annotation.Nullable; /** @@ -83,6 +84,8 @@ public class CachingAnalysisEnvironment implements AnalysisEnvironment { */ final List<ActionAnalysisMetadata> actions = new ArrayList<>(); + private Consumer<Artifact.SourceArtifact> sourceDependencyListener; + public CachingAnalysisEnvironment( ArtifactFactory artifactFactory, ActionKeyContext actionKeyContext, @@ -90,7 +93,8 @@ public class CachingAnalysisEnvironment implements AnalysisEnvironment { boolean isSystemEnv, boolean extendedSanityChecks, ExtendedEventHandler errorEventListener, - SkyFunction.Environment env) { + SkyFunction.Environment env, + Consumer<Artifact.SourceArtifact> sourceDependencyListener) { this.artifactFactory = artifactFactory; this.actionKeyContext = actionKeyContext; this.owner = Preconditions.checkNotNull(owner); @@ -100,6 +104,7 @@ public class CachingAnalysisEnvironment implements AnalysisEnvironment { this.skyframeEnv = env; middlemanFactory = new MiddlemanFactory(artifactFactory, this); artifacts = new HashMap<>(); + this.sourceDependencyListener = sourceDependencyListener; } public void disable(Target target) { @@ -353,4 +358,9 @@ public class CachingAnalysisEnvironment implements AnalysisEnvironment { public ArtifactOwner getOwner() { return owner; } + + @Override + public void registerSourceDependency(Artifact.SourceArtifact source) { + sourceDependencyListener.accept(source); + } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java index e6dd22da7f..30861cd3ac 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredTargetFactory.java @@ -20,6 +20,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.Artifact.SourceArtifact; import com.google.devtools.build.lib.actions.ArtifactFactory; import com.google.devtools.build.lib.actions.ArtifactOwner; import com.google.devtools.build.lib.actions.ArtifactRoot; @@ -243,12 +244,12 @@ public final class ConfiguredTargetFactory { } } else if (target instanceof InputFile) { InputFile inputFile = (InputFile) target; - Artifact artifact = + SourceArtifact artifact = artifactFactory.getSourceArtifact( inputFile.getExecPath(), inputFile.getPackage().getSourceRoot(), ConfiguredTargetKey.of(target.getLabel(), config)); - + analysisEnvironment.registerSourceDependency(artifact); return new InputFileConfiguredTarget(targetContext, inputFile, artifact); } else if (target instanceof PackageGroup) { PackageGroup packageGroup = (PackageGroup) target; diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java index 93379b780f..60a22fb1c8 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java @@ -568,7 +568,8 @@ public final class SkyframeBuildView { isSystemEnv, extendedSanityChecks, eventHandler, - env); + env, + skyframeExecutor.getSourceDependencyListener((SkyKey) owner)); } /** 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 95537d629e..3fc728303d 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 @@ -174,6 +174,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import java.util.function.Supplier; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -2254,6 +2255,10 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { return patternParsingValue.toLoadingResult(eventHandler, packageManager); } + public Consumer<Artifact.SourceArtifact> getSourceDependencyListener(SkyKey key) { + return unusedSource -> {}; // Default, no-op implementation. + } + /** * A progress received to track analysis invalidation and update progress messages. */ diff --git a/src/main/java/com/google/devtools/build/skyframe/InterruptibleIOLongSupplier.java b/src/main/java/com/google/devtools/build/skyframe/InterruptibleIOLongSupplier.java new file mode 100644 index 0000000000..271f7b2f95 --- /dev/null +++ b/src/main/java/com/google/devtools/build/skyframe/InterruptibleIOLongSupplier.java @@ -0,0 +1,21 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.skyframe; + +import java.io.IOException; + +/** Wraps a deferred computation that returns a long and throws the noted exceptions. */ +public interface InterruptibleIOLongSupplier { + long getLong() throws InterruptedException, IOException; +} diff --git a/src/main/java/com/google/devtools/build/skyframe/TransitiveVersionTable.java b/src/main/java/com/google/devtools/build/skyframe/TransitiveVersionTable.java new file mode 100644 index 0000000000..210cff45b8 --- /dev/null +++ b/src/main/java/com/google/devtools/build/skyframe/TransitiveVersionTable.java @@ -0,0 +1,30 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.skyframe; + +import java.io.IOException; + +/** Readable view of transitive version information. */ +public interface TransitiveVersionTable { + + VersionAggregator get(SkyKey key); + + /** Encapsulates transitive version information. */ + interface VersionAggregator { + /** @return the maximum transitive source version or -1 if no sources were found */ + long getMaxTransitiveVersion( + long baselineVersion, InterruptibleIOLongSupplier deferredMaxDepVersion) + throws InterruptedException, IOException; + } +} |