Skip to content

Commit

Permalink
Automated rollback of commit ceec93c.
Browse files Browse the repository at this point in the history
RELNOTES: None
PiperOrigin-RevId: 350794308
  • Loading branch information
aiuto authored and copybara-github committed Jan 8, 2021
1 parent fd44d30 commit 0f626a4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.actions.cache;

import com.google.common.base.Preconditions;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.FileArtifactValue;
import com.google.devtools.build.lib.util.StreamWriter;
Expand All @@ -26,11 +27,6 @@
* OutputStream.
*/
public interface VirtualActionInput extends ActionInput, StreamWriter {
/**
* An empty virtual artifact <b>without</b> an execpath. This is used to denote empty files in
* runfiles and filesets.
*/
public static final VirtualActionInput EMPTY_MARKER = new EmptyActionInput();

/**
* Gets a {@link ByteString} representation of the fake file. Used to avoid copying if the fake
Expand All @@ -52,7 +48,15 @@ default FileArtifactValue getMetadata() throws IOException {
* use instances of this class to represent those files.
*/
final class EmptyActionInput implements VirtualActionInput {
private EmptyActionInput() {}
private final PathFragment execPath;

public EmptyActionInput(PathFragment execPath) {
this.execPath = Preconditions.checkNotNull(execPath);
}

public EmptyActionInput(String execPath) {
this(PathFragment.create(execPath));
}

@Override
public boolean isSymlink() {
Expand All @@ -61,12 +65,12 @@ public boolean isSymlink() {

@Override
public String getExecPathString() {
throw new UnsupportedOperationException("empty virtual artifact doesn't have an execpath");
return execPath.getPathString();
}

@Override
public PathFragment getExecPath() {
throw new UnsupportedOperationException("empty virtual artifact doesn't have an execpath");
return execPath;
}

@Override
Expand All @@ -81,7 +85,7 @@ public ByteString getBytes() throws IOException {

@Override
public String toString() {
return "EmptyActionInput";
return "EmptyActionInput: " + execPath;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.google.devtools.build.lib.actions.MetadataProvider;
import com.google.devtools.build.lib.actions.RunfilesSupplier;
import com.google.devtools.build.lib.actions.Spawn;
import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
import com.google.devtools.build.lib.actions.cache.VirtualActionInput.EmptyActionInput;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.vfs.Path;
Expand All @@ -48,6 +48,8 @@
* laid out.
*/
public class SpawnInputExpander {
public static final ActionInput EMPTY_FILE = new EmptyActionInput("/dev/null");

private final Path execRoot;
private final boolean strict;
private final RelativeSymlinkBehavior relSymlinkBehavior;
Expand Down Expand Up @@ -146,7 +148,7 @@ void addRunfilesToInputs(
addMapping(inputMap, location, localArtifact);
}
} else {
addMapping(inputMap, location, VirtualActionInput.EMPTY_MARKER);
addMapping(inputMap, location, EMPTY_FILE);
}
}
}
Expand Down Expand Up @@ -194,10 +196,10 @@ void addFilesetManifest(

for (Map.Entry<PathFragment, String> mapping : filesetManifest.getEntries().entrySet()) {
String value = mapping.getValue();
ActionInput artifact =
value == null
? VirtualActionInput.EMPTY_MARKER
: ActionInputHelper.fromPath(execRoot.getRelative(value).getPathString());
ActionInput artifact =
value == null
? EMPTY_FILE
: ActionInputHelper.fromPath(execRoot.getRelative(value).getPathString());
addMapping(inputMappings, mapping.getKey(), artifact);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.google.devtools.build.lib.actions.FilesetOutputSymlink;
import com.google.devtools.build.lib.actions.RunfilesSupplier;
import com.google.devtools.build.lib.actions.Spawn;
import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.analysis.RunfilesSupplierImpl;
Expand Down Expand Up @@ -252,7 +251,7 @@ public void testRunfilesRootSymlink() throws Exception {
// directory gets created.
assertThat(inputMappings)
.containsEntry(
PathFragment.create("runfiles/workspace/.runfile"), VirtualActionInput.EMPTY_MARKER);
PathFragment.create("runfiles/workspace/.runfile"), SpawnInputExpander.EMPTY_FILE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.clock.JavaClock;
import com.google.devtools.build.lib.exec.SpawnInputExpander;
import com.google.devtools.build.lib.remote.options.RemoteOptions;
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.remote.util.InMemoryCacheClient;
Expand Down Expand Up @@ -140,7 +141,7 @@ public void testStagingEmptyVirtualActionInput() throws Exception {

// act
actionInputFetcher.prefetchFiles(
ImmutableList.of(VirtualActionInput.EMPTY_MARKER), metadataProvider);
ImmutableList.of(SpawnInputExpander.EMPTY_FILE), metadataProvider);

// assert that nothing happened
assertThat(actionInputFetcher.downloadedFiles()).isEmpty();
Expand Down

0 comments on commit 0f626a4

Please sign in to comment.