File tree Expand file tree Collapse file tree
src/main/java/com/google/devtools/build/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424import com .google .devtools .build .lib .actions .Artifact .ArtifactExpander ;
2525import com .google .devtools .build .lib .actions .Artifact .SpecialArtifact ;
2626import com .google .devtools .build .lib .actions .Artifact .TreeFileArtifact ;
27+ import com .google .devtools .build .lib .vfs .Path ;
2728import com .google .devtools .build .lib .vfs .PathFragment ;
2829import java .util .ArrayList ;
2930import java .util .Collection ;
@@ -218,4 +219,16 @@ public static List<ActionInput> expandArtifacts(Iterable<? extends ActionInput>
218219 public static Iterable <String > toExecPaths (Iterable <? extends ActionInput > artifacts ) {
219220 return Iterables .transform (artifacts , EXEC_PATH_STRING_FORMATTER );
220221 }
222+
223+ /**
224+ * Returns the {@link Path} for an {@link ActionInput}.
225+ */
226+ public static Path toPath (ActionInput input , Path execRoot ) {
227+ Preconditions .checkNotNull (input , "input" );
228+ Preconditions .checkNotNull (execRoot , "execRoot" );
229+
230+ return (input instanceof Artifact )
231+ ? ((Artifact ) input ).getPath ()
232+ : execRoot .getRelative (input .getExecPath ());
233+ }
221234}
Original file line number Diff line number Diff line change 1616import com .google .common .cache .Cache ;
1717import com .google .common .cache .CacheBuilder ;
1818import com .google .devtools .build .lib .actions .ActionInput ;
19+ import com .google .devtools .build .lib .actions .ActionInputHelper ;
1920import com .google .devtools .build .lib .actions .Artifact ;
2021import com .google .devtools .build .lib .actions .DigestOfDirectoryException ;
2122import com .google .devtools .build .lib .actions .FileArtifactValue ;
@@ -60,10 +61,7 @@ public FileArtifactValue getMetadata(ActionInput input) throws IOException {
6061 .get (
6162 input .getExecPathString (),
6263 () -> {
63- Path path =
64- (input instanceof Artifact )
65- ? ((Artifact ) input ).getPath ()
66- : execRoot .getRelative (input .getExecPath ());
64+ Path path = ActionInputHelper .toPath (input , execRoot );
6765 try {
6866 FileArtifactValue metadata = FileArtifactValue .create (path );
6967 if (metadata .getType ().isDirectory ()) {
Original file line number Diff line number Diff line change @@ -340,7 +340,7 @@ private TreeNode buildParentNode(
340340 Preconditions .checkArgument (
341341 inputsStart == inputsEnd - 1 , "Encountered two inputs with the same path." );
342342 ActionInput input = inputs .get (inputsStart );
343- Path leafPath = execRoot . getRelative (input . getExecPathString () );
343+ Path leafPath = ActionInputHelper . toPath (input , execRoot );
344344 if (!(input instanceof VirtualActionInput ) && uploadSymlinks ) {
345345 FileStatus stat = leafPath .stat (Symlinks .NOFOLLOW );
346346 if (stat .isSymbolicLink ()) {
@@ -405,7 +405,7 @@ private synchronized Directory getOrComputeDirectory(TreeNode node) throws IOExc
405405 if (uploadSymlinks ) {
406406 // We need to stat the input to check whether it is a symlink.
407407 // getInputMetadata only gives target metadata.
408- Path inputPath = execRoot . getRelative (input . getExecPath () );
408+ Path inputPath = ActionInputHelper . toPath (input , execRoot );
409409 FileStatus stat = inputPath .stat (Symlinks .NOFOLLOW );
410410 if (stat .isSymbolicLink ()) {
411411 PathFragment target = inputPath .readSymbolicLink ();
You can’t perform that action at this time.
0 commit comments