diff options
author | ulfjack <ulfjack@google.com> | 2017-09-08 15:58:43 +0200 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2017-09-11 13:06:58 +0200 |
commit | 5c3467f2d251ae85889caca627794a8f9ff726b2 (patch) | |
tree | fb73e3d2f21637765430b06f0d8c1152cf8afd9b /src/main/java/com/google/devtools/build/lib/actions | |
parent | f322ba774727597b3238c33929c7ef2071f134b4 (diff) |
ActionInputFileCache: move getMetadata to a new super-interface
Update the callers that only need getMetadata to use the new interface.
PiperOrigin-RevId: 167992239
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions')
3 files changed, 47 insertions, 24 deletions
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 1257308718..477baa15da 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 @@ -419,13 +419,13 @@ public abstract class AbstractAction implements Action, SkylarkValue { * checking, this method must be called. */ protected void checkInputsForDirectories( - EventHandler eventHandler, ActionInputFileCache metadataHandler) throws ExecException { + EventHandler eventHandler, MetadataProvider metadataProvider) throws ExecException { // Report "directory dependency checking" warning only for non-generated directories (generated // ones will be reported earlier). for (Artifact input : getMandatoryInputs()) { // Assume that if the file did not exist, we would not have gotten here. try { - if (input.isSourceArtifact() && !metadataHandler.getMetadata(input).isFile()) { + if (input.isSourceArtifact() && !metadataProvider.getMetadata(input).isFile()) { eventHandler.handle(Event.warn(getOwner().getLocation(), "input '" + input.prettyPrint() + "' to " + getOwner().getLabel() + " is a directory; dependency checking of directories is unsound")); diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java b/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java index 1590445eb7..27b219d588 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionInputFileCache.java @@ -13,10 +13,8 @@ // limitations under the License. package com.google.devtools.build.lib.actions; -import com.google.devtools.build.lib.actions.cache.Metadata; import com.google.devtools.build.lib.vfs.Path; import com.google.protobuf.ByteString; -import java.io.IOException; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; @@ -26,26 +24,7 @@ import javax.annotation.concurrent.ThreadSafe; * NOTE: Implementations must be thread safe. */ @ThreadSafe -public interface ActionInputFileCache { - /** - * Returns digest for the given artifact. This digest is current as of some time t >= the start of - * the present build. If the artifact is an output of an action that already executed at time p, - * then t >= p. Aside from these properties, t can be any value and may vary arbitrarily across - * calls. - * - * The return value is owned by the cache and must not be modified. - * - * @param input the input to retrieve the digest for - * @return the artifact's digest or null if digest cannot be obtained (due to artifact - * non-existence, lookup errors, or any other reason) - * - * @throws DigestOfDirectoryException in case {@code input} is a directory. - * @throws IOException If the file cannot be digested. - * - */ - @Nullable - Metadata getMetadata(ActionInput input) throws IOException; - +public interface ActionInputFileCache extends MetadataProvider { /** * Checks if the file is available locally, based on the assumption that previous operations on * the ActionInputFileCache would have created a cache entry for it. diff --git a/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java b/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java new file mode 100644 index 0000000000..40d54b6c92 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/actions/MetadataProvider.java @@ -0,0 +1,44 @@ +// 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.actions; + +import com.google.devtools.build.lib.actions.cache.Metadata; +import java.io.IOException; +import javax.annotation.Nullable; + +/** + * The interface for Action inputs metadata (Digest and size). + * + * NOTE: Implementations must be thread safe. + */ +public interface MetadataProvider { + /** + * Returns digest for the given artifact. This digest is current as of some time t >= the start of + * the present build. If the artifact is an output of an action that already executed at time p, + * then t >= p. Aside from these properties, t can be any value and may vary arbitrarily across + * calls. + * + * The return value is owned by the cache and must not be modified. + * + * @param input the input to retrieve the digest for + * @return the artifact's digest or null if digest cannot be obtained (due to artifact + * non-existence, lookup errors, or any other reason) + * + * @throws DigestOfDirectoryException in case {@code input} is a directory. + * @throws IOException If the file cannot be digested. + * + */ + @Nullable + Metadata getMetadata(ActionInput input) throws IOException; +}
\ No newline at end of file |